babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722
  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/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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 | undefined, forcedExtension: any): InternalTexture;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * 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.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * 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.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Represents an Dual Shock controller
  12300. */
  12301. static DUALSHOCK: number;
  12302. /**
  12303. * Specifies whether the left control stick should be Y-inverted
  12304. */
  12305. protected _invertLeftStickY: boolean;
  12306. /**
  12307. * Specifies if the gamepad has been connected
  12308. */
  12309. readonly isConnected: boolean;
  12310. /**
  12311. * Initializes the gamepad
  12312. * @param id The id of the gamepad
  12313. * @param index The index of the gamepad
  12314. * @param browserGamepad The browser gamepad
  12315. * @param leftStickX The x component of the left joystick
  12316. * @param leftStickY The y component of the left joystick
  12317. * @param rightStickX The x component of the right joystick
  12318. * @param rightStickY The y component of the right joystick
  12319. */
  12320. constructor(
  12321. /**
  12322. * The id of the gamepad
  12323. */
  12324. id: string,
  12325. /**
  12326. * The index of the gamepad
  12327. */
  12328. index: number,
  12329. /**
  12330. * The browser gamepad
  12331. */
  12332. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12333. /**
  12334. * Callback triggered when the left joystick has changed
  12335. * @param callback
  12336. */
  12337. onleftstickchanged(callback: (values: StickValues) => void): void;
  12338. /**
  12339. * Callback triggered when the right joystick has changed
  12340. * @param callback
  12341. */
  12342. onrightstickchanged(callback: (values: StickValues) => void): void;
  12343. /**
  12344. * Gets the left joystick
  12345. */
  12346. /**
  12347. * Sets the left joystick values
  12348. */
  12349. leftStick: StickValues;
  12350. /**
  12351. * Gets the right joystick
  12352. */
  12353. /**
  12354. * Sets the right joystick value
  12355. */
  12356. rightStick: StickValues;
  12357. /**
  12358. * Updates the gamepad joystick positions
  12359. */
  12360. update(): void;
  12361. /**
  12362. * Disposes the gamepad
  12363. */
  12364. dispose(): void;
  12365. }
  12366. /**
  12367. * Represents a generic gamepad
  12368. */
  12369. export class GenericPad extends Gamepad {
  12370. private _buttons;
  12371. private _onbuttondown;
  12372. private _onbuttonup;
  12373. /**
  12374. * Observable triggered when a button has been pressed
  12375. */
  12376. onButtonDownObservable: Observable<number>;
  12377. /**
  12378. * Observable triggered when a button has been released
  12379. */
  12380. onButtonUpObservable: Observable<number>;
  12381. /**
  12382. * Callback triggered when a button has been pressed
  12383. * @param callback Called when a button has been pressed
  12384. */
  12385. onbuttondown(callback: (buttonPressed: number) => void): void;
  12386. /**
  12387. * Callback triggered when a button has been released
  12388. * @param callback Called when a button has been released
  12389. */
  12390. onbuttonup(callback: (buttonReleased: number) => void): void;
  12391. /**
  12392. * Initializes the generic gamepad
  12393. * @param id The id of the generic gamepad
  12394. * @param index The index of the generic gamepad
  12395. * @param browserGamepad The browser gamepad
  12396. */
  12397. constructor(id: string, index: number, browserGamepad: any);
  12398. private _setButtonValue;
  12399. /**
  12400. * Updates the generic gamepad
  12401. */
  12402. update(): void;
  12403. /**
  12404. * Disposes the generic gamepad
  12405. */
  12406. dispose(): void;
  12407. }
  12408. }
  12409. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12410. import { Nullable } from "babylonjs/types";
  12411. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12412. import { Scene } from "babylonjs/scene";
  12413. module "babylonjs/Engines/engine" {
  12414. interface Engine {
  12415. /**
  12416. * Creates a raw texture
  12417. * @param data defines the data to store in the texture
  12418. * @param width defines the width of the texture
  12419. * @param height defines the height of the texture
  12420. * @param format defines the format of the data
  12421. * @param generateMipMaps defines if the engine should generate the mip levels
  12422. * @param invertY defines if data must be stored with Y axis inverted
  12423. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12424. * @param compression defines the compression used (null by default)
  12425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12426. * @returns the raw texture inside an InternalTexture
  12427. */
  12428. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12429. /**
  12430. * Update a raw texture
  12431. * @param texture defines the texture to update
  12432. * @param data defines the data to store in the texture
  12433. * @param format defines the format of the data
  12434. * @param invertY defines if data must be stored with Y axis inverted
  12435. */
  12436. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12437. /**
  12438. * Update a raw texture
  12439. * @param texture defines the texture to update
  12440. * @param data defines the data to store in the texture
  12441. * @param format defines the format of the data
  12442. * @param invertY defines if data must be stored with Y axis inverted
  12443. * @param compression defines the compression used (null by default)
  12444. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12445. */
  12446. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12447. /**
  12448. * Creates a new raw cube texture
  12449. * @param data defines the array of data to use to create each face
  12450. * @param size defines the size of the textures
  12451. * @param format defines the format of the data
  12452. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12453. * @param generateMipMaps defines if the engine should generate the mip levels
  12454. * @param invertY defines if data must be stored with Y axis inverted
  12455. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12456. * @param compression defines the compression used (null by default)
  12457. * @returns the cube texture as an InternalTexture
  12458. */
  12459. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12460. /**
  12461. * Update a raw cube texture
  12462. * @param texture defines the texture to udpdate
  12463. * @param data defines the data to store
  12464. * @param format defines the data format
  12465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12466. * @param invertY defines if data must be stored with Y axis inverted
  12467. */
  12468. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12469. /**
  12470. * Update a raw cube texture
  12471. * @param texture defines the texture to udpdate
  12472. * @param data defines the data to store
  12473. * @param format defines the data format
  12474. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12475. * @param invertY defines if data must be stored with Y axis inverted
  12476. * @param compression defines the compression used (null by default)
  12477. */
  12478. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12479. /**
  12480. * Update a raw cube texture
  12481. * @param texture defines the texture to udpdate
  12482. * @param data defines the data to store
  12483. * @param format defines the data format
  12484. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12485. * @param invertY defines if data must be stored with Y axis inverted
  12486. * @param compression defines the compression used (null by default)
  12487. * @param level defines which level of the texture to update
  12488. */
  12489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12490. /**
  12491. * Creates a new raw cube texture from a specified url
  12492. * @param url defines the url where the data is located
  12493. * @param scene defines the current scene
  12494. * @param size defines the size of the textures
  12495. * @param format defines the format of the data
  12496. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12497. * @param noMipmap defines if the engine should avoid generating the mip levels
  12498. * @param callback defines a callback used to extract texture data from loaded data
  12499. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12500. * @param onLoad defines a callback called when texture is loaded
  12501. * @param onError defines a callback called if there is an error
  12502. * @returns the cube texture as an InternalTexture
  12503. */
  12504. 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>): InternalTexture;
  12505. /**
  12506. * Creates a new raw cube texture from a specified url
  12507. * @param url defines the url where the data is located
  12508. * @param scene defines the current scene
  12509. * @param size defines the size of the textures
  12510. * @param format defines the format of the data
  12511. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12512. * @param noMipmap defines if the engine should avoid generating the mip levels
  12513. * @param callback defines a callback used to extract texture data from loaded data
  12514. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12515. * @param onLoad defines a callback called when texture is loaded
  12516. * @param onError defines a callback called if there is an error
  12517. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12518. * @param invertY defines if data must be stored with Y axis inverted
  12519. * @returns the cube texture as an InternalTexture
  12520. */
  12521. 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;
  12522. /**
  12523. * Creates a new raw 3D texture
  12524. * @param data defines the data used to create the texture
  12525. * @param width defines the width of the texture
  12526. * @param height defines the height of the texture
  12527. * @param depth defines the depth of the texture
  12528. * @param format defines the format of the texture
  12529. * @param generateMipMaps defines if the engine must generate mip levels
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12532. * @param compression defines the compressed used (can be null)
  12533. * @param textureType defines the compressed used (can be null)
  12534. * @returns a new raw 3D texture (stored in an InternalTexture)
  12535. */
  12536. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12537. /**
  12538. * Update a raw 3D texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store
  12541. * @param format defines the data format
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. */
  12544. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12545. /**
  12546. * Update a raw 3D texture
  12547. * @param texture defines the texture to update
  12548. * @param data defines the data to store
  12549. * @param format defines the data format
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param compression defines the used compression (can be null)
  12552. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12553. */
  12554. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12555. }
  12556. }
  12557. }
  12558. declare module "babylonjs/Materials/Textures/rawTexture" {
  12559. import { Scene } from "babylonjs/scene";
  12560. import { Texture } from "babylonjs/Materials/Textures/texture";
  12561. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12562. /**
  12563. * Raw texture can help creating a texture directly from an array of data.
  12564. * This can be super useful if you either get the data from an uncompressed source or
  12565. * if you wish to create your texture pixel by pixel.
  12566. */
  12567. export class RawTexture extends Texture {
  12568. /**
  12569. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12570. */
  12571. format: number;
  12572. private _engine;
  12573. /**
  12574. * Instantiates a new RawTexture.
  12575. * Raw texture can help creating a texture directly from an array of data.
  12576. * This can be super useful if you either get the data from an uncompressed source or
  12577. * if you wish to create your texture pixel by pixel.
  12578. * @param data define the array of data to use to create the texture
  12579. * @param width define the width of the texture
  12580. * @param height define the height of the texture
  12581. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12582. * @param scene define the scene the texture belongs to
  12583. * @param generateMipMaps define whether mip maps should be generated or not
  12584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12587. */
  12588. constructor(data: ArrayBufferView, width: number, height: number,
  12589. /**
  12590. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12591. */
  12592. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12593. /**
  12594. * Updates the texture underlying data.
  12595. * @param data Define the new data of the texture
  12596. */
  12597. update(data: ArrayBufferView): void;
  12598. /**
  12599. * Creates a luminance texture from some data.
  12600. * @param data Define the texture data
  12601. * @param width Define the width of the texture
  12602. * @param height Define the height of the texture
  12603. * @param scene Define the scene the texture belongs to
  12604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12607. * @returns the luminance texture
  12608. */
  12609. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12610. /**
  12611. * Creates a luminance alpha texture from some data.
  12612. * @param data Define the texture data
  12613. * @param width Define the width of the texture
  12614. * @param height Define the height of the texture
  12615. * @param scene Define the scene the texture belongs to
  12616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12619. * @returns the luminance alpha texture
  12620. */
  12621. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12622. /**
  12623. * Creates an alpha texture from some data.
  12624. * @param data Define the texture data
  12625. * @param width Define the width of the texture
  12626. * @param height Define the height of the texture
  12627. * @param scene Define the scene the texture belongs to
  12628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12631. * @returns the alpha texture
  12632. */
  12633. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12634. /**
  12635. * Creates a RGB texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12644. * @returns the RGB alpha texture
  12645. */
  12646. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12647. /**
  12648. * Creates a RGBA texture from some data.
  12649. * @param data Define the texture data
  12650. * @param width Define the width of the texture
  12651. * @param height Define the height of the texture
  12652. * @param scene Define the scene the texture belongs to
  12653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12657. * @returns the RGBA texture
  12658. */
  12659. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12660. /**
  12661. * Creates a R texture from some data.
  12662. * @param data Define the texture data
  12663. * @param width Define the width of the texture
  12664. * @param height Define the height of the texture
  12665. * @param scene Define the scene the texture belongs to
  12666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12670. * @returns the R texture
  12671. */
  12672. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12673. }
  12674. }
  12675. declare module "babylonjs/Maths/math.size" {
  12676. /**
  12677. * Interface for the size containing width and height
  12678. */
  12679. export interface ISize {
  12680. /**
  12681. * Width
  12682. */
  12683. width: number;
  12684. /**
  12685. * Heighht
  12686. */
  12687. height: number;
  12688. }
  12689. /**
  12690. * Size containing widht and height
  12691. */
  12692. export class Size implements ISize {
  12693. /**
  12694. * Width
  12695. */
  12696. width: number;
  12697. /**
  12698. * Height
  12699. */
  12700. height: number;
  12701. /**
  12702. * Creates a Size object from the given width and height (floats).
  12703. * @param width width of the new size
  12704. * @param height height of the new size
  12705. */
  12706. constructor(width: number, height: number);
  12707. /**
  12708. * Returns a string with the Size width and height
  12709. * @returns a string with the Size width and height
  12710. */
  12711. toString(): string;
  12712. /**
  12713. * "Size"
  12714. * @returns the string "Size"
  12715. */
  12716. getClassName(): string;
  12717. /**
  12718. * Returns the Size hash code.
  12719. * @returns a hash code for a unique width and height
  12720. */
  12721. getHashCode(): number;
  12722. /**
  12723. * Updates the current size from the given one.
  12724. * @param src the given size
  12725. */
  12726. copyFrom(src: Size): void;
  12727. /**
  12728. * Updates in place the current Size from the given floats.
  12729. * @param width width of the new size
  12730. * @param height height of the new size
  12731. * @returns the updated Size.
  12732. */
  12733. copyFromFloats(width: number, height: number): Size;
  12734. /**
  12735. * Updates in place the current Size from the given floats.
  12736. * @param width width to set
  12737. * @param height height to set
  12738. * @returns the updated Size.
  12739. */
  12740. set(width: number, height: number): Size;
  12741. /**
  12742. * Multiplies the width and height by numbers
  12743. * @param w factor to multiple the width by
  12744. * @param h factor to multiple the height by
  12745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12746. */
  12747. multiplyByFloats(w: number, h: number): Size;
  12748. /**
  12749. * Clones the size
  12750. * @returns a new Size copied from the given one.
  12751. */
  12752. clone(): Size;
  12753. /**
  12754. * True if the current Size and the given one width and height are strictly equal.
  12755. * @param other the other size to compare against
  12756. * @returns True if the current Size and the given one width and height are strictly equal.
  12757. */
  12758. equals(other: Size): boolean;
  12759. /**
  12760. * The surface of the Size : width * height (float).
  12761. */
  12762. readonly surface: number;
  12763. /**
  12764. * Create a new size of zero
  12765. * @returns a new Size set to (0.0, 0.0)
  12766. */
  12767. static Zero(): Size;
  12768. /**
  12769. * Sums the width and height of two sizes
  12770. * @param otherSize size to add to this size
  12771. * @returns a new Size set as the addition result of the current Size and the given one.
  12772. */
  12773. add(otherSize: Size): Size;
  12774. /**
  12775. * Subtracts the width and height of two
  12776. * @param otherSize size to subtract to this size
  12777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12778. */
  12779. subtract(otherSize: Size): Size;
  12780. /**
  12781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. * @param start starting size to lerp between
  12783. * @param end end size to lerp between
  12784. * @param amount amount to lerp between the start and end values
  12785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12786. */
  12787. static Lerp(start: Size, end: Size, amount: number): Size;
  12788. }
  12789. }
  12790. declare module "babylonjs/Animations/runtimeAnimation" {
  12791. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12792. import { Animatable } from "babylonjs/Animations/animatable";
  12793. import { Scene } from "babylonjs/scene";
  12794. /**
  12795. * Defines a runtime animation
  12796. */
  12797. export class RuntimeAnimation {
  12798. private _events;
  12799. /**
  12800. * The current frame of the runtime animation
  12801. */
  12802. private _currentFrame;
  12803. /**
  12804. * The animation used by the runtime animation
  12805. */
  12806. private _animation;
  12807. /**
  12808. * The target of the runtime animation
  12809. */
  12810. private _target;
  12811. /**
  12812. * The initiating animatable
  12813. */
  12814. private _host;
  12815. /**
  12816. * The original value of the runtime animation
  12817. */
  12818. private _originalValue;
  12819. /**
  12820. * The original blend value of the runtime animation
  12821. */
  12822. private _originalBlendValue;
  12823. /**
  12824. * The offsets cache of the runtime animation
  12825. */
  12826. private _offsetsCache;
  12827. /**
  12828. * The high limits cache of the runtime animation
  12829. */
  12830. private _highLimitsCache;
  12831. /**
  12832. * Specifies if the runtime animation has been stopped
  12833. */
  12834. private _stopped;
  12835. /**
  12836. * The blending factor of the runtime animation
  12837. */
  12838. private _blendingFactor;
  12839. /**
  12840. * The BabylonJS scene
  12841. */
  12842. private _scene;
  12843. /**
  12844. * The current value of the runtime animation
  12845. */
  12846. private _currentValue;
  12847. /** @hidden */
  12848. _animationState: _IAnimationState;
  12849. /**
  12850. * The active target of the runtime animation
  12851. */
  12852. private _activeTargets;
  12853. private _currentActiveTarget;
  12854. private _directTarget;
  12855. /**
  12856. * The target path of the runtime animation
  12857. */
  12858. private _targetPath;
  12859. /**
  12860. * The weight of the runtime animation
  12861. */
  12862. private _weight;
  12863. /**
  12864. * The ratio offset of the runtime animation
  12865. */
  12866. private _ratioOffset;
  12867. /**
  12868. * The previous delay of the runtime animation
  12869. */
  12870. private _previousDelay;
  12871. /**
  12872. * The previous ratio of the runtime animation
  12873. */
  12874. private _previousRatio;
  12875. private _enableBlending;
  12876. private _keys;
  12877. private _minFrame;
  12878. private _maxFrame;
  12879. private _minValue;
  12880. private _maxValue;
  12881. private _targetIsArray;
  12882. /**
  12883. * Gets the current frame of the runtime animation
  12884. */
  12885. readonly currentFrame: number;
  12886. /**
  12887. * Gets the weight of the runtime animation
  12888. */
  12889. readonly weight: number;
  12890. /**
  12891. * Gets the current value of the runtime animation
  12892. */
  12893. readonly currentValue: any;
  12894. /**
  12895. * Gets the target path of the runtime animation
  12896. */
  12897. readonly targetPath: string;
  12898. /**
  12899. * Gets the actual target of the runtime animation
  12900. */
  12901. readonly target: any;
  12902. /** @hidden */
  12903. _onLoop: () => void;
  12904. /**
  12905. * Create a new RuntimeAnimation object
  12906. * @param target defines the target of the animation
  12907. * @param animation defines the source animation object
  12908. * @param scene defines the hosting scene
  12909. * @param host defines the initiating Animatable
  12910. */
  12911. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12912. private _preparePath;
  12913. /**
  12914. * Gets the animation from the runtime animation
  12915. */
  12916. readonly animation: Animation;
  12917. /**
  12918. * Resets the runtime animation to the beginning
  12919. * @param restoreOriginal defines whether to restore the target property to the original value
  12920. */
  12921. reset(restoreOriginal?: boolean): void;
  12922. /**
  12923. * Specifies if the runtime animation is stopped
  12924. * @returns Boolean specifying if the runtime animation is stopped
  12925. */
  12926. isStopped(): boolean;
  12927. /**
  12928. * Disposes of the runtime animation
  12929. */
  12930. dispose(): void;
  12931. /**
  12932. * Apply the interpolated value to the target
  12933. * @param currentValue defines the value computed by the animation
  12934. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12935. */
  12936. setValue(currentValue: any, weight: number): void;
  12937. private _getOriginalValues;
  12938. private _setValue;
  12939. /**
  12940. * Gets the loop pmode of the runtime animation
  12941. * @returns Loop Mode
  12942. */
  12943. private _getCorrectLoopMode;
  12944. /**
  12945. * Move the current animation to a given frame
  12946. * @param frame defines the frame to move to
  12947. */
  12948. goToFrame(frame: number): void;
  12949. /**
  12950. * @hidden Internal use only
  12951. */
  12952. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12953. /**
  12954. * Execute the current animation
  12955. * @param delay defines the delay to add to the current frame
  12956. * @param from defines the lower bound of the animation range
  12957. * @param to defines the upper bound of the animation range
  12958. * @param loop defines if the current animation must loop
  12959. * @param speedRatio defines the current speed ratio
  12960. * @param weight defines the weight of the animation (default is -1 so no weight)
  12961. * @param onLoop optional callback called when animation loops
  12962. * @returns a boolean indicating if the animation is running
  12963. */
  12964. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12965. }
  12966. }
  12967. declare module "babylonjs/Animations/animatable" {
  12968. import { Animation } from "babylonjs/Animations/animation";
  12969. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12970. import { Nullable } from "babylonjs/types";
  12971. import { Observable } from "babylonjs/Misc/observable";
  12972. import { Scene } from "babylonjs/scene";
  12973. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12974. import { Node } from "babylonjs/node";
  12975. /**
  12976. * Class used to store an actual running animation
  12977. */
  12978. export class Animatable {
  12979. /** defines the target object */
  12980. target: any;
  12981. /** defines the starting frame number (default is 0) */
  12982. fromFrame: number;
  12983. /** defines the ending frame number (default is 100) */
  12984. toFrame: number;
  12985. /** defines if the animation must loop (default is false) */
  12986. loopAnimation: boolean;
  12987. /** defines a callback to call when animation ends if it is not looping */
  12988. onAnimationEnd?: (() => void) | null | undefined;
  12989. /** defines a callback to call when animation loops */
  12990. onAnimationLoop?: (() => void) | null | undefined;
  12991. private _localDelayOffset;
  12992. private _pausedDelay;
  12993. private _runtimeAnimations;
  12994. private _paused;
  12995. private _scene;
  12996. private _speedRatio;
  12997. private _weight;
  12998. private _syncRoot;
  12999. /**
  13000. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13001. * This will only apply for non looping animation (default is true)
  13002. */
  13003. disposeOnEnd: boolean;
  13004. /**
  13005. * Gets a boolean indicating if the animation has started
  13006. */
  13007. animationStarted: boolean;
  13008. /**
  13009. * Observer raised when the animation ends
  13010. */
  13011. onAnimationEndObservable: Observable<Animatable>;
  13012. /**
  13013. * Observer raised when the animation loops
  13014. */
  13015. onAnimationLoopObservable: Observable<Animatable>;
  13016. /**
  13017. * Gets the root Animatable used to synchronize and normalize animations
  13018. */
  13019. readonly syncRoot: Nullable<Animatable>;
  13020. /**
  13021. * Gets the current frame of the first RuntimeAnimation
  13022. * Used to synchronize Animatables
  13023. */
  13024. readonly masterFrame: number;
  13025. /**
  13026. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13027. */
  13028. weight: number;
  13029. /**
  13030. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13031. */
  13032. speedRatio: number;
  13033. /**
  13034. * Creates a new Animatable
  13035. * @param scene defines the hosting scene
  13036. * @param target defines the target object
  13037. * @param fromFrame defines the starting frame number (default is 0)
  13038. * @param toFrame defines the ending frame number (default is 100)
  13039. * @param loopAnimation defines if the animation must loop (default is false)
  13040. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13041. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13042. * @param animations defines a group of animation to add to the new Animatable
  13043. * @param onAnimationLoop defines a callback to call when animation loops
  13044. */
  13045. constructor(scene: Scene,
  13046. /** defines the target object */
  13047. target: any,
  13048. /** defines the starting frame number (default is 0) */
  13049. fromFrame?: number,
  13050. /** defines the ending frame number (default is 100) */
  13051. toFrame?: number,
  13052. /** defines if the animation must loop (default is false) */
  13053. loopAnimation?: boolean, speedRatio?: number,
  13054. /** defines a callback to call when animation ends if it is not looping */
  13055. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13056. /** defines a callback to call when animation loops */
  13057. onAnimationLoop?: (() => void) | null | undefined);
  13058. /**
  13059. * Synchronize and normalize current Animatable with a source Animatable
  13060. * This is useful when using animation weights and when animations are not of the same length
  13061. * @param root defines the root Animatable to synchronize with
  13062. * @returns the current Animatable
  13063. */
  13064. syncWith(root: Animatable): Animatable;
  13065. /**
  13066. * Gets the list of runtime animations
  13067. * @returns an array of RuntimeAnimation
  13068. */
  13069. getAnimations(): RuntimeAnimation[];
  13070. /**
  13071. * Adds more animations to the current animatable
  13072. * @param target defines the target of the animations
  13073. * @param animations defines the new animations to add
  13074. */
  13075. appendAnimations(target: any, animations: Animation[]): void;
  13076. /**
  13077. * Gets the source animation for a specific property
  13078. * @param property defines the propertyu to look for
  13079. * @returns null or the source animation for the given property
  13080. */
  13081. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13082. /**
  13083. * Gets the runtime animation for a specific property
  13084. * @param property defines the propertyu to look for
  13085. * @returns null or the runtime animation for the given property
  13086. */
  13087. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13088. /**
  13089. * Resets the animatable to its original state
  13090. */
  13091. reset(): void;
  13092. /**
  13093. * Allows the animatable to blend with current running animations
  13094. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13095. * @param blendingSpeed defines the blending speed to use
  13096. */
  13097. enableBlending(blendingSpeed: number): void;
  13098. /**
  13099. * Disable animation blending
  13100. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13101. */
  13102. disableBlending(): void;
  13103. /**
  13104. * Jump directly to a given frame
  13105. * @param frame defines the frame to jump to
  13106. */
  13107. goToFrame(frame: number): void;
  13108. /**
  13109. * Pause the animation
  13110. */
  13111. pause(): void;
  13112. /**
  13113. * Restart the animation
  13114. */
  13115. restart(): void;
  13116. private _raiseOnAnimationEnd;
  13117. /**
  13118. * Stop and delete the current animation
  13119. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13120. * @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)
  13121. */
  13122. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13123. /**
  13124. * Wait asynchronously for the animation to end
  13125. * @returns a promise which will be fullfilled when the animation ends
  13126. */
  13127. waitAsync(): Promise<Animatable>;
  13128. /** @hidden */
  13129. _animate(delay: number): boolean;
  13130. }
  13131. module "babylonjs/scene" {
  13132. interface Scene {
  13133. /** @hidden */
  13134. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13135. /** @hidden */
  13136. _processLateAnimationBindingsForMatrices(holder: {
  13137. totalWeight: number;
  13138. animations: RuntimeAnimation[];
  13139. originalValue: Matrix;
  13140. }): any;
  13141. /** @hidden */
  13142. _processLateAnimationBindingsForQuaternions(holder: {
  13143. totalWeight: number;
  13144. animations: RuntimeAnimation[];
  13145. originalValue: Quaternion;
  13146. }, refQuaternion: Quaternion): Quaternion;
  13147. /** @hidden */
  13148. _processLateAnimationBindings(): void;
  13149. /**
  13150. * Will start the animation sequence of a given target
  13151. * @param target defines the target
  13152. * @param from defines from which frame should animation start
  13153. * @param to defines until which frame should animation run.
  13154. * @param weight defines the weight to apply to the animation (1.0 by default)
  13155. * @param loop defines if the animation loops
  13156. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13157. * @param onAnimationEnd defines the function to be executed when the animation ends
  13158. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13159. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13160. * @param onAnimationLoop defines the callback to call when an animation loops
  13161. * @returns the animatable object created for this animation
  13162. */
  13163. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13164. /**
  13165. * Will start the animation sequence of a given target
  13166. * @param target defines the target
  13167. * @param from defines from which frame should animation start
  13168. * @param to defines until which frame should animation run.
  13169. * @param loop defines if the animation loops
  13170. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13171. * @param onAnimationEnd defines the function to be executed when the animation ends
  13172. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13173. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13174. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13175. * @param onAnimationLoop defines the callback to call when an animation loops
  13176. * @returns the animatable object created for this animation
  13177. */
  13178. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13179. /**
  13180. * Will start the animation sequence of a given target and its hierarchy
  13181. * @param target defines the target
  13182. * @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.
  13183. * @param from defines from which frame should animation start
  13184. * @param to defines until which frame should animation run.
  13185. * @param loop defines if the animation loops
  13186. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13187. * @param onAnimationEnd defines the function to be executed when the animation ends
  13188. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13189. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13190. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13191. * @param onAnimationLoop defines the callback to call when an animation loops
  13192. * @returns the list of created animatables
  13193. */
  13194. 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[];
  13195. /**
  13196. * Begin a new animation on a given node
  13197. * @param target defines the target where the animation will take place
  13198. * @param animations defines the list of animations to start
  13199. * @param from defines the initial value
  13200. * @param to defines the final value
  13201. * @param loop defines if you want animation to loop (off by default)
  13202. * @param speedRatio defines the speed ratio to apply to all animations
  13203. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13204. * @param onAnimationLoop defines the callback to call when an animation loops
  13205. * @returns the list of created animatables
  13206. */
  13207. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13208. /**
  13209. * Begin a new animation on a given node and its hierarchy
  13210. * @param target defines the root node where the animation will take place
  13211. * @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.
  13212. * @param animations defines the list of animations to start
  13213. * @param from defines the initial value
  13214. * @param to defines the final value
  13215. * @param loop defines if you want animation to loop (off by default)
  13216. * @param speedRatio defines the speed ratio to apply to all animations
  13217. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13218. * @param onAnimationLoop defines the callback to call when an animation loops
  13219. * @returns the list of animatables created for all nodes
  13220. */
  13221. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13222. /**
  13223. * Gets the animatable associated with a specific target
  13224. * @param target defines the target of the animatable
  13225. * @returns the required animatable if found
  13226. */
  13227. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13228. /**
  13229. * Gets all animatables associated with a given target
  13230. * @param target defines the target to look animatables for
  13231. * @returns an array of Animatables
  13232. */
  13233. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13234. /**
  13235. * Stops and removes all animations that have been applied to the scene
  13236. */
  13237. stopAllAnimations(): void;
  13238. }
  13239. }
  13240. module "babylonjs/Bones/bone" {
  13241. interface Bone {
  13242. /**
  13243. * Copy an animation range from another bone
  13244. * @param source defines the source bone
  13245. * @param rangeName defines the range name to copy
  13246. * @param frameOffset defines the frame offset
  13247. * @param rescaleAsRequired defines if rescaling must be applied if required
  13248. * @param skelDimensionsRatio defines the scaling ratio
  13249. * @returns true if operation was successful
  13250. */
  13251. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13252. }
  13253. }
  13254. }
  13255. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13256. /**
  13257. * Class used to override all child animations of a given target
  13258. */
  13259. export class AnimationPropertiesOverride {
  13260. /**
  13261. * Gets or sets a value indicating if animation blending must be used
  13262. */
  13263. enableBlending: boolean;
  13264. /**
  13265. * Gets or sets the blending speed to use when enableBlending is true
  13266. */
  13267. blendingSpeed: number;
  13268. /**
  13269. * Gets or sets the default loop mode to use
  13270. */
  13271. loopMode: number;
  13272. }
  13273. }
  13274. declare module "babylonjs/Bones/skeleton" {
  13275. import { Bone } from "babylonjs/Bones/bone";
  13276. import { Observable } from "babylonjs/Misc/observable";
  13277. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13278. import { Scene } from "babylonjs/scene";
  13279. import { Nullable } from "babylonjs/types";
  13280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13281. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13282. import { Animatable } from "babylonjs/Animations/animatable";
  13283. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13284. import { Animation } from "babylonjs/Animations/animation";
  13285. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13286. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13287. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13288. /**
  13289. * Class used to handle skinning animations
  13290. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13291. */
  13292. export class Skeleton implements IAnimatable {
  13293. /** defines the skeleton name */
  13294. name: string;
  13295. /** defines the skeleton Id */
  13296. id: string;
  13297. /**
  13298. * Defines the list of child bones
  13299. */
  13300. bones: Bone[];
  13301. /**
  13302. * Defines an estimate of the dimension of the skeleton at rest
  13303. */
  13304. dimensionsAtRest: Vector3;
  13305. /**
  13306. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13307. */
  13308. needInitialSkinMatrix: boolean;
  13309. /**
  13310. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13311. */
  13312. overrideMesh: Nullable<AbstractMesh>;
  13313. /**
  13314. * Gets the list of animations attached to this skeleton
  13315. */
  13316. animations: Array<Animation>;
  13317. private _scene;
  13318. private _isDirty;
  13319. private _transformMatrices;
  13320. private _transformMatrixTexture;
  13321. private _meshesWithPoseMatrix;
  13322. private _animatables;
  13323. private _identity;
  13324. private _synchronizedWithMesh;
  13325. private _ranges;
  13326. private _lastAbsoluteTransformsUpdateId;
  13327. private _canUseTextureForBones;
  13328. private _uniqueId;
  13329. /** @hidden */
  13330. _numBonesWithLinkedTransformNode: number;
  13331. /** @hidden */
  13332. _hasWaitingData: Nullable<boolean>;
  13333. /**
  13334. * Specifies if the skeleton should be serialized
  13335. */
  13336. doNotSerialize: boolean;
  13337. private _useTextureToStoreBoneMatrices;
  13338. /**
  13339. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13340. * Please note that this option is not available if the hardware does not support it
  13341. */
  13342. useTextureToStoreBoneMatrices: boolean;
  13343. private _animationPropertiesOverride;
  13344. /**
  13345. * Gets or sets the animation properties override
  13346. */
  13347. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13348. /**
  13349. * List of inspectable custom properties (used by the Inspector)
  13350. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13351. */
  13352. inspectableCustomProperties: IInspectable[];
  13353. /**
  13354. * An observable triggered before computing the skeleton's matrices
  13355. */
  13356. onBeforeComputeObservable: Observable<Skeleton>;
  13357. /**
  13358. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13359. */
  13360. readonly isUsingTextureForMatrices: boolean;
  13361. /**
  13362. * Gets the unique ID of this skeleton
  13363. */
  13364. readonly uniqueId: number;
  13365. /**
  13366. * Creates a new skeleton
  13367. * @param name defines the skeleton name
  13368. * @param id defines the skeleton Id
  13369. * @param scene defines the hosting scene
  13370. */
  13371. constructor(
  13372. /** defines the skeleton name */
  13373. name: string,
  13374. /** defines the skeleton Id */
  13375. id: string, scene: Scene);
  13376. /**
  13377. * Gets the current object class name.
  13378. * @return the class name
  13379. */
  13380. getClassName(): string;
  13381. /**
  13382. * Returns an array containing the root bones
  13383. * @returns an array containing the root bones
  13384. */
  13385. getChildren(): Array<Bone>;
  13386. /**
  13387. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13388. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13389. * @returns a Float32Array containing matrices data
  13390. */
  13391. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13392. /**
  13393. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13394. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13395. * @returns a raw texture containing the data
  13396. */
  13397. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13398. /**
  13399. * Gets the current hosting scene
  13400. * @returns a scene object
  13401. */
  13402. getScene(): Scene;
  13403. /**
  13404. * Gets a string representing the current skeleton data
  13405. * @param fullDetails defines a boolean indicating if we want a verbose version
  13406. * @returns a string representing the current skeleton data
  13407. */
  13408. toString(fullDetails?: boolean): string;
  13409. /**
  13410. * Get bone's index searching by name
  13411. * @param name defines bone's name to search for
  13412. * @return the indice of the bone. Returns -1 if not found
  13413. */
  13414. getBoneIndexByName(name: string): number;
  13415. /**
  13416. * Creater a new animation range
  13417. * @param name defines the name of the range
  13418. * @param from defines the start key
  13419. * @param to defines the end key
  13420. */
  13421. createAnimationRange(name: string, from: number, to: number): void;
  13422. /**
  13423. * Delete a specific animation range
  13424. * @param name defines the name of the range
  13425. * @param deleteFrames defines if frames must be removed as well
  13426. */
  13427. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13428. /**
  13429. * Gets a specific animation range
  13430. * @param name defines the name of the range to look for
  13431. * @returns the requested animation range or null if not found
  13432. */
  13433. getAnimationRange(name: string): Nullable<AnimationRange>;
  13434. /**
  13435. * Gets the list of all animation ranges defined on this skeleton
  13436. * @returns an array
  13437. */
  13438. getAnimationRanges(): Nullable<AnimationRange>[];
  13439. /**
  13440. * Copy animation range from a source skeleton.
  13441. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13442. * @param source defines the source skeleton
  13443. * @param name defines the name of the range to copy
  13444. * @param rescaleAsRequired defines if rescaling must be applied if required
  13445. * @returns true if operation was successful
  13446. */
  13447. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13448. /**
  13449. * Forces the skeleton to go to rest pose
  13450. */
  13451. returnToRest(): void;
  13452. private _getHighestAnimationFrame;
  13453. /**
  13454. * Begin a specific animation range
  13455. * @param name defines the name of the range to start
  13456. * @param loop defines if looping must be turned on (false by default)
  13457. * @param speedRatio defines the speed ratio to apply (1 by default)
  13458. * @param onAnimationEnd defines a callback which will be called when animation will end
  13459. * @returns a new animatable
  13460. */
  13461. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13462. /** @hidden */
  13463. _markAsDirty(): void;
  13464. /** @hidden */
  13465. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13466. /** @hidden */
  13467. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13468. private _computeTransformMatrices;
  13469. /**
  13470. * Build all resources required to render a skeleton
  13471. */
  13472. prepare(): void;
  13473. /**
  13474. * Gets the list of animatables currently running for this skeleton
  13475. * @returns an array of animatables
  13476. */
  13477. getAnimatables(): IAnimatable[];
  13478. /**
  13479. * Clone the current skeleton
  13480. * @param name defines the name of the new skeleton
  13481. * @param id defines the id of the new skeleton
  13482. * @returns the new skeleton
  13483. */
  13484. clone(name: string, id: string): Skeleton;
  13485. /**
  13486. * Enable animation blending for this skeleton
  13487. * @param blendingSpeed defines the blending speed to apply
  13488. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13489. */
  13490. enableBlending(blendingSpeed?: number): void;
  13491. /**
  13492. * Releases all resources associated with the current skeleton
  13493. */
  13494. dispose(): void;
  13495. /**
  13496. * Serialize the skeleton in a JSON object
  13497. * @returns a JSON object
  13498. */
  13499. serialize(): any;
  13500. /**
  13501. * Creates a new skeleton from serialized data
  13502. * @param parsedSkeleton defines the serialized data
  13503. * @param scene defines the hosting scene
  13504. * @returns a new skeleton
  13505. */
  13506. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13507. /**
  13508. * Compute all node absolute transforms
  13509. * @param forceUpdate defines if computation must be done even if cache is up to date
  13510. */
  13511. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13512. /**
  13513. * Gets the root pose matrix
  13514. * @returns a matrix
  13515. */
  13516. getPoseMatrix(): Nullable<Matrix>;
  13517. /**
  13518. * Sorts bones per internal index
  13519. */
  13520. sortBones(): void;
  13521. private _sortBones;
  13522. }
  13523. }
  13524. declare module "babylonjs/Bones/bone" {
  13525. import { Skeleton } from "babylonjs/Bones/skeleton";
  13526. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13527. import { Nullable } from "babylonjs/types";
  13528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13529. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13530. import { Node } from "babylonjs/node";
  13531. import { Space } from "babylonjs/Maths/math.axis";
  13532. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13533. /**
  13534. * Class used to store bone information
  13535. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13536. */
  13537. export class Bone extends Node {
  13538. /**
  13539. * defines the bone name
  13540. */
  13541. name: string;
  13542. private static _tmpVecs;
  13543. private static _tmpQuat;
  13544. private static _tmpMats;
  13545. /**
  13546. * Gets the list of child bones
  13547. */
  13548. children: Bone[];
  13549. /** Gets the animations associated with this bone */
  13550. animations: import("babylonjs/Animations/animation").Animation[];
  13551. /**
  13552. * Gets or sets bone length
  13553. */
  13554. length: number;
  13555. /**
  13556. * @hidden Internal only
  13557. * Set this value to map this bone to a different index in the transform matrices
  13558. * Set this value to -1 to exclude the bone from the transform matrices
  13559. */
  13560. _index: Nullable<number>;
  13561. private _skeleton;
  13562. private _localMatrix;
  13563. private _restPose;
  13564. private _baseMatrix;
  13565. private _absoluteTransform;
  13566. private _invertedAbsoluteTransform;
  13567. private _parent;
  13568. private _scalingDeterminant;
  13569. private _worldTransform;
  13570. private _localScaling;
  13571. private _localRotation;
  13572. private _localPosition;
  13573. private _needToDecompose;
  13574. private _needToCompose;
  13575. /** @hidden */
  13576. _linkedTransformNode: Nullable<TransformNode>;
  13577. /** @hidden */
  13578. _waitingTransformNodeId: Nullable<string>;
  13579. /** @hidden */
  13580. /** @hidden */
  13581. _matrix: Matrix;
  13582. /**
  13583. * Create a new bone
  13584. * @param name defines the bone name
  13585. * @param skeleton defines the parent skeleton
  13586. * @param parentBone defines the parent (can be null if the bone is the root)
  13587. * @param localMatrix defines the local matrix
  13588. * @param restPose defines the rest pose matrix
  13589. * @param baseMatrix defines the base matrix
  13590. * @param index defines index of the bone in the hiearchy
  13591. */
  13592. constructor(
  13593. /**
  13594. * defines the bone name
  13595. */
  13596. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13597. /**
  13598. * Gets the current object class name.
  13599. * @return the class name
  13600. */
  13601. getClassName(): string;
  13602. /**
  13603. * Gets the parent skeleton
  13604. * @returns a skeleton
  13605. */
  13606. getSkeleton(): Skeleton;
  13607. /**
  13608. * Gets parent bone
  13609. * @returns a bone or null if the bone is the root of the bone hierarchy
  13610. */
  13611. getParent(): Nullable<Bone>;
  13612. /**
  13613. * Returns an array containing the root bones
  13614. * @returns an array containing the root bones
  13615. */
  13616. getChildren(): Array<Bone>;
  13617. /**
  13618. * Sets the parent bone
  13619. * @param parent defines the parent (can be null if the bone is the root)
  13620. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13621. */
  13622. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13623. /**
  13624. * Gets the local matrix
  13625. * @returns a matrix
  13626. */
  13627. getLocalMatrix(): Matrix;
  13628. /**
  13629. * Gets the base matrix (initial matrix which remains unchanged)
  13630. * @returns a matrix
  13631. */
  13632. getBaseMatrix(): Matrix;
  13633. /**
  13634. * Gets the rest pose matrix
  13635. * @returns a matrix
  13636. */
  13637. getRestPose(): Matrix;
  13638. /**
  13639. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13640. */
  13641. getWorldMatrix(): Matrix;
  13642. /**
  13643. * Sets the local matrix to rest pose matrix
  13644. */
  13645. returnToRest(): void;
  13646. /**
  13647. * Gets the inverse of the absolute transform matrix.
  13648. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13649. * @returns a matrix
  13650. */
  13651. getInvertedAbsoluteTransform(): Matrix;
  13652. /**
  13653. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13654. * @returns a matrix
  13655. */
  13656. getAbsoluteTransform(): Matrix;
  13657. /**
  13658. * Links with the given transform node.
  13659. * The local matrix of this bone is copied from the transform node every frame.
  13660. * @param transformNode defines the transform node to link to
  13661. */
  13662. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13663. /**
  13664. * Gets the node used to drive the bone's transformation
  13665. * @returns a transform node or null
  13666. */
  13667. getTransformNode(): Nullable<TransformNode>;
  13668. /** Gets or sets current position (in local space) */
  13669. position: Vector3;
  13670. /** Gets or sets current rotation (in local space) */
  13671. rotation: Vector3;
  13672. /** Gets or sets current rotation quaternion (in local space) */
  13673. rotationQuaternion: Quaternion;
  13674. /** Gets or sets current scaling (in local space) */
  13675. scaling: Vector3;
  13676. /**
  13677. * Gets the animation properties override
  13678. */
  13679. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13680. private _decompose;
  13681. private _compose;
  13682. /**
  13683. * Update the base and local matrices
  13684. * @param matrix defines the new base or local matrix
  13685. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13686. * @param updateLocalMatrix defines if the local matrix should be updated
  13687. */
  13688. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13689. /** @hidden */
  13690. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13691. /**
  13692. * Flag the bone as dirty (Forcing it to update everything)
  13693. */
  13694. markAsDirty(): void;
  13695. /** @hidden */
  13696. _markAsDirtyAndCompose(): void;
  13697. private _markAsDirtyAndDecompose;
  13698. /**
  13699. * Translate the bone in local or world space
  13700. * @param vec The amount to translate the bone
  13701. * @param space The space that the translation is in
  13702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13703. */
  13704. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13705. /**
  13706. * Set the postion of the bone in local or world space
  13707. * @param position The position to set the bone
  13708. * @param space The space that the position is in
  13709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13710. */
  13711. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13712. /**
  13713. * Set the absolute position of the bone (world space)
  13714. * @param position The position to set the bone
  13715. * @param mesh The mesh that this bone is attached to
  13716. */
  13717. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13718. /**
  13719. * Scale the bone on the x, y and z axes (in local space)
  13720. * @param x The amount to scale the bone on the x axis
  13721. * @param y The amount to scale the bone on the y axis
  13722. * @param z The amount to scale the bone on the z axis
  13723. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13724. */
  13725. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13726. /**
  13727. * Set the bone scaling in local space
  13728. * @param scale defines the scaling vector
  13729. */
  13730. setScale(scale: Vector3): void;
  13731. /**
  13732. * Gets the current scaling in local space
  13733. * @returns the current scaling vector
  13734. */
  13735. getScale(): Vector3;
  13736. /**
  13737. * Gets the current scaling in local space and stores it in a target vector
  13738. * @param result defines the target vector
  13739. */
  13740. getScaleToRef(result: Vector3): void;
  13741. /**
  13742. * Set the yaw, pitch, and roll of the bone in local or world space
  13743. * @param yaw The rotation of the bone on the y axis
  13744. * @param pitch The rotation of the bone on the x axis
  13745. * @param roll The rotation of the bone on the z axis
  13746. * @param space The space that the axes of rotation are in
  13747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13748. */
  13749. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13750. /**
  13751. * Add a rotation to the bone on an axis in local or world space
  13752. * @param axis The axis to rotate the bone on
  13753. * @param amount The amount to rotate the bone
  13754. * @param space The space that the axis is in
  13755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13756. */
  13757. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13758. /**
  13759. * Set the rotation of the bone to a particular axis angle in local or world space
  13760. * @param axis The axis to rotate the bone on
  13761. * @param angle The angle that the bone should be rotated to
  13762. * @param space The space that the axis is in
  13763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13764. */
  13765. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13766. /**
  13767. * Set the euler rotation of the bone in local of world space
  13768. * @param rotation The euler rotation that the bone should be set to
  13769. * @param space The space that the rotation is in
  13770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13771. */
  13772. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13773. /**
  13774. * Set the quaternion rotation of the bone in local of world space
  13775. * @param quat The quaternion rotation that the bone should be set to
  13776. * @param space The space that the rotation is in
  13777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13778. */
  13779. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13780. /**
  13781. * Set the rotation matrix of the bone in local of world space
  13782. * @param rotMat The rotation matrix that the bone should be set to
  13783. * @param space The space that the rotation is in
  13784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13785. */
  13786. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13787. private _rotateWithMatrix;
  13788. private _getNegativeRotationToRef;
  13789. /**
  13790. * Get the position of the bone in local or world space
  13791. * @param space The space that the returned position is in
  13792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13793. * @returns The position of the bone
  13794. */
  13795. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13796. /**
  13797. * Copy the position of the bone to a vector3 in local or world space
  13798. * @param space The space that the returned position is in
  13799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13800. * @param result The vector3 to copy the position to
  13801. */
  13802. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13803. /**
  13804. * Get the absolute position of the bone (world space)
  13805. * @param mesh The mesh that this bone is attached to
  13806. * @returns The absolute position of the bone
  13807. */
  13808. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13809. /**
  13810. * Copy the absolute position of the bone (world space) to the result param
  13811. * @param mesh The mesh that this bone is attached to
  13812. * @param result The vector3 to copy the absolute position to
  13813. */
  13814. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13815. /**
  13816. * Compute the absolute transforms of this bone and its children
  13817. */
  13818. computeAbsoluteTransforms(): void;
  13819. /**
  13820. * Get the world direction from an axis that is in the local space of the bone
  13821. * @param localAxis The local direction that is used to compute the world direction
  13822. * @param mesh The mesh that this bone is attached to
  13823. * @returns The world direction
  13824. */
  13825. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13826. /**
  13827. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13828. * @param localAxis The local direction that is used to compute the world direction
  13829. * @param mesh The mesh that this bone is attached to
  13830. * @param result The vector3 that the world direction will be copied to
  13831. */
  13832. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13833. /**
  13834. * Get the euler rotation of the bone in local or world space
  13835. * @param space The space that the rotation should be in
  13836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13837. * @returns The euler rotation
  13838. */
  13839. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13840. /**
  13841. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13842. * @param space The space that the rotation should be in
  13843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13844. * @param result The vector3 that the rotation should be copied to
  13845. */
  13846. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13847. /**
  13848. * Get the quaternion rotation of the bone in either local or world space
  13849. * @param space The space that the rotation should be in
  13850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13851. * @returns The quaternion rotation
  13852. */
  13853. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13854. /**
  13855. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13856. * @param space The space that the rotation should be in
  13857. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13858. * @param result The quaternion that the rotation should be copied to
  13859. */
  13860. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13861. /**
  13862. * Get the rotation matrix of the bone in local or world space
  13863. * @param space The space that the rotation should be in
  13864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13865. * @returns The rotation matrix
  13866. */
  13867. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13868. /**
  13869. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13870. * @param space The space that the rotation should be in
  13871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13872. * @param result The quaternion that the rotation should be copied to
  13873. */
  13874. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13875. /**
  13876. * Get the world position of a point that is in the local space of the bone
  13877. * @param position The local position
  13878. * @param mesh The mesh that this bone is attached to
  13879. * @returns The world position
  13880. */
  13881. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13882. /**
  13883. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13884. * @param position The local position
  13885. * @param mesh The mesh that this bone is attached to
  13886. * @param result The vector3 that the world position should be copied to
  13887. */
  13888. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13889. /**
  13890. * Get the local position of a point that is in world space
  13891. * @param position The world position
  13892. * @param mesh The mesh that this bone is attached to
  13893. * @returns The local position
  13894. */
  13895. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13896. /**
  13897. * Get the local position of a point that is in world space and copy it to the result param
  13898. * @param position The world position
  13899. * @param mesh The mesh that this bone is attached to
  13900. * @param result The vector3 that the local position should be copied to
  13901. */
  13902. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13903. }
  13904. }
  13905. declare module "babylonjs/Meshes/transformNode" {
  13906. import { DeepImmutable } from "babylonjs/types";
  13907. import { Observable } from "babylonjs/Misc/observable";
  13908. import { Nullable } from "babylonjs/types";
  13909. import { Camera } from "babylonjs/Cameras/camera";
  13910. import { Scene } from "babylonjs/scene";
  13911. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13912. import { Node } from "babylonjs/node";
  13913. import { Bone } from "babylonjs/Bones/bone";
  13914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13915. import { Space } from "babylonjs/Maths/math.axis";
  13916. /**
  13917. * 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.
  13918. * @see https://doc.babylonjs.com/how_to/transformnode
  13919. */
  13920. export class TransformNode extends Node {
  13921. /**
  13922. * Object will not rotate to face the camera
  13923. */
  13924. static BILLBOARDMODE_NONE: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the x axis
  13927. */
  13928. static BILLBOARDMODE_X: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the y axis
  13931. */
  13932. static BILLBOARDMODE_Y: number;
  13933. /**
  13934. * Object will rotate to face the camera but only on the z axis
  13935. */
  13936. static BILLBOARDMODE_Z: number;
  13937. /**
  13938. * Object will rotate to face the camera
  13939. */
  13940. static BILLBOARDMODE_ALL: number;
  13941. /**
  13942. * Object will rotate to face the camera's position instead of orientation
  13943. */
  13944. static BILLBOARDMODE_USE_POSITION: number;
  13945. private _forward;
  13946. private _forwardInverted;
  13947. private _up;
  13948. private _right;
  13949. private _rightInverted;
  13950. private _position;
  13951. private _rotation;
  13952. private _rotationQuaternion;
  13953. protected _scaling: Vector3;
  13954. protected _isDirty: boolean;
  13955. private _transformToBoneReferal;
  13956. private _isAbsoluteSynced;
  13957. private _billboardMode;
  13958. /**
  13959. * Gets or sets the billboard mode. Default is 0.
  13960. *
  13961. * | Value | Type | Description |
  13962. * | --- | --- | --- |
  13963. * | 0 | BILLBOARDMODE_NONE | |
  13964. * | 1 | BILLBOARDMODE_X | |
  13965. * | 2 | BILLBOARDMODE_Y | |
  13966. * | 4 | BILLBOARDMODE_Z | |
  13967. * | 7 | BILLBOARDMODE_ALL | |
  13968. *
  13969. */
  13970. billboardMode: number;
  13971. private _preserveParentRotationForBillboard;
  13972. /**
  13973. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13974. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13975. */
  13976. preserveParentRotationForBillboard: boolean;
  13977. /**
  13978. * 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
  13979. */
  13980. scalingDeterminant: number;
  13981. private _infiniteDistance;
  13982. /**
  13983. * Gets or sets the distance of the object to max, often used by skybox
  13984. */
  13985. infiniteDistance: boolean;
  13986. /**
  13987. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13988. * By default the system will update normals to compensate
  13989. */
  13990. ignoreNonUniformScaling: boolean;
  13991. /**
  13992. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13993. */
  13994. reIntegrateRotationIntoRotationQuaternion: boolean;
  13995. /** @hidden */
  13996. _poseMatrix: Nullable<Matrix>;
  13997. /** @hidden */
  13998. _localMatrix: Matrix;
  13999. private _usePivotMatrix;
  14000. private _absolutePosition;
  14001. private _absoluteScaling;
  14002. private _absoluteRotationQuaternion;
  14003. private _pivotMatrix;
  14004. private _pivotMatrixInverse;
  14005. protected _postMultiplyPivotMatrix: boolean;
  14006. protected _isWorldMatrixFrozen: boolean;
  14007. /** @hidden */
  14008. _indexInSceneTransformNodesArray: number;
  14009. /**
  14010. * An event triggered after the world matrix is updated
  14011. */
  14012. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14013. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14014. /**
  14015. * Gets a string identifying the name of the class
  14016. * @returns "TransformNode" string
  14017. */
  14018. getClassName(): string;
  14019. /**
  14020. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14021. */
  14022. position: Vector3;
  14023. /**
  14024. * 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)).
  14025. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14026. */
  14027. rotation: Vector3;
  14028. /**
  14029. * 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)).
  14030. */
  14031. scaling: Vector3;
  14032. /**
  14033. * 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).
  14034. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14035. */
  14036. rotationQuaternion: Nullable<Quaternion>;
  14037. /**
  14038. * The forward direction of that transform in world space.
  14039. */
  14040. readonly forward: Vector3;
  14041. /**
  14042. * The up direction of that transform in world space.
  14043. */
  14044. readonly up: Vector3;
  14045. /**
  14046. * The right direction of that transform in world space.
  14047. */
  14048. readonly right: Vector3;
  14049. /**
  14050. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14051. * @param matrix the matrix to copy the pose from
  14052. * @returns this TransformNode.
  14053. */
  14054. updatePoseMatrix(matrix: Matrix): TransformNode;
  14055. /**
  14056. * Returns the mesh Pose matrix.
  14057. * @returns the pose matrix
  14058. */
  14059. getPoseMatrix(): Matrix;
  14060. /** @hidden */
  14061. _isSynchronized(): boolean;
  14062. /** @hidden */
  14063. _initCache(): void;
  14064. /**
  14065. * Flag the transform node as dirty (Forcing it to update everything)
  14066. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14067. * @returns this transform node
  14068. */
  14069. markAsDirty(property: string): TransformNode;
  14070. /**
  14071. * Returns the current mesh absolute position.
  14072. * Returns a Vector3.
  14073. */
  14074. readonly absolutePosition: Vector3;
  14075. /**
  14076. * Returns the current mesh absolute scaling.
  14077. * Returns a Vector3.
  14078. */
  14079. readonly absoluteScaling: Vector3;
  14080. /**
  14081. * Returns the current mesh absolute rotation.
  14082. * Returns a Quaternion.
  14083. */
  14084. readonly absoluteRotationQuaternion: Quaternion;
  14085. /**
  14086. * Sets a new matrix to apply before all other transformation
  14087. * @param matrix defines the transform matrix
  14088. * @returns the current TransformNode
  14089. */
  14090. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14091. /**
  14092. * Sets a new pivot matrix to the current node
  14093. * @param matrix defines the new pivot matrix to use
  14094. * @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
  14095. * @returns the current TransformNode
  14096. */
  14097. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14098. /**
  14099. * Returns the mesh pivot matrix.
  14100. * Default : Identity.
  14101. * @returns the matrix
  14102. */
  14103. getPivotMatrix(): Matrix;
  14104. /**
  14105. * Prevents the World matrix to be computed any longer.
  14106. * @returns the TransformNode.
  14107. */
  14108. freezeWorldMatrix(): TransformNode;
  14109. /**
  14110. * Allows back the World matrix computation.
  14111. * @returns the TransformNode.
  14112. */
  14113. unfreezeWorldMatrix(): this;
  14114. /**
  14115. * True if the World matrix has been frozen.
  14116. */
  14117. readonly isWorldMatrixFrozen: boolean;
  14118. /**
  14119. * Retuns the mesh absolute position in the World.
  14120. * @returns a Vector3.
  14121. */
  14122. getAbsolutePosition(): Vector3;
  14123. /**
  14124. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14125. * @param absolutePosition the absolute position to set
  14126. * @returns the TransformNode.
  14127. */
  14128. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14129. /**
  14130. * Sets the mesh position in its local space.
  14131. * @param vector3 the position to set in localspace
  14132. * @returns the TransformNode.
  14133. */
  14134. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14135. /**
  14136. * Returns the mesh position in the local space from the current World matrix values.
  14137. * @returns a new Vector3.
  14138. */
  14139. getPositionExpressedInLocalSpace(): Vector3;
  14140. /**
  14141. * Translates the mesh along the passed Vector3 in its local space.
  14142. * @param vector3 the distance to translate in localspace
  14143. * @returns the TransformNode.
  14144. */
  14145. locallyTranslate(vector3: Vector3): TransformNode;
  14146. private static _lookAtVectorCache;
  14147. /**
  14148. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14149. * @param targetPoint the position (must be in same space as current mesh) to look at
  14150. * @param yawCor optional yaw (y-axis) correction in radians
  14151. * @param pitchCor optional pitch (x-axis) correction in radians
  14152. * @param rollCor optional roll (z-axis) correction in radians
  14153. * @param space the choosen space of the target
  14154. * @returns the TransformNode.
  14155. */
  14156. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14157. /**
  14158. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14159. * This Vector3 is expressed in the World space.
  14160. * @param localAxis axis to rotate
  14161. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14162. */
  14163. getDirection(localAxis: Vector3): Vector3;
  14164. /**
  14165. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14166. * localAxis is expressed in the mesh local space.
  14167. * result is computed in the Wordl space from the mesh World matrix.
  14168. * @param localAxis axis to rotate
  14169. * @param result the resulting transformnode
  14170. * @returns this TransformNode.
  14171. */
  14172. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14173. /**
  14174. * Sets this transform node rotation to the given local axis.
  14175. * @param localAxis the axis in local space
  14176. * @param yawCor optional yaw (y-axis) correction in radians
  14177. * @param pitchCor optional pitch (x-axis) correction in radians
  14178. * @param rollCor optional roll (z-axis) correction in radians
  14179. * @returns this TransformNode
  14180. */
  14181. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14182. /**
  14183. * Sets a new pivot point to the current node
  14184. * @param point defines the new pivot point to use
  14185. * @param space defines if the point is in world or local space (local by default)
  14186. * @returns the current TransformNode
  14187. */
  14188. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14189. /**
  14190. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14191. * @returns the pivot point
  14192. */
  14193. getPivotPoint(): Vector3;
  14194. /**
  14195. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14196. * @param result the vector3 to store the result
  14197. * @returns this TransformNode.
  14198. */
  14199. getPivotPointToRef(result: Vector3): TransformNode;
  14200. /**
  14201. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14202. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14203. */
  14204. getAbsolutePivotPoint(): Vector3;
  14205. /**
  14206. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14207. * @param result vector3 to store the result
  14208. * @returns this TransformNode.
  14209. */
  14210. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14211. /**
  14212. * Defines the passed node as the parent of the current node.
  14213. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14214. * @see https://doc.babylonjs.com/how_to/parenting
  14215. * @param node the node ot set as the parent
  14216. * @returns this TransformNode.
  14217. */
  14218. setParent(node: Nullable<Node>): TransformNode;
  14219. private _nonUniformScaling;
  14220. /**
  14221. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14222. */
  14223. readonly nonUniformScaling: boolean;
  14224. /** @hidden */
  14225. _updateNonUniformScalingState(value: boolean): boolean;
  14226. /**
  14227. * Attach the current TransformNode to another TransformNode associated with a bone
  14228. * @param bone Bone affecting the TransformNode
  14229. * @param affectedTransformNode TransformNode associated with the bone
  14230. * @returns this object
  14231. */
  14232. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14233. /**
  14234. * Detach the transform node if its associated with a bone
  14235. * @returns this object
  14236. */
  14237. detachFromBone(): TransformNode;
  14238. private static _rotationAxisCache;
  14239. /**
  14240. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14241. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14242. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14243. * The passed axis is also normalized.
  14244. * @param axis the axis to rotate around
  14245. * @param amount the amount to rotate in radians
  14246. * @param space Space to rotate in (Default: local)
  14247. * @returns the TransformNode.
  14248. */
  14249. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14250. /**
  14251. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14252. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14253. * The passed axis is also normalized. .
  14254. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14255. * @param point the point to rotate around
  14256. * @param axis the axis to rotate around
  14257. * @param amount the amount to rotate in radians
  14258. * @returns the TransformNode
  14259. */
  14260. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14261. /**
  14262. * Translates the mesh along the axis vector for the passed distance in the given space.
  14263. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14264. * @param axis the axis to translate in
  14265. * @param distance the distance to translate
  14266. * @param space Space to rotate in (Default: local)
  14267. * @returns the TransformNode.
  14268. */
  14269. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14270. /**
  14271. * Adds a rotation step to the mesh current rotation.
  14272. * x, y, z are Euler angles expressed in radians.
  14273. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14274. * This means this rotation is made in the mesh local space only.
  14275. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14276. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14277. * ```javascript
  14278. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14279. * ```
  14280. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14281. * 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.
  14282. * @param x Rotation to add
  14283. * @param y Rotation to add
  14284. * @param z Rotation to add
  14285. * @returns the TransformNode.
  14286. */
  14287. addRotation(x: number, y: number, z: number): TransformNode;
  14288. /**
  14289. * @hidden
  14290. */
  14291. protected _getEffectiveParent(): Nullable<Node>;
  14292. /**
  14293. * Computes the world matrix of the node
  14294. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14295. * @returns the world matrix
  14296. */
  14297. computeWorldMatrix(force?: boolean): Matrix;
  14298. protected _afterComputeWorldMatrix(): void;
  14299. /**
  14300. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14301. * @param func callback function to add
  14302. *
  14303. * @returns the TransformNode.
  14304. */
  14305. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14306. /**
  14307. * Removes a registered callback function.
  14308. * @param func callback function to remove
  14309. * @returns the TransformNode.
  14310. */
  14311. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14312. /**
  14313. * Gets the position of the current mesh in camera space
  14314. * @param camera defines the camera to use
  14315. * @returns a position
  14316. */
  14317. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14318. /**
  14319. * Returns the distance from the mesh to the active camera
  14320. * @param camera defines the camera to use
  14321. * @returns the distance
  14322. */
  14323. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14324. /**
  14325. * Clone the current transform node
  14326. * @param name Name of the new clone
  14327. * @param newParent New parent for the clone
  14328. * @param doNotCloneChildren Do not clone children hierarchy
  14329. * @returns the new transform node
  14330. */
  14331. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14332. /**
  14333. * Serializes the objects information.
  14334. * @param currentSerializationObject defines the object to serialize in
  14335. * @returns the serialized object
  14336. */
  14337. serialize(currentSerializationObject?: any): any;
  14338. /**
  14339. * Returns a new TransformNode object parsed from the source provided.
  14340. * @param parsedTransformNode is the source.
  14341. * @param scene the scne the object belongs to
  14342. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14343. * @returns a new TransformNode object parsed from the source provided.
  14344. */
  14345. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14346. /**
  14347. * Get all child-transformNodes of this node
  14348. * @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
  14349. * @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
  14350. * @returns an array of TransformNode
  14351. */
  14352. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14353. /**
  14354. * Releases resources associated with this transform node.
  14355. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14356. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14357. */
  14358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14359. /**
  14360. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14361. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14362. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14363. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14364. * @returns the current mesh
  14365. */
  14366. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14367. private _syncAbsoluteScalingAndRotation;
  14368. }
  14369. }
  14370. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14371. import { Observable } from "babylonjs/Misc/observable";
  14372. import { Nullable } from "babylonjs/types";
  14373. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14374. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14376. import { Ray } from "babylonjs/Culling/ray";
  14377. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14378. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14379. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14380. /**
  14381. * Defines the types of pose enabled controllers that are supported
  14382. */
  14383. export enum PoseEnabledControllerType {
  14384. /**
  14385. * HTC Vive
  14386. */
  14387. VIVE = 0,
  14388. /**
  14389. * Oculus Rift
  14390. */
  14391. OCULUS = 1,
  14392. /**
  14393. * Windows mixed reality
  14394. */
  14395. WINDOWS = 2,
  14396. /**
  14397. * Samsung gear VR
  14398. */
  14399. GEAR_VR = 3,
  14400. /**
  14401. * Google Daydream
  14402. */
  14403. DAYDREAM = 4,
  14404. /**
  14405. * Generic
  14406. */
  14407. GENERIC = 5
  14408. }
  14409. /**
  14410. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14411. */
  14412. export interface MutableGamepadButton {
  14413. /**
  14414. * Value of the button/trigger
  14415. */
  14416. value: number;
  14417. /**
  14418. * If the button/trigger is currently touched
  14419. */
  14420. touched: boolean;
  14421. /**
  14422. * If the button/trigger is currently pressed
  14423. */
  14424. pressed: boolean;
  14425. }
  14426. /**
  14427. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14428. * @hidden
  14429. */
  14430. export interface ExtendedGamepadButton extends GamepadButton {
  14431. /**
  14432. * If the button/trigger is currently pressed
  14433. */
  14434. readonly pressed: boolean;
  14435. /**
  14436. * If the button/trigger is currently touched
  14437. */
  14438. readonly touched: boolean;
  14439. /**
  14440. * Value of the button/trigger
  14441. */
  14442. readonly value: number;
  14443. }
  14444. /** @hidden */
  14445. export interface _GamePadFactory {
  14446. /**
  14447. * Returns wether or not the current gamepad can be created for this type of controller.
  14448. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14449. * @returns true if it can be created, otherwise false
  14450. */
  14451. canCreate(gamepadInfo: any): boolean;
  14452. /**
  14453. * Creates a new instance of the Gamepad.
  14454. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14455. * @returns the new gamepad instance
  14456. */
  14457. create(gamepadInfo: any): Gamepad;
  14458. }
  14459. /**
  14460. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14461. */
  14462. export class PoseEnabledControllerHelper {
  14463. /** @hidden */
  14464. static _ControllerFactories: _GamePadFactory[];
  14465. /** @hidden */
  14466. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14467. /**
  14468. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14469. * @param vrGamepad the gamepad to initialized
  14470. * @returns a vr controller of the type the gamepad identified as
  14471. */
  14472. static InitiateController(vrGamepad: any): Gamepad;
  14473. }
  14474. /**
  14475. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14476. */
  14477. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14478. /**
  14479. * If the controller is used in a webXR session
  14480. */
  14481. isXR: boolean;
  14482. private _deviceRoomPosition;
  14483. private _deviceRoomRotationQuaternion;
  14484. /**
  14485. * The device position in babylon space
  14486. */
  14487. devicePosition: Vector3;
  14488. /**
  14489. * The device rotation in babylon space
  14490. */
  14491. deviceRotationQuaternion: Quaternion;
  14492. /**
  14493. * The scale factor of the device in babylon space
  14494. */
  14495. deviceScaleFactor: number;
  14496. /**
  14497. * (Likely devicePosition should be used instead) The device position in its room space
  14498. */
  14499. position: Vector3;
  14500. /**
  14501. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14502. */
  14503. rotationQuaternion: Quaternion;
  14504. /**
  14505. * The type of controller (Eg. Windows mixed reality)
  14506. */
  14507. controllerType: PoseEnabledControllerType;
  14508. protected _calculatedPosition: Vector3;
  14509. private _calculatedRotation;
  14510. /**
  14511. * The raw pose from the device
  14512. */
  14513. rawPose: DevicePose;
  14514. private _trackPosition;
  14515. private _maxRotationDistFromHeadset;
  14516. private _draggedRoomRotation;
  14517. /**
  14518. * @hidden
  14519. */
  14520. _disableTrackPosition(fixedPosition: Vector3): void;
  14521. /**
  14522. * Internal, the mesh attached to the controller
  14523. * @hidden
  14524. */
  14525. _mesh: Nullable<AbstractMesh>;
  14526. private _poseControlledCamera;
  14527. private _leftHandSystemQuaternion;
  14528. /**
  14529. * Internal, matrix used to convert room space to babylon space
  14530. * @hidden
  14531. */
  14532. _deviceToWorld: Matrix;
  14533. /**
  14534. * Node to be used when casting a ray from the controller
  14535. * @hidden
  14536. */
  14537. _pointingPoseNode: Nullable<TransformNode>;
  14538. /**
  14539. * Name of the child mesh that can be used to cast a ray from the controller
  14540. */
  14541. static readonly POINTING_POSE: string;
  14542. /**
  14543. * Creates a new PoseEnabledController from a gamepad
  14544. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14545. */
  14546. constructor(browserGamepad: any);
  14547. private _workingMatrix;
  14548. /**
  14549. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14550. */
  14551. update(): void;
  14552. /**
  14553. * Updates only the pose device and mesh without doing any button event checking
  14554. */
  14555. protected _updatePoseAndMesh(): void;
  14556. /**
  14557. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14558. * @param poseData raw pose fromthe device
  14559. */
  14560. updateFromDevice(poseData: DevicePose): void;
  14561. /**
  14562. * @hidden
  14563. */
  14564. _meshAttachedObservable: Observable<AbstractMesh>;
  14565. /**
  14566. * Attaches a mesh to the controller
  14567. * @param mesh the mesh to be attached
  14568. */
  14569. attachToMesh(mesh: AbstractMesh): void;
  14570. /**
  14571. * Attaches the controllers mesh to a camera
  14572. * @param camera the camera the mesh should be attached to
  14573. */
  14574. attachToPoseControlledCamera(camera: TargetCamera): void;
  14575. /**
  14576. * Disposes of the controller
  14577. */
  14578. dispose(): void;
  14579. /**
  14580. * The mesh that is attached to the controller
  14581. */
  14582. readonly mesh: Nullable<AbstractMesh>;
  14583. /**
  14584. * Gets the ray of the controller in the direction the controller is pointing
  14585. * @param length the length the resulting ray should be
  14586. * @returns a ray in the direction the controller is pointing
  14587. */
  14588. getForwardRay(length?: number): Ray;
  14589. }
  14590. }
  14591. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14592. import { Observable } from "babylonjs/Misc/observable";
  14593. import { Scene } from "babylonjs/scene";
  14594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14595. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14596. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14597. /**
  14598. * Defines the WebVRController object that represents controllers tracked in 3D space
  14599. */
  14600. export abstract class WebVRController extends PoseEnabledController {
  14601. /**
  14602. * Internal, the default controller model for the controller
  14603. */
  14604. protected _defaultModel: AbstractMesh;
  14605. /**
  14606. * Fired when the trigger state has changed
  14607. */
  14608. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the main button state has changed
  14611. */
  14612. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when the secondary button state has changed
  14615. */
  14616. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14617. /**
  14618. * Fired when the pad state has changed
  14619. */
  14620. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14621. /**
  14622. * Fired when controllers stick values have changed
  14623. */
  14624. onPadValuesChangedObservable: Observable<StickValues>;
  14625. /**
  14626. * Array of button availible on the controller
  14627. */
  14628. protected _buttons: Array<MutableGamepadButton>;
  14629. private _onButtonStateChange;
  14630. /**
  14631. * Fired when a controller button's state has changed
  14632. * @param callback the callback containing the button that was modified
  14633. */
  14634. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14635. /**
  14636. * X and Y axis corresponding to the controllers joystick
  14637. */
  14638. pad: StickValues;
  14639. /**
  14640. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14641. */
  14642. hand: string;
  14643. /**
  14644. * The default controller model for the controller
  14645. */
  14646. readonly defaultModel: AbstractMesh;
  14647. /**
  14648. * Creates a new WebVRController from a gamepad
  14649. * @param vrGamepad the gamepad that the WebVRController should be created from
  14650. */
  14651. constructor(vrGamepad: any);
  14652. /**
  14653. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14654. */
  14655. update(): void;
  14656. /**
  14657. * Function to be called when a button is modified
  14658. */
  14659. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14660. /**
  14661. * Loads a mesh and attaches it to the controller
  14662. * @param scene the scene the mesh should be added to
  14663. * @param meshLoaded callback for when the mesh has been loaded
  14664. */
  14665. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14666. private _setButtonValue;
  14667. private _changes;
  14668. private _checkChanges;
  14669. /**
  14670. * Disposes of th webVRCOntroller
  14671. */
  14672. dispose(): void;
  14673. }
  14674. }
  14675. declare module "babylonjs/Lights/hemisphericLight" {
  14676. import { Nullable } from "babylonjs/types";
  14677. import { Scene } from "babylonjs/scene";
  14678. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14679. import { Color3 } from "babylonjs/Maths/math.color";
  14680. import { Effect } from "babylonjs/Materials/effect";
  14681. import { Light } from "babylonjs/Lights/light";
  14682. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14683. /**
  14684. * The HemisphericLight simulates the ambient environment light,
  14685. * so the passed direction is the light reflection direction, not the incoming direction.
  14686. */
  14687. export class HemisphericLight extends Light {
  14688. /**
  14689. * The groundColor is the light in the opposite direction to the one specified during creation.
  14690. * 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.
  14691. */
  14692. groundColor: Color3;
  14693. /**
  14694. * The light reflection direction, not the incoming direction.
  14695. */
  14696. direction: Vector3;
  14697. /**
  14698. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14699. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14700. * The HemisphericLight can't cast shadows.
  14701. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14702. * @param name The friendly name of the light
  14703. * @param direction The direction of the light reflection
  14704. * @param scene The scene the light belongs to
  14705. */
  14706. constructor(name: string, direction: Vector3, scene: Scene);
  14707. protected _buildUniformLayout(): void;
  14708. /**
  14709. * Returns the string "HemisphericLight".
  14710. * @return The class name
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14715. * Returns the updated direction.
  14716. * @param target The target the direction should point to
  14717. * @return The computed direction
  14718. */
  14719. setDirectionToTarget(target: Vector3): Vector3;
  14720. /**
  14721. * Returns the shadow generator associated to the light.
  14722. * @returns Always null for hemispheric lights because it does not support shadows.
  14723. */
  14724. getShadowGenerator(): Nullable<IShadowGenerator>;
  14725. /**
  14726. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14727. * @param effect The effect to update
  14728. * @param lightIndex The index of the light in the effect to update
  14729. * @returns The hemispheric light
  14730. */
  14731. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14732. /**
  14733. * Computes the world matrix of the node
  14734. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14735. * @param useWasUpdatedFlag defines a reserved property
  14736. * @returns the world matrix
  14737. */
  14738. computeWorldMatrix(): Matrix;
  14739. /**
  14740. * Returns the integer 3.
  14741. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14742. */
  14743. getTypeID(): number;
  14744. /**
  14745. * Prepares the list of defines specific to the light type.
  14746. * @param defines the list of defines
  14747. * @param lightIndex defines the index of the light for the effect
  14748. */
  14749. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14750. }
  14751. }
  14752. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14753. /** @hidden */
  14754. export var vrMultiviewToSingleviewPixelShader: {
  14755. name: string;
  14756. shader: string;
  14757. };
  14758. }
  14759. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14760. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14761. import { Scene } from "babylonjs/scene";
  14762. /**
  14763. * Renders to multiple views with a single draw call
  14764. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14765. */
  14766. export class MultiviewRenderTarget extends RenderTargetTexture {
  14767. /**
  14768. * Creates a multiview render target
  14769. * @param scene scene used with the render target
  14770. * @param size the size of the render target (used for each view)
  14771. */
  14772. constructor(scene: Scene, size?: number | {
  14773. width: number;
  14774. height: number;
  14775. } | {
  14776. ratio: number;
  14777. });
  14778. /**
  14779. * @hidden
  14780. * @param faceIndex the face index, if its a cube texture
  14781. */
  14782. _bindFrameBuffer(faceIndex?: number): void;
  14783. /**
  14784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14785. * @returns the view count
  14786. */
  14787. getViewCount(): number;
  14788. }
  14789. }
  14790. declare module "babylonjs/Maths/math.frustum" {
  14791. import { Matrix } from "babylonjs/Maths/math.vector";
  14792. import { DeepImmutable } from "babylonjs/types";
  14793. import { Plane } from "babylonjs/Maths/math.plane";
  14794. /**
  14795. * Reprasents a camera frustum
  14796. */
  14797. export class Frustum {
  14798. /**
  14799. * Gets the planes representing the frustum
  14800. * @param transform matrix to be applied to the returned planes
  14801. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14802. */
  14803. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14804. /**
  14805. * Gets the near frustum plane transformed by the transform matrix
  14806. * @param transform transformation matrix to be applied to the resulting frustum plane
  14807. * @param frustumPlane the resuling frustum plane
  14808. */
  14809. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14810. /**
  14811. * Gets the far frustum plane transformed by the transform matrix
  14812. * @param transform transformation matrix to be applied to the resulting frustum plane
  14813. * @param frustumPlane the resuling frustum plane
  14814. */
  14815. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14816. /**
  14817. * Gets the left frustum plane transformed by the transform matrix
  14818. * @param transform transformation matrix to be applied to the resulting frustum plane
  14819. * @param frustumPlane the resuling frustum plane
  14820. */
  14821. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14822. /**
  14823. * Gets the right frustum plane transformed by the transform matrix
  14824. * @param transform transformation matrix to be applied to the resulting frustum plane
  14825. * @param frustumPlane the resuling frustum plane
  14826. */
  14827. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14828. /**
  14829. * Gets the top frustum plane transformed by the transform matrix
  14830. * @param transform transformation matrix to be applied to the resulting frustum plane
  14831. * @param frustumPlane the resuling frustum plane
  14832. */
  14833. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14834. /**
  14835. * Gets the bottom frustum plane transformed by the transform matrix
  14836. * @param transform transformation matrix to be applied to the resulting frustum plane
  14837. * @param frustumPlane the resuling frustum plane
  14838. */
  14839. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14840. /**
  14841. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14842. * @param transform transformation matrix to be applied to the resulting frustum planes
  14843. * @param frustumPlanes the resuling frustum planes
  14844. */
  14845. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14846. }
  14847. }
  14848. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14849. import { Camera } from "babylonjs/Cameras/camera";
  14850. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14851. import { Nullable } from "babylonjs/types";
  14852. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14853. import { Matrix } from "babylonjs/Maths/math.vector";
  14854. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14855. module "babylonjs/Engines/engine" {
  14856. interface Engine {
  14857. /**
  14858. * Creates a new multiview render target
  14859. * @param width defines the width of the texture
  14860. * @param height defines the height of the texture
  14861. * @returns the created multiview texture
  14862. */
  14863. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14864. /**
  14865. * Binds a multiview framebuffer to be drawn to
  14866. * @param multiviewTexture texture to bind
  14867. */
  14868. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14869. }
  14870. }
  14871. module "babylonjs/Cameras/camera" {
  14872. interface Camera {
  14873. /**
  14874. * @hidden
  14875. * 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)
  14876. */
  14877. _useMultiviewToSingleView: boolean;
  14878. /**
  14879. * @hidden
  14880. * 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)
  14881. */
  14882. _multiviewTexture: Nullable<RenderTargetTexture>;
  14883. /**
  14884. * @hidden
  14885. * ensures the multiview texture of the camera exists and has the specified width/height
  14886. * @param width height to set on the multiview texture
  14887. * @param height width to set on the multiview texture
  14888. */
  14889. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14890. }
  14891. }
  14892. module "babylonjs/scene" {
  14893. interface Scene {
  14894. /** @hidden */
  14895. _transformMatrixR: Matrix;
  14896. /** @hidden */
  14897. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14898. /** @hidden */
  14899. _createMultiviewUbo(): void;
  14900. /** @hidden */
  14901. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14902. /** @hidden */
  14903. _renderMultiviewToSingleView(camera: Camera): void;
  14904. }
  14905. }
  14906. }
  14907. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14908. import { Camera } from "babylonjs/Cameras/camera";
  14909. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14910. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14911. import "babylonjs/Engines/Extensions/engine.multiview";
  14912. /**
  14913. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14914. * This will not be used for webXR as it supports displaying texture arrays directly
  14915. */
  14916. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14917. /**
  14918. * Initializes a VRMultiviewToSingleview
  14919. * @param name name of the post process
  14920. * @param camera camera to be applied to
  14921. * @param scaleFactor scaling factor to the size of the output texture
  14922. */
  14923. constructor(name: string, camera: Camera, scaleFactor: number);
  14924. }
  14925. }
  14926. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14927. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14928. import { Nullable } from "babylonjs/types";
  14929. import { Size } from "babylonjs/Maths/math.size";
  14930. import { Observable } from "babylonjs/Misc/observable";
  14931. module "babylonjs/Engines/engine" {
  14932. interface Engine {
  14933. /** @hidden */
  14934. _vrDisplay: any;
  14935. /** @hidden */
  14936. _vrSupported: boolean;
  14937. /** @hidden */
  14938. _oldSize: Size;
  14939. /** @hidden */
  14940. _oldHardwareScaleFactor: number;
  14941. /** @hidden */
  14942. _vrExclusivePointerMode: boolean;
  14943. /** @hidden */
  14944. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14945. /** @hidden */
  14946. _onVRDisplayPointerRestricted: () => void;
  14947. /** @hidden */
  14948. _onVRDisplayPointerUnrestricted: () => void;
  14949. /** @hidden */
  14950. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14951. /** @hidden */
  14952. _onVrDisplayDisconnect: Nullable<() => void>;
  14953. /** @hidden */
  14954. _onVrDisplayPresentChange: Nullable<() => void>;
  14955. /**
  14956. * Observable signaled when VR display mode changes
  14957. */
  14958. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14959. /**
  14960. * Observable signaled when VR request present is complete
  14961. */
  14962. onVRRequestPresentComplete: Observable<boolean>;
  14963. /**
  14964. * Observable signaled when VR request present starts
  14965. */
  14966. onVRRequestPresentStart: Observable<Engine>;
  14967. /**
  14968. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14969. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14970. */
  14971. isInVRExclusivePointerMode: boolean;
  14972. /**
  14973. * Gets a boolean indicating if a webVR device was detected
  14974. * @returns true if a webVR device was detected
  14975. */
  14976. isVRDevicePresent(): boolean;
  14977. /**
  14978. * Gets the current webVR device
  14979. * @returns the current webVR device (or null)
  14980. */
  14981. getVRDevice(): any;
  14982. /**
  14983. * Initializes a webVR display and starts listening to display change events
  14984. * The onVRDisplayChangedObservable will be notified upon these changes
  14985. * @returns A promise containing a VRDisplay and if vr is supported
  14986. */
  14987. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14988. /** @hidden */
  14989. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14990. /**
  14991. * Call this function to switch to webVR mode
  14992. * Will do nothing if webVR is not supported or if there is no webVR device
  14993. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14994. */
  14995. enableVR(): void;
  14996. /** @hidden */
  14997. _onVRFullScreenTriggered(): void;
  14998. }
  14999. }
  15000. }
  15001. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15002. import { Nullable } from "babylonjs/types";
  15003. import { Observable } from "babylonjs/Misc/observable";
  15004. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15005. import { Scene } from "babylonjs/scene";
  15006. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15007. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15008. import { Node } from "babylonjs/node";
  15009. import { Ray } from "babylonjs/Culling/ray";
  15010. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15011. import "babylonjs/Engines/Extensions/engine.webVR";
  15012. /**
  15013. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15014. * IMPORTANT!! The data is right-hand data.
  15015. * @export
  15016. * @interface DevicePose
  15017. */
  15018. export interface DevicePose {
  15019. /**
  15020. * The position of the device, values in array are [x,y,z].
  15021. */
  15022. readonly position: Nullable<Float32Array>;
  15023. /**
  15024. * The linearVelocity of the device, values in array are [x,y,z].
  15025. */
  15026. readonly linearVelocity: Nullable<Float32Array>;
  15027. /**
  15028. * The linearAcceleration of the device, values in array are [x,y,z].
  15029. */
  15030. readonly linearAcceleration: Nullable<Float32Array>;
  15031. /**
  15032. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15033. */
  15034. readonly orientation: Nullable<Float32Array>;
  15035. /**
  15036. * The angularVelocity of the device, values in array are [x,y,z].
  15037. */
  15038. readonly angularVelocity: Nullable<Float32Array>;
  15039. /**
  15040. * The angularAcceleration of the device, values in array are [x,y,z].
  15041. */
  15042. readonly angularAcceleration: Nullable<Float32Array>;
  15043. }
  15044. /**
  15045. * Interface representing a pose controlled object in Babylon.
  15046. * A pose controlled object has both regular pose values as well as pose values
  15047. * from an external device such as a VR head mounted display
  15048. */
  15049. export interface PoseControlled {
  15050. /**
  15051. * The position of the object in babylon space.
  15052. */
  15053. position: Vector3;
  15054. /**
  15055. * The rotation quaternion of the object in babylon space.
  15056. */
  15057. rotationQuaternion: Quaternion;
  15058. /**
  15059. * The position of the device in babylon space.
  15060. */
  15061. devicePosition?: Vector3;
  15062. /**
  15063. * The rotation quaternion of the device in babylon space.
  15064. */
  15065. deviceRotationQuaternion: Quaternion;
  15066. /**
  15067. * The raw pose coming from the device.
  15068. */
  15069. rawPose: Nullable<DevicePose>;
  15070. /**
  15071. * The scale of the device to be used when translating from device space to babylon space.
  15072. */
  15073. deviceScaleFactor: number;
  15074. /**
  15075. * Updates the poseControlled values based on the input device pose.
  15076. * @param poseData the pose data to update the object with
  15077. */
  15078. updateFromDevice(poseData: DevicePose): void;
  15079. }
  15080. /**
  15081. * Set of options to customize the webVRCamera
  15082. */
  15083. export interface WebVROptions {
  15084. /**
  15085. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15086. */
  15087. trackPosition?: boolean;
  15088. /**
  15089. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15090. */
  15091. positionScale?: number;
  15092. /**
  15093. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15094. */
  15095. displayName?: string;
  15096. /**
  15097. * Should the native controller meshes be initialized. (default: true)
  15098. */
  15099. controllerMeshes?: boolean;
  15100. /**
  15101. * Creating a default HemiLight only on controllers. (default: true)
  15102. */
  15103. defaultLightingOnControllers?: boolean;
  15104. /**
  15105. * If you don't want to use the default VR button of the helper. (default: false)
  15106. */
  15107. useCustomVRButton?: boolean;
  15108. /**
  15109. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15110. */
  15111. customVRButton?: HTMLButtonElement;
  15112. /**
  15113. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15114. */
  15115. rayLength?: number;
  15116. /**
  15117. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15118. */
  15119. defaultHeight?: number;
  15120. /**
  15121. * If multiview should be used if availible (default: false)
  15122. */
  15123. useMultiview?: boolean;
  15124. }
  15125. /**
  15126. * This represents a WebVR camera.
  15127. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15128. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15129. */
  15130. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15131. private webVROptions;
  15132. /**
  15133. * @hidden
  15134. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15135. */
  15136. _vrDevice: any;
  15137. /**
  15138. * The rawPose of the vrDevice.
  15139. */
  15140. rawPose: Nullable<DevicePose>;
  15141. private _onVREnabled;
  15142. private _specsVersion;
  15143. private _attached;
  15144. private _frameData;
  15145. protected _descendants: Array<Node>;
  15146. private _deviceRoomPosition;
  15147. /** @hidden */
  15148. _deviceRoomRotationQuaternion: Quaternion;
  15149. private _standingMatrix;
  15150. /**
  15151. * Represents device position in babylon space.
  15152. */
  15153. devicePosition: Vector3;
  15154. /**
  15155. * Represents device rotation in babylon space.
  15156. */
  15157. deviceRotationQuaternion: Quaternion;
  15158. /**
  15159. * The scale of the device to be used when translating from device space to babylon space.
  15160. */
  15161. deviceScaleFactor: number;
  15162. private _deviceToWorld;
  15163. private _worldToDevice;
  15164. /**
  15165. * References to the webVR controllers for the vrDevice.
  15166. */
  15167. controllers: Array<WebVRController>;
  15168. /**
  15169. * Emits an event when a controller is attached.
  15170. */
  15171. onControllersAttachedObservable: Observable<WebVRController[]>;
  15172. /**
  15173. * Emits an event when a controller's mesh has been loaded;
  15174. */
  15175. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15176. /**
  15177. * Emits an event when the HMD's pose has been updated.
  15178. */
  15179. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15180. private _poseSet;
  15181. /**
  15182. * If the rig cameras be used as parent instead of this camera.
  15183. */
  15184. rigParenting: boolean;
  15185. private _lightOnControllers;
  15186. private _defaultHeight?;
  15187. /**
  15188. * Instantiates a WebVRFreeCamera.
  15189. * @param name The name of the WebVRFreeCamera
  15190. * @param position The starting anchor position for the camera
  15191. * @param scene The scene the camera belongs to
  15192. * @param webVROptions a set of customizable options for the webVRCamera
  15193. */
  15194. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15195. /**
  15196. * Gets the device distance from the ground in meters.
  15197. * @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.
  15198. */
  15199. deviceDistanceToRoomGround(): number;
  15200. /**
  15201. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15202. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15203. */
  15204. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15205. /**
  15206. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15207. * @returns A promise with a boolean set to if the standing matrix is supported.
  15208. */
  15209. useStandingMatrixAsync(): Promise<boolean>;
  15210. /**
  15211. * Disposes the camera
  15212. */
  15213. dispose(): void;
  15214. /**
  15215. * Gets a vrController by name.
  15216. * @param name The name of the controller to retreive
  15217. * @returns the controller matching the name specified or null if not found
  15218. */
  15219. getControllerByName(name: string): Nullable<WebVRController>;
  15220. private _leftController;
  15221. /**
  15222. * The controller corresponding to the users left hand.
  15223. */
  15224. readonly leftController: Nullable<WebVRController>;
  15225. private _rightController;
  15226. /**
  15227. * The controller corresponding to the users right hand.
  15228. */
  15229. readonly rightController: Nullable<WebVRController>;
  15230. /**
  15231. * Casts a ray forward from the vrCamera's gaze.
  15232. * @param length Length of the ray (default: 100)
  15233. * @returns the ray corresponding to the gaze
  15234. */
  15235. getForwardRay(length?: number): Ray;
  15236. /**
  15237. * @hidden
  15238. * Updates the camera based on device's frame data
  15239. */
  15240. _checkInputs(): void;
  15241. /**
  15242. * Updates the poseControlled values based on the input device pose.
  15243. * @param poseData Pose coming from the device
  15244. */
  15245. updateFromDevice(poseData: DevicePose): void;
  15246. private _htmlElementAttached;
  15247. private _detachIfAttached;
  15248. /**
  15249. * WebVR's attach control will start broadcasting frames to the device.
  15250. * Note that in certain browsers (chrome for example) this function must be called
  15251. * within a user-interaction callback. Example:
  15252. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15253. *
  15254. * @param element html element to attach the vrDevice to
  15255. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15256. */
  15257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15258. /**
  15259. * Detaches the camera from the html element and disables VR
  15260. *
  15261. * @param element html element to detach from
  15262. */
  15263. detachControl(element: HTMLElement): void;
  15264. /**
  15265. * @returns the name of this class
  15266. */
  15267. getClassName(): string;
  15268. /**
  15269. * Calls resetPose on the vrDisplay
  15270. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15271. */
  15272. resetToCurrentRotation(): void;
  15273. /**
  15274. * @hidden
  15275. * Updates the rig cameras (left and right eye)
  15276. */
  15277. _updateRigCameras(): void;
  15278. private _workingVector;
  15279. private _oneVector;
  15280. private _workingMatrix;
  15281. private updateCacheCalled;
  15282. private _correctPositionIfNotTrackPosition;
  15283. /**
  15284. * @hidden
  15285. * Updates the cached values of the camera
  15286. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15287. */
  15288. _updateCache(ignoreParentClass?: boolean): void;
  15289. /**
  15290. * @hidden
  15291. * Get current device position in babylon world
  15292. */
  15293. _computeDevicePosition(): void;
  15294. /**
  15295. * Updates the current device position and rotation in the babylon world
  15296. */
  15297. update(): void;
  15298. /**
  15299. * @hidden
  15300. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15301. * @returns an identity matrix
  15302. */
  15303. _getViewMatrix(): Matrix;
  15304. private _tmpMatrix;
  15305. /**
  15306. * This function is called by the two RIG cameras.
  15307. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15308. * @hidden
  15309. */
  15310. _getWebVRViewMatrix(): Matrix;
  15311. /** @hidden */
  15312. _getWebVRProjectionMatrix(): Matrix;
  15313. private _onGamepadConnectedObserver;
  15314. private _onGamepadDisconnectedObserver;
  15315. private _updateCacheWhenTrackingDisabledObserver;
  15316. /**
  15317. * Initializes the controllers and their meshes
  15318. */
  15319. initControllers(): void;
  15320. }
  15321. }
  15322. declare module "babylonjs/PostProcesses/postProcess" {
  15323. import { Nullable } from "babylonjs/types";
  15324. import { SmartArray } from "babylonjs/Misc/smartArray";
  15325. import { Observable } from "babylonjs/Misc/observable";
  15326. import { Vector2 } from "babylonjs/Maths/math.vector";
  15327. import { Camera } from "babylonjs/Cameras/camera";
  15328. import { Effect } from "babylonjs/Materials/effect";
  15329. import "babylonjs/Shaders/postprocess.vertex";
  15330. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15331. import { Engine } from "babylonjs/Engines/engine";
  15332. import { Color4 } from "babylonjs/Maths/math.color";
  15333. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15334. /**
  15335. * Size options for a post process
  15336. */
  15337. export type PostProcessOptions = {
  15338. width: number;
  15339. height: number;
  15340. };
  15341. /**
  15342. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15343. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15344. */
  15345. export class PostProcess {
  15346. /** Name of the PostProcess. */
  15347. name: string;
  15348. /**
  15349. * Gets or sets the unique id of the post process
  15350. */
  15351. uniqueId: number;
  15352. /**
  15353. * Width of the texture to apply the post process on
  15354. */
  15355. width: number;
  15356. /**
  15357. * Height of the texture to apply the post process on
  15358. */
  15359. height: number;
  15360. /**
  15361. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15362. * @hidden
  15363. */
  15364. _outputTexture: Nullable<InternalTexture>;
  15365. /**
  15366. * Sampling mode used by the shader
  15367. * See https://doc.babylonjs.com/classes/3.1/texture
  15368. */
  15369. renderTargetSamplingMode: number;
  15370. /**
  15371. * Clear color to use when screen clearing
  15372. */
  15373. clearColor: Color4;
  15374. /**
  15375. * If the buffer needs to be cleared before applying the post process. (default: true)
  15376. * Should be set to false if shader will overwrite all previous pixels.
  15377. */
  15378. autoClear: boolean;
  15379. /**
  15380. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15381. */
  15382. alphaMode: number;
  15383. /**
  15384. * Sets the setAlphaBlendConstants of the babylon engine
  15385. */
  15386. alphaConstants: Color4;
  15387. /**
  15388. * Animations to be used for the post processing
  15389. */
  15390. animations: import("babylonjs/Animations/animation").Animation[];
  15391. /**
  15392. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15393. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15394. */
  15395. enablePixelPerfectMode: boolean;
  15396. /**
  15397. * Force the postprocess to be applied without taking in account viewport
  15398. */
  15399. forceFullscreenViewport: boolean;
  15400. /**
  15401. * List of inspectable custom properties (used by the Inspector)
  15402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15403. */
  15404. inspectableCustomProperties: IInspectable[];
  15405. /**
  15406. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15407. *
  15408. * | Value | Type | Description |
  15409. * | ----- | ----------------------------------- | ----------- |
  15410. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15411. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15412. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15413. *
  15414. */
  15415. scaleMode: number;
  15416. /**
  15417. * Force textures to be a power of two (default: false)
  15418. */
  15419. alwaysForcePOT: boolean;
  15420. private _samples;
  15421. /**
  15422. * Number of sample textures (default: 1)
  15423. */
  15424. samples: number;
  15425. /**
  15426. * Modify the scale of the post process to be the same as the viewport (default: false)
  15427. */
  15428. adaptScaleToCurrentViewport: boolean;
  15429. private _camera;
  15430. private _scene;
  15431. private _engine;
  15432. private _options;
  15433. private _reusable;
  15434. private _textureType;
  15435. /**
  15436. * Smart array of input and output textures for the post process.
  15437. * @hidden
  15438. */
  15439. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15440. /**
  15441. * The index in _textures that corresponds to the output texture.
  15442. * @hidden
  15443. */
  15444. _currentRenderTextureInd: number;
  15445. private _effect;
  15446. private _samplers;
  15447. private _fragmentUrl;
  15448. private _vertexUrl;
  15449. private _parameters;
  15450. private _scaleRatio;
  15451. protected _indexParameters: any;
  15452. private _shareOutputWithPostProcess;
  15453. private _texelSize;
  15454. private _forcedOutputTexture;
  15455. /**
  15456. * Returns the fragment url or shader name used in the post process.
  15457. * @returns the fragment url or name in the shader store.
  15458. */
  15459. getEffectName(): string;
  15460. /**
  15461. * An event triggered when the postprocess is activated.
  15462. */
  15463. onActivateObservable: Observable<Camera>;
  15464. private _onActivateObserver;
  15465. /**
  15466. * A function that is added to the onActivateObservable
  15467. */
  15468. onActivate: Nullable<(camera: Camera) => void>;
  15469. /**
  15470. * An event triggered when the postprocess changes its size.
  15471. */
  15472. onSizeChangedObservable: Observable<PostProcess>;
  15473. private _onSizeChangedObserver;
  15474. /**
  15475. * A function that is added to the onSizeChangedObservable
  15476. */
  15477. onSizeChanged: (postProcess: PostProcess) => void;
  15478. /**
  15479. * An event triggered when the postprocess applies its effect.
  15480. */
  15481. onApplyObservable: Observable<Effect>;
  15482. private _onApplyObserver;
  15483. /**
  15484. * A function that is added to the onApplyObservable
  15485. */
  15486. onApply: (effect: Effect) => void;
  15487. /**
  15488. * An event triggered before rendering the postprocess
  15489. */
  15490. onBeforeRenderObservable: Observable<Effect>;
  15491. private _onBeforeRenderObserver;
  15492. /**
  15493. * A function that is added to the onBeforeRenderObservable
  15494. */
  15495. onBeforeRender: (effect: Effect) => void;
  15496. /**
  15497. * An event triggered after rendering the postprocess
  15498. */
  15499. onAfterRenderObservable: Observable<Effect>;
  15500. private _onAfterRenderObserver;
  15501. /**
  15502. * A function that is added to the onAfterRenderObservable
  15503. */
  15504. onAfterRender: (efect: Effect) => void;
  15505. /**
  15506. * 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
  15507. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15508. */
  15509. inputTexture: InternalTexture;
  15510. /**
  15511. * Gets the camera which post process is applied to.
  15512. * @returns The camera the post process is applied to.
  15513. */
  15514. getCamera(): Camera;
  15515. /**
  15516. * Gets the texel size of the postprocess.
  15517. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15518. */
  15519. readonly texelSize: Vector2;
  15520. /**
  15521. * Creates a new instance PostProcess
  15522. * @param name The name of the PostProcess.
  15523. * @param fragmentUrl The url of the fragment shader to be used.
  15524. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15525. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15526. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15527. * @param camera The camera to apply the render pass to.
  15528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15529. * @param engine The engine which the post process will be applied. (default: current engine)
  15530. * @param reusable If the post process can be reused on the same frame. (default: false)
  15531. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15532. * @param textureType Type of textures used when performing the post process. (default: 0)
  15533. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15534. * @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
  15535. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15536. */
  15537. constructor(
  15538. /** Name of the PostProcess. */
  15539. 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);
  15540. /**
  15541. * Gets a string idenfifying the name of the class
  15542. * @returns "PostProcess" string
  15543. */
  15544. getClassName(): string;
  15545. /**
  15546. * Gets the engine which this post process belongs to.
  15547. * @returns The engine the post process was enabled with.
  15548. */
  15549. getEngine(): Engine;
  15550. /**
  15551. * The effect that is created when initializing the post process.
  15552. * @returns The created effect corresponding the the postprocess.
  15553. */
  15554. getEffect(): Effect;
  15555. /**
  15556. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15557. * @param postProcess The post process to share the output with.
  15558. * @returns This post process.
  15559. */
  15560. shareOutputWith(postProcess: PostProcess): PostProcess;
  15561. /**
  15562. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15563. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15564. */
  15565. useOwnOutput(): void;
  15566. /**
  15567. * Updates the effect with the current post process compile time values and recompiles the shader.
  15568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15571. * @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
  15572. * @param onCompiled Called when the shader has been compiled.
  15573. * @param onError Called if there is an error when compiling a shader.
  15574. */
  15575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15576. /**
  15577. * The post process is reusable if it can be used multiple times within one frame.
  15578. * @returns If the post process is reusable
  15579. */
  15580. isReusable(): boolean;
  15581. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15582. markTextureDirty(): void;
  15583. /**
  15584. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15585. * 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.
  15586. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15587. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15588. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15589. * @returns The target texture that was bound to be written to.
  15590. */
  15591. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15592. /**
  15593. * If the post process is supported.
  15594. */
  15595. readonly isSupported: boolean;
  15596. /**
  15597. * The aspect ratio of the output texture.
  15598. */
  15599. readonly aspectRatio: number;
  15600. /**
  15601. * Get a value indicating if the post-process is ready to be used
  15602. * @returns true if the post-process is ready (shader is compiled)
  15603. */
  15604. isReady(): boolean;
  15605. /**
  15606. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15607. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15608. */
  15609. apply(): Nullable<Effect>;
  15610. private _disposeTextures;
  15611. /**
  15612. * Disposes the post process.
  15613. * @param camera The camera to dispose the post process on.
  15614. */
  15615. dispose(camera?: Camera): void;
  15616. }
  15617. }
  15618. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15619. /** @hidden */
  15620. export var kernelBlurVaryingDeclaration: {
  15621. name: string;
  15622. shader: string;
  15623. };
  15624. }
  15625. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15626. /** @hidden */
  15627. export var kernelBlurFragment: {
  15628. name: string;
  15629. shader: string;
  15630. };
  15631. }
  15632. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15633. /** @hidden */
  15634. export var kernelBlurFragment2: {
  15635. name: string;
  15636. shader: string;
  15637. };
  15638. }
  15639. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15640. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15641. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15642. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15643. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15644. /** @hidden */
  15645. export var kernelBlurPixelShader: {
  15646. name: string;
  15647. shader: string;
  15648. };
  15649. }
  15650. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15651. /** @hidden */
  15652. export var kernelBlurVertex: {
  15653. name: string;
  15654. shader: string;
  15655. };
  15656. }
  15657. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15658. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15659. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15660. /** @hidden */
  15661. export var kernelBlurVertexShader: {
  15662. name: string;
  15663. shader: string;
  15664. };
  15665. }
  15666. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15667. import { Vector2 } from "babylonjs/Maths/math.vector";
  15668. import { Nullable } from "babylonjs/types";
  15669. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15670. import { Camera } from "babylonjs/Cameras/camera";
  15671. import { Effect } from "babylonjs/Materials/effect";
  15672. import { Engine } from "babylonjs/Engines/engine";
  15673. import "babylonjs/Shaders/kernelBlur.fragment";
  15674. import "babylonjs/Shaders/kernelBlur.vertex";
  15675. /**
  15676. * The Blur Post Process which blurs an image based on a kernel and direction.
  15677. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15678. */
  15679. export class BlurPostProcess extends PostProcess {
  15680. /** The direction in which to blur the image. */
  15681. direction: Vector2;
  15682. private blockCompilation;
  15683. protected _kernel: number;
  15684. protected _idealKernel: number;
  15685. protected _packedFloat: boolean;
  15686. private _staticDefines;
  15687. /**
  15688. * Sets the length in pixels of the blur sample region
  15689. */
  15690. /**
  15691. * Gets the length in pixels of the blur sample region
  15692. */
  15693. kernel: number;
  15694. /**
  15695. * Sets wether or not the blur needs to unpack/repack floats
  15696. */
  15697. /**
  15698. * Gets wether or not the blur is unpacking/repacking floats
  15699. */
  15700. packedFloat: boolean;
  15701. /**
  15702. * Creates a new instance BlurPostProcess
  15703. * @param name The name of the effect.
  15704. * @param direction The direction in which to blur the image.
  15705. * @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.
  15706. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15707. * @param camera The camera to apply the render pass to.
  15708. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15709. * @param engine The engine which the post process will be applied. (default: current engine)
  15710. * @param reusable If the post process can be reused on the same frame. (default: false)
  15711. * @param textureType Type of textures used when performing the post process. (default: 0)
  15712. * @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)
  15713. */
  15714. constructor(name: string,
  15715. /** The direction in which to blur the image. */
  15716. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15717. /**
  15718. * Updates the effect with the current post process compile time values and recompiles the shader.
  15719. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15720. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15721. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15722. * @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
  15723. * @param onCompiled Called when the shader has been compiled.
  15724. * @param onError Called if there is an error when compiling a shader.
  15725. */
  15726. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15727. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15728. /**
  15729. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15730. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15731. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15732. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15733. * The gaps between physical kernels are compensated for in the weighting of the samples
  15734. * @param idealKernel Ideal blur kernel.
  15735. * @return Nearest best kernel.
  15736. */
  15737. protected _nearestBestKernel(idealKernel: number): number;
  15738. /**
  15739. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15740. * @param x The point on the Gaussian distribution to sample.
  15741. * @return the value of the Gaussian function at x.
  15742. */
  15743. protected _gaussianWeight(x: number): number;
  15744. /**
  15745. * Generates a string that can be used as a floating point number in GLSL.
  15746. * @param x Value to print.
  15747. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15748. * @return GLSL float string.
  15749. */
  15750. protected _glslFloat(x: number, decimalFigures?: number): string;
  15751. }
  15752. }
  15753. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15754. import { Scene } from "babylonjs/scene";
  15755. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15756. import { Plane } from "babylonjs/Maths/math.plane";
  15757. /**
  15758. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15759. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15760. * You can then easily use it as a reflectionTexture on a flat surface.
  15761. * In case the surface is not a plane, please consider relying on reflection probes.
  15762. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15763. */
  15764. export class MirrorTexture extends RenderTargetTexture {
  15765. private scene;
  15766. /**
  15767. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15768. * 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.
  15769. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15770. */
  15771. mirrorPlane: Plane;
  15772. /**
  15773. * Define the blur ratio used to blur the reflection if needed.
  15774. */
  15775. blurRatio: number;
  15776. /**
  15777. * Define the adaptive blur kernel used to blur the reflection if needed.
  15778. * This will autocompute the closest best match for the `blurKernel`
  15779. */
  15780. adaptiveBlurKernel: number;
  15781. /**
  15782. * Define the blur kernel used to blur the reflection if needed.
  15783. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15784. */
  15785. blurKernel: number;
  15786. /**
  15787. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15789. */
  15790. blurKernelX: number;
  15791. /**
  15792. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15793. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15794. */
  15795. blurKernelY: number;
  15796. private _autoComputeBlurKernel;
  15797. protected _onRatioRescale(): void;
  15798. private _updateGammaSpace;
  15799. private _imageProcessingConfigChangeObserver;
  15800. private _transformMatrix;
  15801. private _mirrorMatrix;
  15802. private _savedViewMatrix;
  15803. private _blurX;
  15804. private _blurY;
  15805. private _adaptiveBlurKernel;
  15806. private _blurKernelX;
  15807. private _blurKernelY;
  15808. private _blurRatio;
  15809. /**
  15810. * Instantiates a Mirror Texture.
  15811. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15812. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15813. * You can then easily use it as a reflectionTexture on a flat surface.
  15814. * In case the surface is not a plane, please consider relying on reflection probes.
  15815. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15816. * @param name
  15817. * @param size
  15818. * @param scene
  15819. * @param generateMipMaps
  15820. * @param type
  15821. * @param samplingMode
  15822. * @param generateDepthBuffer
  15823. */
  15824. constructor(name: string, size: number | {
  15825. width: number;
  15826. height: number;
  15827. } | {
  15828. ratio: number;
  15829. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15830. private _preparePostProcesses;
  15831. /**
  15832. * Clone the mirror texture.
  15833. * @returns the cloned texture
  15834. */
  15835. clone(): MirrorTexture;
  15836. /**
  15837. * Serialize the texture to a JSON representation you could use in Parse later on
  15838. * @returns the serialized JSON representation
  15839. */
  15840. serialize(): any;
  15841. /**
  15842. * Dispose the texture and release its associated resources.
  15843. */
  15844. dispose(): void;
  15845. }
  15846. }
  15847. declare module "babylonjs/Materials/Textures/texture" {
  15848. import { Observable } from "babylonjs/Misc/observable";
  15849. import { Nullable } from "babylonjs/types";
  15850. import { Scene } from "babylonjs/scene";
  15851. import { Matrix } from "babylonjs/Maths/math.vector";
  15852. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15853. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15854. import { Engine } from "babylonjs/Engines/engine";
  15855. /**
  15856. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15857. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15858. */
  15859. export class Texture extends BaseTexture {
  15860. /** @hidden */
  15861. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15862. /** @hidden */
  15863. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15864. /** @hidden */
  15865. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15866. /** nearest is mag = nearest and min = nearest and mip = linear */
  15867. static readonly NEAREST_SAMPLINGMODE: number;
  15868. /** nearest is mag = nearest and min = nearest and mip = linear */
  15869. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15870. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15871. static readonly BILINEAR_SAMPLINGMODE: number;
  15872. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15873. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15874. /** Trilinear is mag = linear and min = linear and mip = linear */
  15875. static readonly TRILINEAR_SAMPLINGMODE: number;
  15876. /** Trilinear is mag = linear and min = linear and mip = linear */
  15877. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15878. /** mag = nearest and min = nearest and mip = nearest */
  15879. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15880. /** mag = nearest and min = linear and mip = nearest */
  15881. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15882. /** mag = nearest and min = linear and mip = linear */
  15883. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15884. /** mag = nearest and min = linear and mip = none */
  15885. static readonly NEAREST_LINEAR: number;
  15886. /** mag = nearest and min = nearest and mip = none */
  15887. static readonly NEAREST_NEAREST: number;
  15888. /** mag = linear and min = nearest and mip = nearest */
  15889. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15890. /** mag = linear and min = nearest and mip = linear */
  15891. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15892. /** mag = linear and min = linear and mip = none */
  15893. static readonly LINEAR_LINEAR: number;
  15894. /** mag = linear and min = nearest and mip = none */
  15895. static readonly LINEAR_NEAREST: number;
  15896. /** Explicit coordinates mode */
  15897. static readonly EXPLICIT_MODE: number;
  15898. /** Spherical coordinates mode */
  15899. static readonly SPHERICAL_MODE: number;
  15900. /** Planar coordinates mode */
  15901. static readonly PLANAR_MODE: number;
  15902. /** Cubic coordinates mode */
  15903. static readonly CUBIC_MODE: number;
  15904. /** Projection coordinates mode */
  15905. static readonly PROJECTION_MODE: number;
  15906. /** Inverse Cubic coordinates mode */
  15907. static readonly SKYBOX_MODE: number;
  15908. /** Inverse Cubic coordinates mode */
  15909. static readonly INVCUBIC_MODE: number;
  15910. /** Equirectangular coordinates mode */
  15911. static readonly EQUIRECTANGULAR_MODE: number;
  15912. /** Equirectangular Fixed coordinates mode */
  15913. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15914. /** Equirectangular Fixed Mirrored coordinates mode */
  15915. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15916. /** Texture is not repeating outside of 0..1 UVs */
  15917. static readonly CLAMP_ADDRESSMODE: number;
  15918. /** Texture is repeating outside of 0..1 UVs */
  15919. static readonly WRAP_ADDRESSMODE: number;
  15920. /** Texture is repeating and mirrored */
  15921. static readonly MIRROR_ADDRESSMODE: number;
  15922. /**
  15923. * 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
  15924. */
  15925. static UseSerializedUrlIfAny: boolean;
  15926. /**
  15927. * Define the url of the texture.
  15928. */
  15929. url: Nullable<string>;
  15930. /**
  15931. * Define an offset on the texture to offset the u coordinates of the UVs
  15932. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15933. */
  15934. uOffset: number;
  15935. /**
  15936. * Define an offset on the texture to offset the v coordinates of the UVs
  15937. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15938. */
  15939. vOffset: number;
  15940. /**
  15941. * Define an offset on the texture to scale the u coordinates of the UVs
  15942. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15943. */
  15944. uScale: number;
  15945. /**
  15946. * Define an offset on the texture to scale the v coordinates of the UVs
  15947. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15948. */
  15949. vScale: number;
  15950. /**
  15951. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15952. * @see http://doc.babylonjs.com/how_to/more_materials
  15953. */
  15954. uAng: number;
  15955. /**
  15956. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15957. * @see http://doc.babylonjs.com/how_to/more_materials
  15958. */
  15959. vAng: number;
  15960. /**
  15961. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15962. * @see http://doc.babylonjs.com/how_to/more_materials
  15963. */
  15964. wAng: number;
  15965. /**
  15966. * Defines the center of rotation (U)
  15967. */
  15968. uRotationCenter: number;
  15969. /**
  15970. * Defines the center of rotation (V)
  15971. */
  15972. vRotationCenter: number;
  15973. /**
  15974. * Defines the center of rotation (W)
  15975. */
  15976. wRotationCenter: number;
  15977. /**
  15978. * Are mip maps generated for this texture or not.
  15979. */
  15980. readonly noMipmap: boolean;
  15981. /**
  15982. * List of inspectable custom properties (used by the Inspector)
  15983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15984. */
  15985. inspectableCustomProperties: Nullable<IInspectable[]>;
  15986. private _noMipmap;
  15987. /** @hidden */
  15988. _invertY: boolean;
  15989. private _rowGenerationMatrix;
  15990. private _cachedTextureMatrix;
  15991. private _projectionModeMatrix;
  15992. private _t0;
  15993. private _t1;
  15994. private _t2;
  15995. private _cachedUOffset;
  15996. private _cachedVOffset;
  15997. private _cachedUScale;
  15998. private _cachedVScale;
  15999. private _cachedUAng;
  16000. private _cachedVAng;
  16001. private _cachedWAng;
  16002. private _cachedProjectionMatrixId;
  16003. private _cachedCoordinatesMode;
  16004. /** @hidden */
  16005. protected _initialSamplingMode: number;
  16006. /** @hidden */
  16007. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16008. private _deleteBuffer;
  16009. protected _format: Nullable<number>;
  16010. private _delayedOnLoad;
  16011. private _delayedOnError;
  16012. /**
  16013. * Observable triggered once the texture has been loaded.
  16014. */
  16015. onLoadObservable: Observable<Texture>;
  16016. protected _isBlocking: boolean;
  16017. /**
  16018. * Is the texture preventing material to render while loading.
  16019. * If false, a default texture will be used instead of the loading one during the preparation step.
  16020. */
  16021. isBlocking: boolean;
  16022. /**
  16023. * Get the current sampling mode associated with the texture.
  16024. */
  16025. readonly samplingMode: number;
  16026. /**
  16027. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16028. */
  16029. readonly invertY: boolean;
  16030. /**
  16031. * Instantiates a new texture.
  16032. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16033. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16034. * @param url define the url of the picture to load as a texture
  16035. * @param scene define the scene or engine the texture will belong to
  16036. * @param noMipmap define if the texture will require mip maps or not
  16037. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16038. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16039. * @param onLoad define a callback triggered when the texture has been loaded
  16040. * @param onError define a callback triggered when an error occurred during the loading session
  16041. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16042. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16043. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16044. */
  16045. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  16046. /**
  16047. * Update the url (and optional buffer) of this texture if url was null during construction.
  16048. * @param url the url of the texture
  16049. * @param buffer the buffer of the texture (defaults to null)
  16050. * @param onLoad callback called when the texture is loaded (defaults to null)
  16051. */
  16052. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16053. /**
  16054. * Finish the loading sequence of a texture flagged as delayed load.
  16055. * @hidden
  16056. */
  16057. delayLoad(): void;
  16058. private _prepareRowForTextureGeneration;
  16059. /**
  16060. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16061. * @returns the transform matrix of the texture.
  16062. */
  16063. getTextureMatrix(): Matrix;
  16064. /**
  16065. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16066. * @returns The reflection texture transform
  16067. */
  16068. getReflectionTextureMatrix(): Matrix;
  16069. /**
  16070. * Clones the texture.
  16071. * @returns the cloned texture
  16072. */
  16073. clone(): Texture;
  16074. /**
  16075. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16076. * @returns The JSON representation of the texture
  16077. */
  16078. serialize(): any;
  16079. /**
  16080. * Get the current class name of the texture useful for serialization or dynamic coding.
  16081. * @returns "Texture"
  16082. */
  16083. getClassName(): string;
  16084. /**
  16085. * Dispose the texture and release its associated resources.
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16090. * @param parsedTexture Define the JSON representation of the texture
  16091. * @param scene Define the scene the parsed texture should be instantiated in
  16092. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16093. * @returns The parsed texture if successful
  16094. */
  16095. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16096. /**
  16097. * Creates a texture from its base 64 representation.
  16098. * @param data Define the base64 payload without the data: prefix
  16099. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16100. * @param scene Define the scene the texture should belong to
  16101. * @param noMipmap Forces the texture to not create mip map information if true
  16102. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16103. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16104. * @param onLoad define a callback triggered when the texture has been loaded
  16105. * @param onError define a callback triggered when an error occurred during the loading session
  16106. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16107. * @returns the created texture
  16108. */
  16109. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16110. /**
  16111. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16112. * @param data Define the base64 payload without the data: prefix
  16113. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16114. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16115. * @param scene Define the scene the texture should belong to
  16116. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16117. * @param noMipmap Forces the texture to not create mip map information if true
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16123. * @returns the created texture
  16124. */
  16125. 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;
  16126. }
  16127. }
  16128. declare module "babylonjs/PostProcesses/postProcessManager" {
  16129. import { Nullable } from "babylonjs/types";
  16130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16131. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16132. import { Scene } from "babylonjs/scene";
  16133. /**
  16134. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16135. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16136. */
  16137. export class PostProcessManager {
  16138. private _scene;
  16139. private _indexBuffer;
  16140. private _vertexBuffers;
  16141. /**
  16142. * Creates a new instance PostProcess
  16143. * @param scene The scene that the post process is associated with.
  16144. */
  16145. constructor(scene: Scene);
  16146. private _prepareBuffers;
  16147. private _buildIndexBuffer;
  16148. /**
  16149. * Rebuilds the vertex buffers of the manager.
  16150. * @hidden
  16151. */
  16152. _rebuild(): void;
  16153. /**
  16154. * Prepares a frame to be run through a post process.
  16155. * @param sourceTexture The input texture to the post procesess. (default: null)
  16156. * @param postProcesses An array of post processes to be run. (default: null)
  16157. * @returns True if the post processes were able to be run.
  16158. * @hidden
  16159. */
  16160. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16161. /**
  16162. * Manually render a set of post processes to a texture.
  16163. * @param postProcesses An array of post processes to be run.
  16164. * @param targetTexture The target texture to render to.
  16165. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16166. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16167. * @param lodLevel defines which lod of the texture to render to
  16168. */
  16169. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16170. /**
  16171. * Finalize the result of the output of the postprocesses.
  16172. * @param doNotPresent If true the result will not be displayed to the screen.
  16173. * @param targetTexture The target texture to render to.
  16174. * @param faceIndex The index of the face to bind the target texture to.
  16175. * @param postProcesses The array of post processes to render.
  16176. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16177. * @hidden
  16178. */
  16179. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16180. /**
  16181. * Disposes of the post process manager.
  16182. */
  16183. dispose(): void;
  16184. }
  16185. }
  16186. declare module "babylonjs/Misc/gradients" {
  16187. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16188. /** Interface used by value gradients (color, factor, ...) */
  16189. export interface IValueGradient {
  16190. /**
  16191. * Gets or sets the gradient value (between 0 and 1)
  16192. */
  16193. gradient: number;
  16194. }
  16195. /** Class used to store color4 gradient */
  16196. export class ColorGradient implements IValueGradient {
  16197. /**
  16198. * Gets or sets the gradient value (between 0 and 1)
  16199. */
  16200. gradient: number;
  16201. /**
  16202. * Gets or sets first associated color
  16203. */
  16204. color1: Color4;
  16205. /**
  16206. * Gets or sets second associated color
  16207. */
  16208. color2?: Color4;
  16209. /**
  16210. * Will get a color picked randomly between color1 and color2.
  16211. * If color2 is undefined then color1 will be used
  16212. * @param result defines the target Color4 to store the result in
  16213. */
  16214. getColorToRef(result: Color4): void;
  16215. }
  16216. /** Class used to store color 3 gradient */
  16217. export class Color3Gradient implements IValueGradient {
  16218. /**
  16219. * Gets or sets the gradient value (between 0 and 1)
  16220. */
  16221. gradient: number;
  16222. /**
  16223. * Gets or sets the associated color
  16224. */
  16225. color: Color3;
  16226. }
  16227. /** Class used to store factor gradient */
  16228. export class FactorGradient implements IValueGradient {
  16229. /**
  16230. * Gets or sets the gradient value (between 0 and 1)
  16231. */
  16232. gradient: number;
  16233. /**
  16234. * Gets or sets first associated factor
  16235. */
  16236. factor1: number;
  16237. /**
  16238. * Gets or sets second associated factor
  16239. */
  16240. factor2?: number;
  16241. /**
  16242. * Will get a number picked randomly between factor1 and factor2.
  16243. * If factor2 is undefined then factor1 will be used
  16244. * @returns the picked number
  16245. */
  16246. getFactor(): number;
  16247. }
  16248. /**
  16249. * Helper used to simplify some generic gradient tasks
  16250. */
  16251. export class GradientHelper {
  16252. /**
  16253. * Gets the current gradient from an array of IValueGradient
  16254. * @param ratio defines the current ratio to get
  16255. * @param gradients defines the array of IValueGradient
  16256. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16257. */
  16258. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16259. }
  16260. }
  16261. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16262. import { Scene } from "babylonjs/scene";
  16263. import { ISceneComponent } from "babylonjs/sceneComponent";
  16264. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16265. module "babylonjs/abstractScene" {
  16266. interface AbstractScene {
  16267. /**
  16268. * The list of procedural textures added to the scene
  16269. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16270. */
  16271. proceduralTextures: Array<ProceduralTexture>;
  16272. }
  16273. }
  16274. /**
  16275. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16276. * in a given scene.
  16277. */
  16278. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16279. /**
  16280. * The component name helpfull to identify the component in the list of scene components.
  16281. */
  16282. readonly name: string;
  16283. /**
  16284. * The scene the component belongs to.
  16285. */
  16286. scene: Scene;
  16287. /**
  16288. * Creates a new instance of the component for the given scene
  16289. * @param scene Defines the scene to register the component in
  16290. */
  16291. constructor(scene: Scene);
  16292. /**
  16293. * Registers the component in a given scene
  16294. */
  16295. register(): void;
  16296. /**
  16297. * Rebuilds the elements related to this component in case of
  16298. * context lost for instance.
  16299. */
  16300. rebuild(): void;
  16301. /**
  16302. * Disposes the component and the associated ressources.
  16303. */
  16304. dispose(): void;
  16305. private _beforeClear;
  16306. }
  16307. }
  16308. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16309. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16310. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16311. module "babylonjs/Engines/engine" {
  16312. interface Engine {
  16313. /**
  16314. * Creates a new render target cube texture
  16315. * @param size defines the size of the texture
  16316. * @param options defines the options used to create the texture
  16317. * @returns a new render target cube texture stored in an InternalTexture
  16318. */
  16319. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16320. }
  16321. }
  16322. }
  16323. declare module "babylonjs/Shaders/procedural.vertex" {
  16324. /** @hidden */
  16325. export var proceduralVertexShader: {
  16326. name: string;
  16327. shader: string;
  16328. };
  16329. }
  16330. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16331. import { Observable } from "babylonjs/Misc/observable";
  16332. import { Nullable } from "babylonjs/types";
  16333. import { Scene } from "babylonjs/scene";
  16334. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16335. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16336. import { Effect } from "babylonjs/Materials/effect";
  16337. import { Texture } from "babylonjs/Materials/Textures/texture";
  16338. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16339. import "babylonjs/Shaders/procedural.vertex";
  16340. /**
  16341. * 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.
  16342. * This is the base class of any Procedural texture and contains most of the shareable code.
  16343. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16344. */
  16345. export class ProceduralTexture extends Texture {
  16346. isCube: boolean;
  16347. /**
  16348. * Define if the texture is enabled or not (disabled texture will not render)
  16349. */
  16350. isEnabled: boolean;
  16351. /**
  16352. * Define if the texture must be cleared before rendering (default is true)
  16353. */
  16354. autoClear: boolean;
  16355. /**
  16356. * Callback called when the texture is generated
  16357. */
  16358. onGenerated: () => void;
  16359. /**
  16360. * Event raised when the texture is generated
  16361. */
  16362. onGeneratedObservable: Observable<ProceduralTexture>;
  16363. /** @hidden */
  16364. _generateMipMaps: boolean;
  16365. /** @hidden **/
  16366. _effect: Effect;
  16367. /** @hidden */
  16368. _textures: {
  16369. [key: string]: Texture;
  16370. };
  16371. private _size;
  16372. private _currentRefreshId;
  16373. private _refreshRate;
  16374. private _vertexBuffers;
  16375. private _indexBuffer;
  16376. private _uniforms;
  16377. private _samplers;
  16378. private _fragment;
  16379. private _floats;
  16380. private _ints;
  16381. private _floatsArrays;
  16382. private _colors3;
  16383. private _colors4;
  16384. private _vectors2;
  16385. private _vectors3;
  16386. private _matrices;
  16387. private _fallbackTexture;
  16388. private _fallbackTextureUsed;
  16389. private _engine;
  16390. private _cachedDefines;
  16391. private _contentUpdateId;
  16392. private _contentData;
  16393. /**
  16394. * Instantiates a new procedural texture.
  16395. * 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.
  16396. * This is the base class of any Procedural texture and contains most of the shareable code.
  16397. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16398. * @param name Define the name of the texture
  16399. * @param size Define the size of the texture to create
  16400. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16401. * @param scene Define the scene the texture belongs to
  16402. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16403. * @param generateMipMaps Define if the texture should creates mip maps or not
  16404. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16405. */
  16406. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16407. /**
  16408. * The effect that is created when initializing the post process.
  16409. * @returns The created effect corresponding the the postprocess.
  16410. */
  16411. getEffect(): Effect;
  16412. /**
  16413. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16414. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16415. */
  16416. getContent(): Nullable<ArrayBufferView>;
  16417. private _createIndexBuffer;
  16418. /** @hidden */
  16419. _rebuild(): void;
  16420. /**
  16421. * Resets the texture in order to recreate its associated resources.
  16422. * This can be called in case of context loss
  16423. */
  16424. reset(): void;
  16425. protected _getDefines(): string;
  16426. /**
  16427. * Is the texture ready to be used ? (rendered at least once)
  16428. * @returns true if ready, otherwise, false.
  16429. */
  16430. isReady(): boolean;
  16431. /**
  16432. * Resets the refresh counter of the texture and start bak from scratch.
  16433. * Could be useful to regenerate the texture if it is setup to render only once.
  16434. */
  16435. resetRefreshCounter(): void;
  16436. /**
  16437. * Set the fragment shader to use in order to render the texture.
  16438. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16439. */
  16440. setFragment(fragment: any): void;
  16441. /**
  16442. * Define the refresh rate of the texture or the rendering frequency.
  16443. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16444. */
  16445. refreshRate: number;
  16446. /** @hidden */
  16447. _shouldRender(): boolean;
  16448. /**
  16449. * Get the size the texture is rendering at.
  16450. * @returns the size (texture is always squared)
  16451. */
  16452. getRenderSize(): number;
  16453. /**
  16454. * Resize the texture to new value.
  16455. * @param size Define the new size the texture should have
  16456. * @param generateMipMaps Define whether the new texture should create mip maps
  16457. */
  16458. resize(size: number, generateMipMaps: boolean): void;
  16459. private _checkUniform;
  16460. /**
  16461. * Set a texture in the shader program used to render.
  16462. * @param name Define the name of the uniform samplers as defined in the shader
  16463. * @param texture Define the texture to bind to this sampler
  16464. * @return the texture itself allowing "fluent" like uniform updates
  16465. */
  16466. setTexture(name: string, texture: Texture): ProceduralTexture;
  16467. /**
  16468. * Set a float in the shader.
  16469. * @param name Define the name of the uniform as defined in the shader
  16470. * @param value Define the value to give to the uniform
  16471. * @return the texture itself allowing "fluent" like uniform updates
  16472. */
  16473. setFloat(name: string, value: number): ProceduralTexture;
  16474. /**
  16475. * Set a int in the shader.
  16476. * @param name Define the name of the uniform as defined in the shader
  16477. * @param value Define the value to give to the uniform
  16478. * @return the texture itself allowing "fluent" like uniform updates
  16479. */
  16480. setInt(name: string, value: number): ProceduralTexture;
  16481. /**
  16482. * Set an array of floats in the shader.
  16483. * @param name Define the name of the uniform as defined in the shader
  16484. * @param value Define the value to give to the uniform
  16485. * @return the texture itself allowing "fluent" like uniform updates
  16486. */
  16487. setFloats(name: string, value: number[]): ProceduralTexture;
  16488. /**
  16489. * Set a vec3 in the shader from a Color3.
  16490. * @param name Define the name of the uniform as defined in the shader
  16491. * @param value Define the value to give to the uniform
  16492. * @return the texture itself allowing "fluent" like uniform updates
  16493. */
  16494. setColor3(name: string, value: Color3): ProceduralTexture;
  16495. /**
  16496. * Set a vec4 in the shader from a Color4.
  16497. * @param name Define the name of the uniform as defined in the shader
  16498. * @param value Define the value to give to the uniform
  16499. * @return the texture itself allowing "fluent" like uniform updates
  16500. */
  16501. setColor4(name: string, value: Color4): ProceduralTexture;
  16502. /**
  16503. * Set a vec2 in the shader from a Vector2.
  16504. * @param name Define the name of the uniform as defined in the shader
  16505. * @param value Define the value to give to the uniform
  16506. * @return the texture itself allowing "fluent" like uniform updates
  16507. */
  16508. setVector2(name: string, value: Vector2): ProceduralTexture;
  16509. /**
  16510. * Set a vec3 in the shader from a Vector3.
  16511. * @param name Define the name of the uniform as defined in the shader
  16512. * @param value Define the value to give to the uniform
  16513. * @return the texture itself allowing "fluent" like uniform updates
  16514. */
  16515. setVector3(name: string, value: Vector3): ProceduralTexture;
  16516. /**
  16517. * Set a mat4 in the shader from a MAtrix.
  16518. * @param name Define the name of the uniform as defined in the shader
  16519. * @param value Define the value to give to the uniform
  16520. * @return the texture itself allowing "fluent" like uniform updates
  16521. */
  16522. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16523. /**
  16524. * Render the texture to its associated render target.
  16525. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16526. */
  16527. render(useCameraPostProcess?: boolean): void;
  16528. /**
  16529. * Clone the texture.
  16530. * @returns the cloned texture
  16531. */
  16532. clone(): ProceduralTexture;
  16533. /**
  16534. * Dispose the texture and release its asoociated resources.
  16535. */
  16536. dispose(): void;
  16537. }
  16538. }
  16539. declare module "babylonjs/Particles/baseParticleSystem" {
  16540. import { Nullable } from "babylonjs/types";
  16541. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16543. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16544. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16545. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16546. import { Scene } from "babylonjs/scene";
  16547. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16548. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16549. import { Texture } from "babylonjs/Materials/Textures/texture";
  16550. import { Color4 } from "babylonjs/Maths/math.color";
  16551. import { Animation } from "babylonjs/Animations/animation";
  16552. /**
  16553. * This represents the base class for particle system in Babylon.
  16554. * 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.
  16555. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16556. * @example https://doc.babylonjs.com/babylon101/particles
  16557. */
  16558. export class BaseParticleSystem {
  16559. /**
  16560. * Source color is added to the destination color without alpha affecting the result
  16561. */
  16562. static BLENDMODE_ONEONE: number;
  16563. /**
  16564. * Blend current color and particle color using particle’s alpha
  16565. */
  16566. static BLENDMODE_STANDARD: number;
  16567. /**
  16568. * Add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_ADD: number;
  16571. /**
  16572. * Multiply current color with particle color
  16573. */
  16574. static BLENDMODE_MULTIPLY: number;
  16575. /**
  16576. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16577. */
  16578. static BLENDMODE_MULTIPLYADD: number;
  16579. /**
  16580. * List of animations used by the particle system.
  16581. */
  16582. animations: Animation[];
  16583. /**
  16584. * The id of the Particle system.
  16585. */
  16586. id: string;
  16587. /**
  16588. * The friendly name of the Particle system.
  16589. */
  16590. name: string;
  16591. /**
  16592. * The rendering group used by the Particle system to chose when to render.
  16593. */
  16594. renderingGroupId: number;
  16595. /**
  16596. * The emitter represents the Mesh or position we are attaching the particle system to.
  16597. */
  16598. emitter: Nullable<AbstractMesh | Vector3>;
  16599. /**
  16600. * The maximum number of particles to emit per frame
  16601. */
  16602. emitRate: number;
  16603. /**
  16604. * If you want to launch only a few particles at once, that can be done, as well.
  16605. */
  16606. manualEmitCount: number;
  16607. /**
  16608. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16609. */
  16610. updateSpeed: number;
  16611. /**
  16612. * The amount of time the particle system is running (depends of the overall update speed).
  16613. */
  16614. targetStopDuration: number;
  16615. /**
  16616. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16617. */
  16618. disposeOnStop: boolean;
  16619. /**
  16620. * Minimum power of emitting particles.
  16621. */
  16622. minEmitPower: number;
  16623. /**
  16624. * Maximum power of emitting particles.
  16625. */
  16626. maxEmitPower: number;
  16627. /**
  16628. * Minimum life time of emitting particles.
  16629. */
  16630. minLifeTime: number;
  16631. /**
  16632. * Maximum life time of emitting particles.
  16633. */
  16634. maxLifeTime: number;
  16635. /**
  16636. * Minimum Size of emitting particles.
  16637. */
  16638. minSize: number;
  16639. /**
  16640. * Maximum Size of emitting particles.
  16641. */
  16642. maxSize: number;
  16643. /**
  16644. * Minimum scale of emitting particles on X axis.
  16645. */
  16646. minScaleX: number;
  16647. /**
  16648. * Maximum scale of emitting particles on X axis.
  16649. */
  16650. maxScaleX: number;
  16651. /**
  16652. * Minimum scale of emitting particles on Y axis.
  16653. */
  16654. minScaleY: number;
  16655. /**
  16656. * Maximum scale of emitting particles on Y axis.
  16657. */
  16658. maxScaleY: number;
  16659. /**
  16660. * Gets or sets the minimal initial rotation in radians.
  16661. */
  16662. minInitialRotation: number;
  16663. /**
  16664. * Gets or sets the maximal initial rotation in radians.
  16665. */
  16666. maxInitialRotation: number;
  16667. /**
  16668. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16669. */
  16670. minAngularSpeed: number;
  16671. /**
  16672. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16673. */
  16674. maxAngularSpeed: number;
  16675. /**
  16676. * The texture used to render each particle. (this can be a spritesheet)
  16677. */
  16678. particleTexture: Nullable<Texture>;
  16679. /**
  16680. * The layer mask we are rendering the particles through.
  16681. */
  16682. layerMask: number;
  16683. /**
  16684. * This can help using your own shader to render the particle system.
  16685. * The according effect will be created
  16686. */
  16687. customShader: any;
  16688. /**
  16689. * By default particle system starts as soon as they are created. This prevents the
  16690. * automatic start to happen and let you decide when to start emitting particles.
  16691. */
  16692. preventAutoStart: boolean;
  16693. private _noiseTexture;
  16694. /**
  16695. * Gets or sets a texture used to add random noise to particle positions
  16696. */
  16697. noiseTexture: Nullable<ProceduralTexture>;
  16698. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16699. noiseStrength: Vector3;
  16700. /**
  16701. * Callback triggered when the particle animation is ending.
  16702. */
  16703. onAnimationEnd: Nullable<() => void>;
  16704. /**
  16705. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16706. */
  16707. blendMode: number;
  16708. /**
  16709. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16710. * to override the particles.
  16711. */
  16712. forceDepthWrite: boolean;
  16713. /** 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 */
  16714. preWarmCycles: number;
  16715. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16716. preWarmStepOffset: number;
  16717. /**
  16718. * 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)
  16719. */
  16720. spriteCellChangeSpeed: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16723. */
  16724. startSpriteCellID: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16727. */
  16728. endSpriteCellID: number;
  16729. /**
  16730. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16731. */
  16732. spriteCellWidth: number;
  16733. /**
  16734. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16735. */
  16736. spriteCellHeight: number;
  16737. /**
  16738. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16739. */
  16740. spriteRandomStartCell: boolean;
  16741. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16742. translationPivot: Vector2;
  16743. /** @hidden */
  16744. protected _isAnimationSheetEnabled: boolean;
  16745. /**
  16746. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16747. */
  16748. beginAnimationOnStart: boolean;
  16749. /**
  16750. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationFrom: number;
  16753. /**
  16754. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16755. */
  16756. beginAnimationTo: number;
  16757. /**
  16758. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16759. */
  16760. beginAnimationLoop: boolean;
  16761. /**
  16762. * Gets or sets a world offset applied to all particles
  16763. */
  16764. worldOffset: Vector3;
  16765. /**
  16766. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16767. */
  16768. isAnimationSheetEnabled: boolean;
  16769. /**
  16770. * Get hosting scene
  16771. * @returns the scene
  16772. */
  16773. getScene(): Scene;
  16774. /**
  16775. * You can use gravity if you want to give an orientation to your particles.
  16776. */
  16777. gravity: Vector3;
  16778. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16779. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16780. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16781. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16782. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16783. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16784. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16785. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16786. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16787. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16788. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16789. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16790. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16791. /**
  16792. * Defines the delay in milliseconds before starting the system (0 by default)
  16793. */
  16794. startDelay: number;
  16795. /**
  16796. * Gets the current list of drag gradients.
  16797. * You must use addDragGradient and removeDragGradient to udpate this list
  16798. * @returns the list of drag gradients
  16799. */
  16800. getDragGradients(): Nullable<Array<FactorGradient>>;
  16801. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16802. limitVelocityDamping: number;
  16803. /**
  16804. * Gets the current list of limit velocity gradients.
  16805. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16806. * @returns the list of limit velocity gradients
  16807. */
  16808. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16809. /**
  16810. * Gets the current list of color gradients.
  16811. * You must use addColorGradient and removeColorGradient to udpate this list
  16812. * @returns the list of color gradients
  16813. */
  16814. getColorGradients(): Nullable<Array<ColorGradient>>;
  16815. /**
  16816. * Gets the current list of size gradients.
  16817. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16818. * @returns the list of size gradients
  16819. */
  16820. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16821. /**
  16822. * Gets the current list of color remap gradients.
  16823. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16824. * @returns the list of color remap gradients
  16825. */
  16826. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16827. /**
  16828. * Gets the current list of alpha remap gradients.
  16829. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16830. * @returns the list of alpha remap gradients
  16831. */
  16832. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Gets the current list of life time gradients.
  16835. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16836. * @returns the list of life time gradients
  16837. */
  16838. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16839. /**
  16840. * Gets the current list of angular speed gradients.
  16841. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16842. * @returns the list of angular speed gradients
  16843. */
  16844. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16845. /**
  16846. * Gets the current list of velocity gradients.
  16847. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16848. * @returns the list of velocity gradients
  16849. */
  16850. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Gets the current list of start size gradients.
  16853. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16854. * @returns the list of start size gradients
  16855. */
  16856. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16857. /**
  16858. * Gets the current list of emit rate gradients.
  16859. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16860. * @returns the list of emit rate gradients
  16861. */
  16862. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16863. /**
  16864. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16865. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16866. */
  16867. direction1: Vector3;
  16868. /**
  16869. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16870. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16871. */
  16872. direction2: Vector3;
  16873. /**
  16874. * 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.
  16875. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16876. */
  16877. minEmitBox: Vector3;
  16878. /**
  16879. * 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.
  16880. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16881. */
  16882. maxEmitBox: Vector3;
  16883. /**
  16884. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16885. */
  16886. color1: Color4;
  16887. /**
  16888. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16889. */
  16890. color2: Color4;
  16891. /**
  16892. * Color the particle will have at the end of its lifetime
  16893. */
  16894. colorDead: Color4;
  16895. /**
  16896. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16897. */
  16898. textureMask: Color4;
  16899. /**
  16900. * The particle emitter type defines the emitter used by the particle system.
  16901. * It can be for example box, sphere, or cone...
  16902. */
  16903. particleEmitterType: IParticleEmitterType;
  16904. /** @hidden */
  16905. _isSubEmitter: boolean;
  16906. /**
  16907. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16908. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16909. */
  16910. billboardMode: number;
  16911. protected _isBillboardBased: boolean;
  16912. /**
  16913. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16914. */
  16915. isBillboardBased: boolean;
  16916. /**
  16917. * The scene the particle system belongs to.
  16918. */
  16919. protected _scene: Scene;
  16920. /**
  16921. * Local cache of defines for image processing.
  16922. */
  16923. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16924. /**
  16925. * Default configuration related to image processing available in the standard Material.
  16926. */
  16927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16928. /**
  16929. * Gets the image processing configuration used either in this material.
  16930. */
  16931. /**
  16932. * Sets the Default image processing configuration used either in the this material.
  16933. *
  16934. * If sets to null, the scene one is in use.
  16935. */
  16936. imageProcessingConfiguration: ImageProcessingConfiguration;
  16937. /**
  16938. * Attaches a new image processing configuration to the Standard Material.
  16939. * @param configuration
  16940. */
  16941. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16942. /** @hidden */
  16943. protected _reset(): void;
  16944. /** @hidden */
  16945. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16946. /**
  16947. * Instantiates a particle system.
  16948. * 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.
  16949. * @param name The name of the particle system
  16950. */
  16951. constructor(name: string);
  16952. /**
  16953. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16956. * @returns the emitter
  16957. */
  16958. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16959. /**
  16960. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16961. * @param radius The radius of the hemisphere to emit from
  16962. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16963. * @returns the emitter
  16964. */
  16965. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16966. /**
  16967. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16968. * @param radius The radius of the sphere to emit from
  16969. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16970. * @returns the emitter
  16971. */
  16972. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16973. /**
  16974. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16975. * @param radius The radius of the sphere to emit from
  16976. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16977. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16978. * @returns the emitter
  16979. */
  16980. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16981. /**
  16982. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16983. * @param radius The radius of the emission cylinder
  16984. * @param height The height of the emission cylinder
  16985. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16986. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16987. * @returns the emitter
  16988. */
  16989. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16990. /**
  16991. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16992. * @param radius The radius of the cylinder to emit from
  16993. * @param height The height of the emission cylinder
  16994. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16995. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16996. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16997. * @returns the emitter
  16998. */
  16999. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17000. /**
  17001. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17002. * @param radius The radius of the cone to emit from
  17003. * @param angle The base angle of the cone
  17004. * @returns the emitter
  17005. */
  17006. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17007. /**
  17008. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17011. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17012. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17013. * @returns the emitter
  17014. */
  17015. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17016. }
  17017. }
  17018. declare module "babylonjs/Particles/subEmitter" {
  17019. import { Scene } from "babylonjs/scene";
  17020. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17021. /**
  17022. * Type of sub emitter
  17023. */
  17024. export enum SubEmitterType {
  17025. /**
  17026. * Attached to the particle over it's lifetime
  17027. */
  17028. ATTACHED = 0,
  17029. /**
  17030. * Created when the particle dies
  17031. */
  17032. END = 1
  17033. }
  17034. /**
  17035. * Sub emitter class used to emit particles from an existing particle
  17036. */
  17037. export class SubEmitter {
  17038. /**
  17039. * the particle system to be used by the sub emitter
  17040. */
  17041. particleSystem: ParticleSystem;
  17042. /**
  17043. * Type of the submitter (Default: END)
  17044. */
  17045. type: SubEmitterType;
  17046. /**
  17047. * 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)
  17048. * Note: This only is supported when using an emitter of type Mesh
  17049. */
  17050. inheritDirection: boolean;
  17051. /**
  17052. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17053. */
  17054. inheritedVelocityAmount: number;
  17055. /**
  17056. * Creates a sub emitter
  17057. * @param particleSystem the particle system to be used by the sub emitter
  17058. */
  17059. constructor(
  17060. /**
  17061. * the particle system to be used by the sub emitter
  17062. */
  17063. particleSystem: ParticleSystem);
  17064. /**
  17065. * Clones the sub emitter
  17066. * @returns the cloned sub emitter
  17067. */
  17068. clone(): SubEmitter;
  17069. /**
  17070. * Serialize current object to a JSON object
  17071. * @returns the serialized object
  17072. */
  17073. serialize(): any;
  17074. /** @hidden */
  17075. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17076. /**
  17077. * Creates a new SubEmitter from a serialized JSON version
  17078. * @param serializationObject defines the JSON object to read from
  17079. * @param scene defines the hosting scene
  17080. * @param rootUrl defines the rootUrl for data loading
  17081. * @returns a new SubEmitter
  17082. */
  17083. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17084. /** Release associated resources */
  17085. dispose(): void;
  17086. }
  17087. }
  17088. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17089. /** @hidden */
  17090. export var clipPlaneFragmentDeclaration: {
  17091. name: string;
  17092. shader: string;
  17093. };
  17094. }
  17095. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17096. /** @hidden */
  17097. export var imageProcessingDeclaration: {
  17098. name: string;
  17099. shader: string;
  17100. };
  17101. }
  17102. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17103. /** @hidden */
  17104. export var imageProcessingFunctions: {
  17105. name: string;
  17106. shader: string;
  17107. };
  17108. }
  17109. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17110. /** @hidden */
  17111. export var clipPlaneFragment: {
  17112. name: string;
  17113. shader: string;
  17114. };
  17115. }
  17116. declare module "babylonjs/Shaders/particles.fragment" {
  17117. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17118. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17119. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17120. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17121. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17122. /** @hidden */
  17123. export var particlesPixelShader: {
  17124. name: string;
  17125. shader: string;
  17126. };
  17127. }
  17128. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17129. /** @hidden */
  17130. export var clipPlaneVertexDeclaration: {
  17131. name: string;
  17132. shader: string;
  17133. };
  17134. }
  17135. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17136. /** @hidden */
  17137. export var clipPlaneVertex: {
  17138. name: string;
  17139. shader: string;
  17140. };
  17141. }
  17142. declare module "babylonjs/Shaders/particles.vertex" {
  17143. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17145. /** @hidden */
  17146. export var particlesVertexShader: {
  17147. name: string;
  17148. shader: string;
  17149. };
  17150. }
  17151. declare module "babylonjs/Particles/particleSystem" {
  17152. import { Nullable } from "babylonjs/types";
  17153. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17154. import { Observable } from "babylonjs/Misc/observable";
  17155. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17156. import { Effect } from "babylonjs/Materials/effect";
  17157. import { Scene, IDisposable } from "babylonjs/scene";
  17158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17159. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17160. import { Particle } from "babylonjs/Particles/particle";
  17161. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17162. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17163. import "babylonjs/Shaders/particles.fragment";
  17164. import "babylonjs/Shaders/particles.vertex";
  17165. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17166. /**
  17167. * This represents a particle system in Babylon.
  17168. * 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.
  17169. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17170. * @example https://doc.babylonjs.com/babylon101/particles
  17171. */
  17172. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17173. /**
  17174. * Billboard mode will only apply to Y axis
  17175. */
  17176. static readonly BILLBOARDMODE_Y: number;
  17177. /**
  17178. * Billboard mode will apply to all axes
  17179. */
  17180. static readonly BILLBOARDMODE_ALL: number;
  17181. /**
  17182. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17183. */
  17184. static readonly BILLBOARDMODE_STRETCHED: number;
  17185. /**
  17186. * This function can be defined to provide custom update for active particles.
  17187. * This function will be called instead of regular update (age, position, color, etc.).
  17188. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17189. */
  17190. updateFunction: (particles: Particle[]) => void;
  17191. private _emitterWorldMatrix;
  17192. /**
  17193. * This function can be defined to specify initial direction for every new particle.
  17194. * It by default use the emitterType defined function
  17195. */
  17196. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17197. /**
  17198. * This function can be defined to specify initial position for every new particle.
  17199. * It by default use the emitterType defined function
  17200. */
  17201. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17202. /**
  17203. * @hidden
  17204. */
  17205. _inheritedVelocityOffset: Vector3;
  17206. /**
  17207. * An event triggered when the system is disposed
  17208. */
  17209. onDisposeObservable: Observable<ParticleSystem>;
  17210. private _onDisposeObserver;
  17211. /**
  17212. * Sets a callback that will be triggered when the system is disposed
  17213. */
  17214. onDispose: () => void;
  17215. private _particles;
  17216. private _epsilon;
  17217. private _capacity;
  17218. private _stockParticles;
  17219. private _newPartsExcess;
  17220. private _vertexData;
  17221. private _vertexBuffer;
  17222. private _vertexBuffers;
  17223. private _spriteBuffer;
  17224. private _indexBuffer;
  17225. private _effect;
  17226. private _customEffect;
  17227. private _cachedDefines;
  17228. private _scaledColorStep;
  17229. private _colorDiff;
  17230. private _scaledDirection;
  17231. private _scaledGravity;
  17232. private _currentRenderId;
  17233. private _alive;
  17234. private _useInstancing;
  17235. private _started;
  17236. private _stopped;
  17237. private _actualFrame;
  17238. private _scaledUpdateSpeed;
  17239. private _vertexBufferSize;
  17240. /** @hidden */
  17241. _currentEmitRateGradient: Nullable<FactorGradient>;
  17242. /** @hidden */
  17243. _currentEmitRate1: number;
  17244. /** @hidden */
  17245. _currentEmitRate2: number;
  17246. /** @hidden */
  17247. _currentStartSizeGradient: Nullable<FactorGradient>;
  17248. /** @hidden */
  17249. _currentStartSize1: number;
  17250. /** @hidden */
  17251. _currentStartSize2: number;
  17252. private readonly _rawTextureWidth;
  17253. private _rampGradientsTexture;
  17254. private _useRampGradients;
  17255. /** Gets or sets a boolean indicating that ramp gradients must be used
  17256. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17257. */
  17258. useRampGradients: boolean;
  17259. /**
  17260. * 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.
  17261. * 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: [])
  17262. */
  17263. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17264. private _subEmitters;
  17265. /**
  17266. * @hidden
  17267. * If the particle systems emitter should be disposed when the particle system is disposed
  17268. */
  17269. _disposeEmitterOnDispose: boolean;
  17270. /**
  17271. * The current active Sub-systems, this property is used by the root particle system only.
  17272. */
  17273. activeSubSystems: Array<ParticleSystem>;
  17274. private _rootParticleSystem;
  17275. /**
  17276. * Gets the current list of active particles
  17277. */
  17278. readonly particles: Particle[];
  17279. /**
  17280. * Returns the string "ParticleSystem"
  17281. * @returns a string containing the class name
  17282. */
  17283. getClassName(): string;
  17284. /**
  17285. * Instantiates a particle system.
  17286. * 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.
  17287. * @param name The name of the particle system
  17288. * @param capacity The max number of particles alive at the same time
  17289. * @param scene The scene the particle system belongs to
  17290. * @param customEffect a custom effect used to change the way particles are rendered by default
  17291. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17292. * @param epsilon Offset used to render the particles
  17293. */
  17294. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17295. private _addFactorGradient;
  17296. private _removeFactorGradient;
  17297. /**
  17298. * Adds a new life time gradient
  17299. * @param gradient defines the gradient to use (between 0 and 1)
  17300. * @param factor defines the life time factor to affect to the specified gradient
  17301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17302. * @returns the current particle system
  17303. */
  17304. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17305. /**
  17306. * Remove a specific life time gradient
  17307. * @param gradient defines the gradient to remove
  17308. * @returns the current particle system
  17309. */
  17310. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17311. /**
  17312. * Adds a new size gradient
  17313. * @param gradient defines the gradient to use (between 0 and 1)
  17314. * @param factor defines the size factor to affect to the specified gradient
  17315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17316. * @returns the current particle system
  17317. */
  17318. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17319. /**
  17320. * Remove a specific size gradient
  17321. * @param gradient defines the gradient to remove
  17322. * @returns the current particle system
  17323. */
  17324. removeSizeGradient(gradient: number): IParticleSystem;
  17325. /**
  17326. * Adds a new color remap gradient
  17327. * @param gradient defines the gradient to use (between 0 and 1)
  17328. * @param min defines the color remap minimal range
  17329. * @param max defines the color remap maximal range
  17330. * @returns the current particle system
  17331. */
  17332. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17333. /**
  17334. * Remove a specific color remap gradient
  17335. * @param gradient defines the gradient to remove
  17336. * @returns the current particle system
  17337. */
  17338. removeColorRemapGradient(gradient: number): IParticleSystem;
  17339. /**
  17340. * Adds a new alpha remap gradient
  17341. * @param gradient defines the gradient to use (between 0 and 1)
  17342. * @param min defines the alpha remap minimal range
  17343. * @param max defines the alpha remap maximal range
  17344. * @returns the current particle system
  17345. */
  17346. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17347. /**
  17348. * Remove a specific alpha remap gradient
  17349. * @param gradient defines the gradient to remove
  17350. * @returns the current particle system
  17351. */
  17352. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17353. /**
  17354. * Adds a new angular speed gradient
  17355. * @param gradient defines the gradient to use (between 0 and 1)
  17356. * @param factor defines the angular speed to affect to the specified gradient
  17357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17358. * @returns the current particle system
  17359. */
  17360. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17361. /**
  17362. * Remove a specific angular speed gradient
  17363. * @param gradient defines the gradient to remove
  17364. * @returns the current particle system
  17365. */
  17366. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17367. /**
  17368. * Adds a new velocity gradient
  17369. * @param gradient defines the gradient to use (between 0 and 1)
  17370. * @param factor defines the velocity to affect to the specified gradient
  17371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17372. * @returns the current particle system
  17373. */
  17374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17375. /**
  17376. * Remove a specific velocity gradient
  17377. * @param gradient defines the gradient to remove
  17378. * @returns the current particle system
  17379. */
  17380. removeVelocityGradient(gradient: number): IParticleSystem;
  17381. /**
  17382. * Adds a new limit velocity gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the limit velocity value to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific limit velocity gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new drag gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param factor defines the drag value to affect to the specified gradient
  17399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17400. * @returns the current particle system
  17401. */
  17402. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific drag gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeDragGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17411. * @param gradient defines the gradient to use (between 0 and 1)
  17412. * @param factor defines the emit rate value to affect to the specified gradient
  17413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17414. * @returns the current particle system
  17415. */
  17416. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17417. /**
  17418. * Remove a specific emit rate gradient
  17419. * @param gradient defines the gradient to remove
  17420. * @returns the current particle system
  17421. */
  17422. removeEmitRateGradient(gradient: number): IParticleSystem;
  17423. /**
  17424. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17425. * @param gradient defines the gradient to use (between 0 and 1)
  17426. * @param factor defines the start size value to affect to the specified gradient
  17427. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17428. * @returns the current particle system
  17429. */
  17430. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17431. /**
  17432. * Remove a specific start size gradient
  17433. * @param gradient defines the gradient to remove
  17434. * @returns the current particle system
  17435. */
  17436. removeStartSizeGradient(gradient: number): IParticleSystem;
  17437. private _createRampGradientTexture;
  17438. /**
  17439. * Gets the current list of ramp gradients.
  17440. * You must use addRampGradient and removeRampGradient to udpate this list
  17441. * @returns the list of ramp gradients
  17442. */
  17443. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17444. /**
  17445. * Adds a new ramp gradient used to remap particle colors
  17446. * @param gradient defines the gradient to use (between 0 and 1)
  17447. * @param color defines the color to affect to the specified gradient
  17448. * @returns the current particle system
  17449. */
  17450. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17451. /**
  17452. * Remove a specific ramp gradient
  17453. * @param gradient defines the gradient to remove
  17454. * @returns the current particle system
  17455. */
  17456. removeRampGradient(gradient: number): ParticleSystem;
  17457. /**
  17458. * Adds a new color gradient
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param color1 defines the color to affect to the specified gradient
  17461. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17462. * @returns this particle system
  17463. */
  17464. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17465. /**
  17466. * Remove a specific color gradient
  17467. * @param gradient defines the gradient to remove
  17468. * @returns this particle system
  17469. */
  17470. removeColorGradient(gradient: number): IParticleSystem;
  17471. private _fetchR;
  17472. protected _reset(): void;
  17473. private _resetEffect;
  17474. private _createVertexBuffers;
  17475. private _createIndexBuffer;
  17476. /**
  17477. * Gets the maximum number of particles active at the same time.
  17478. * @returns The max number of active particles.
  17479. */
  17480. getCapacity(): number;
  17481. /**
  17482. * Gets whether there are still active particles in the system.
  17483. * @returns True if it is alive, otherwise false.
  17484. */
  17485. isAlive(): boolean;
  17486. /**
  17487. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17488. * @returns True if it has been started, otherwise false.
  17489. */
  17490. isStarted(): boolean;
  17491. private _prepareSubEmitterInternalArray;
  17492. /**
  17493. * Starts the particle system and begins to emit
  17494. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17495. */
  17496. start(delay?: number): void;
  17497. /**
  17498. * Stops the particle system.
  17499. * @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.
  17500. */
  17501. stop(stopSubEmitters?: boolean): void;
  17502. /**
  17503. * Remove all active particles
  17504. */
  17505. reset(): void;
  17506. /**
  17507. * @hidden (for internal use only)
  17508. */
  17509. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17510. /**
  17511. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17512. * Its lifetime will start back at 0.
  17513. */
  17514. recycleParticle: (particle: Particle) => void;
  17515. private _stopSubEmitters;
  17516. private _createParticle;
  17517. private _removeFromRoot;
  17518. private _emitFromParticle;
  17519. private _update;
  17520. /** @hidden */
  17521. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17522. /** @hidden */
  17523. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17524. /** @hidden */
  17525. private _getEffect;
  17526. /**
  17527. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17528. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17529. */
  17530. animate(preWarmOnly?: boolean): void;
  17531. private _appendParticleVertices;
  17532. /**
  17533. * Rebuilds the particle system.
  17534. */
  17535. rebuild(): void;
  17536. /**
  17537. * Is this system ready to be used/rendered
  17538. * @return true if the system is ready
  17539. */
  17540. isReady(): boolean;
  17541. private _render;
  17542. /**
  17543. * Renders the particle system in its current state.
  17544. * @returns the current number of particles
  17545. */
  17546. render(): number;
  17547. /**
  17548. * Disposes the particle system and free the associated resources
  17549. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17550. */
  17551. dispose(disposeTexture?: boolean): void;
  17552. /**
  17553. * Clones the particle system.
  17554. * @param name The name of the cloned object
  17555. * @param newEmitter The new emitter to use
  17556. * @returns the cloned particle system
  17557. */
  17558. clone(name: string, newEmitter: any): ParticleSystem;
  17559. /**
  17560. * Serializes the particle system to a JSON object.
  17561. * @returns the JSON object
  17562. */
  17563. serialize(): any;
  17564. /** @hidden */
  17565. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17566. /** @hidden */
  17567. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17568. /**
  17569. * Parses a JSON object to create a particle system.
  17570. * @param parsedParticleSystem The JSON object to parse
  17571. * @param scene The scene to create the particle system in
  17572. * @param rootUrl The root url to use to load external dependencies like texture
  17573. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17574. * @returns the Parsed particle system
  17575. */
  17576. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17577. }
  17578. }
  17579. declare module "babylonjs/Particles/particle" {
  17580. import { Nullable } from "babylonjs/types";
  17581. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17582. import { Color4 } from "babylonjs/Maths/math.color";
  17583. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17584. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17585. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17586. /**
  17587. * A particle represents one of the element emitted by a particle system.
  17588. * This is mainly define by its coordinates, direction, velocity and age.
  17589. */
  17590. export class Particle {
  17591. /**
  17592. * The particle system the particle belongs to.
  17593. */
  17594. particleSystem: ParticleSystem;
  17595. private static _Count;
  17596. /**
  17597. * Unique ID of the particle
  17598. */
  17599. id: number;
  17600. /**
  17601. * The world position of the particle in the scene.
  17602. */
  17603. position: Vector3;
  17604. /**
  17605. * The world direction of the particle in the scene.
  17606. */
  17607. direction: Vector3;
  17608. /**
  17609. * The color of the particle.
  17610. */
  17611. color: Color4;
  17612. /**
  17613. * The color change of the particle per step.
  17614. */
  17615. colorStep: Color4;
  17616. /**
  17617. * Defines how long will the life of the particle be.
  17618. */
  17619. lifeTime: number;
  17620. /**
  17621. * The current age of the particle.
  17622. */
  17623. age: number;
  17624. /**
  17625. * The current size of the particle.
  17626. */
  17627. size: number;
  17628. /**
  17629. * The current scale of the particle.
  17630. */
  17631. scale: Vector2;
  17632. /**
  17633. * The current angle of the particle.
  17634. */
  17635. angle: number;
  17636. /**
  17637. * Defines how fast is the angle changing.
  17638. */
  17639. angularSpeed: number;
  17640. /**
  17641. * Defines the cell index used by the particle to be rendered from a sprite.
  17642. */
  17643. cellIndex: number;
  17644. /**
  17645. * The information required to support color remapping
  17646. */
  17647. remapData: Vector4;
  17648. /** @hidden */
  17649. _randomCellOffset?: number;
  17650. /** @hidden */
  17651. _initialDirection: Nullable<Vector3>;
  17652. /** @hidden */
  17653. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17654. /** @hidden */
  17655. _initialStartSpriteCellID: number;
  17656. /** @hidden */
  17657. _initialEndSpriteCellID: number;
  17658. /** @hidden */
  17659. _currentColorGradient: Nullable<ColorGradient>;
  17660. /** @hidden */
  17661. _currentColor1: Color4;
  17662. /** @hidden */
  17663. _currentColor2: Color4;
  17664. /** @hidden */
  17665. _currentSizeGradient: Nullable<FactorGradient>;
  17666. /** @hidden */
  17667. _currentSize1: number;
  17668. /** @hidden */
  17669. _currentSize2: number;
  17670. /** @hidden */
  17671. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17672. /** @hidden */
  17673. _currentAngularSpeed1: number;
  17674. /** @hidden */
  17675. _currentAngularSpeed2: number;
  17676. /** @hidden */
  17677. _currentVelocityGradient: Nullable<FactorGradient>;
  17678. /** @hidden */
  17679. _currentVelocity1: number;
  17680. /** @hidden */
  17681. _currentVelocity2: number;
  17682. /** @hidden */
  17683. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17684. /** @hidden */
  17685. _currentLimitVelocity1: number;
  17686. /** @hidden */
  17687. _currentLimitVelocity2: number;
  17688. /** @hidden */
  17689. _currentDragGradient: Nullable<FactorGradient>;
  17690. /** @hidden */
  17691. _currentDrag1: number;
  17692. /** @hidden */
  17693. _currentDrag2: number;
  17694. /** @hidden */
  17695. _randomNoiseCoordinates1: Vector3;
  17696. /** @hidden */
  17697. _randomNoiseCoordinates2: Vector3;
  17698. /**
  17699. * Creates a new instance Particle
  17700. * @param particleSystem the particle system the particle belongs to
  17701. */
  17702. constructor(
  17703. /**
  17704. * The particle system the particle belongs to.
  17705. */
  17706. particleSystem: ParticleSystem);
  17707. private updateCellInfoFromSystem;
  17708. /**
  17709. * Defines how the sprite cell index is updated for the particle
  17710. */
  17711. updateCellIndex(): void;
  17712. /** @hidden */
  17713. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17714. /** @hidden */
  17715. _inheritParticleInfoToSubEmitters(): void;
  17716. /** @hidden */
  17717. _reset(): void;
  17718. /**
  17719. * Copy the properties of particle to another one.
  17720. * @param other the particle to copy the information to.
  17721. */
  17722. copyTo(other: Particle): void;
  17723. }
  17724. }
  17725. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17726. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17727. import { Effect } from "babylonjs/Materials/effect";
  17728. import { Particle } from "babylonjs/Particles/particle";
  17729. /**
  17730. * Particle emitter represents a volume emitting particles.
  17731. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17732. */
  17733. export interface IParticleEmitterType {
  17734. /**
  17735. * Called by the particle System when the direction is computed for the created particle.
  17736. * @param worldMatrix is the world matrix of the particle system
  17737. * @param directionToUpdate is the direction vector to update with the result
  17738. * @param particle is the particle we are computed the direction for
  17739. */
  17740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17741. /**
  17742. * Called by the particle System when the position is computed for the created particle.
  17743. * @param worldMatrix is the world matrix of the particle system
  17744. * @param positionToUpdate is the position vector to update with the result
  17745. * @param particle is the particle we are computed the position for
  17746. */
  17747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17748. /**
  17749. * Clones the current emitter and returns a copy of it
  17750. * @returns the new emitter
  17751. */
  17752. clone(): IParticleEmitterType;
  17753. /**
  17754. * Called by the GPUParticleSystem to setup the update shader
  17755. * @param effect defines the update shader
  17756. */
  17757. applyToShader(effect: Effect): void;
  17758. /**
  17759. * Returns a string to use to update the GPU particles update shader
  17760. * @returns the effect defines string
  17761. */
  17762. getEffectDefines(): string;
  17763. /**
  17764. * Returns a string representing the class name
  17765. * @returns a string containing the class name
  17766. */
  17767. getClassName(): string;
  17768. /**
  17769. * Serializes the particle system to a JSON object.
  17770. * @returns the JSON object
  17771. */
  17772. serialize(): any;
  17773. /**
  17774. * Parse properties from a JSON object
  17775. * @param serializationObject defines the JSON object
  17776. */
  17777. parse(serializationObject: any): void;
  17778. }
  17779. }
  17780. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17781. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17782. import { Effect } from "babylonjs/Materials/effect";
  17783. import { Particle } from "babylonjs/Particles/particle";
  17784. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17785. /**
  17786. * Particle emitter emitting particles from the inside of a box.
  17787. * It emits the particles randomly between 2 given directions.
  17788. */
  17789. export class BoxParticleEmitter implements IParticleEmitterType {
  17790. /**
  17791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17792. */
  17793. direction1: Vector3;
  17794. /**
  17795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17796. */
  17797. direction2: Vector3;
  17798. /**
  17799. * 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.
  17800. */
  17801. minEmitBox: Vector3;
  17802. /**
  17803. * 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.
  17804. */
  17805. maxEmitBox: Vector3;
  17806. /**
  17807. * Creates a new instance BoxParticleEmitter
  17808. */
  17809. constructor();
  17810. /**
  17811. * Called by the particle System when the direction is computed for the created particle.
  17812. * @param worldMatrix is the world matrix of the particle system
  17813. * @param directionToUpdate is the direction vector to update with the result
  17814. * @param particle is the particle we are computed the direction for
  17815. */
  17816. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17817. /**
  17818. * Called by the particle System when the position is computed for the created particle.
  17819. * @param worldMatrix is the world matrix of the particle system
  17820. * @param positionToUpdate is the position vector to update with the result
  17821. * @param particle is the particle we are computed the position for
  17822. */
  17823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17824. /**
  17825. * Clones the current emitter and returns a copy of it
  17826. * @returns the new emitter
  17827. */
  17828. clone(): BoxParticleEmitter;
  17829. /**
  17830. * Called by the GPUParticleSystem to setup the update shader
  17831. * @param effect defines the update shader
  17832. */
  17833. applyToShader(effect: Effect): void;
  17834. /**
  17835. * Returns a string to use to update the GPU particles update shader
  17836. * @returns a string containng the defines string
  17837. */
  17838. getEffectDefines(): string;
  17839. /**
  17840. * Returns the string "BoxParticleEmitter"
  17841. * @returns a string containing the class name
  17842. */
  17843. getClassName(): string;
  17844. /**
  17845. * Serializes the particle system to a JSON object.
  17846. * @returns the JSON object
  17847. */
  17848. serialize(): any;
  17849. /**
  17850. * Parse properties from a JSON object
  17851. * @param serializationObject defines the JSON object
  17852. */
  17853. parse(serializationObject: any): void;
  17854. }
  17855. }
  17856. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17858. import { Effect } from "babylonjs/Materials/effect";
  17859. import { Particle } from "babylonjs/Particles/particle";
  17860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17861. /**
  17862. * Particle emitter emitting particles from the inside of a cone.
  17863. * It emits the particles alongside the cone volume from the base to the particle.
  17864. * The emission direction might be randomized.
  17865. */
  17866. export class ConeParticleEmitter implements IParticleEmitterType {
  17867. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17868. directionRandomizer: number;
  17869. private _radius;
  17870. private _angle;
  17871. private _height;
  17872. /**
  17873. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17874. */
  17875. radiusRange: number;
  17876. /**
  17877. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17878. */
  17879. heightRange: number;
  17880. /**
  17881. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17882. */
  17883. emitFromSpawnPointOnly: boolean;
  17884. /**
  17885. * Gets or sets the radius of the emission cone
  17886. */
  17887. radius: number;
  17888. /**
  17889. * Gets or sets the angle of the emission cone
  17890. */
  17891. angle: number;
  17892. private _buildHeight;
  17893. /**
  17894. * Creates a new instance ConeParticleEmitter
  17895. * @param radius the radius of the emission cone (1 by default)
  17896. * @param angle the cone base angle (PI by default)
  17897. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17898. */
  17899. constructor(radius?: number, angle?: number,
  17900. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17901. directionRandomizer?: number);
  17902. /**
  17903. * Called by the particle System when the direction is computed for the created particle.
  17904. * @param worldMatrix is the world matrix of the particle system
  17905. * @param directionToUpdate is the direction vector to update with the result
  17906. * @param particle is the particle we are computed the direction for
  17907. */
  17908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17909. /**
  17910. * Called by the particle System when the position is computed for the created particle.
  17911. * @param worldMatrix is the world matrix of the particle system
  17912. * @param positionToUpdate is the position vector to update with the result
  17913. * @param particle is the particle we are computed the position for
  17914. */
  17915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17916. /**
  17917. * Clones the current emitter and returns a copy of it
  17918. * @returns the new emitter
  17919. */
  17920. clone(): ConeParticleEmitter;
  17921. /**
  17922. * Called by the GPUParticleSystem to setup the update shader
  17923. * @param effect defines the update shader
  17924. */
  17925. applyToShader(effect: Effect): void;
  17926. /**
  17927. * Returns a string to use to update the GPU particles update shader
  17928. * @returns a string containng the defines string
  17929. */
  17930. getEffectDefines(): string;
  17931. /**
  17932. * Returns the string "ConeParticleEmitter"
  17933. * @returns a string containing the class name
  17934. */
  17935. getClassName(): string;
  17936. /**
  17937. * Serializes the particle system to a JSON object.
  17938. * @returns the JSON object
  17939. */
  17940. serialize(): any;
  17941. /**
  17942. * Parse properties from a JSON object
  17943. * @param serializationObject defines the JSON object
  17944. */
  17945. parse(serializationObject: any): void;
  17946. }
  17947. }
  17948. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17949. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17950. import { Effect } from "babylonjs/Materials/effect";
  17951. import { Particle } from "babylonjs/Particles/particle";
  17952. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17953. /**
  17954. * Particle emitter emitting particles from the inside of a cylinder.
  17955. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17956. */
  17957. export class CylinderParticleEmitter implements IParticleEmitterType {
  17958. /**
  17959. * The radius of the emission cylinder.
  17960. */
  17961. radius: number;
  17962. /**
  17963. * The height of the emission cylinder.
  17964. */
  17965. height: number;
  17966. /**
  17967. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17968. */
  17969. radiusRange: number;
  17970. /**
  17971. * How much to randomize the particle direction [0-1].
  17972. */
  17973. directionRandomizer: number;
  17974. /**
  17975. * Creates a new instance CylinderParticleEmitter
  17976. * @param radius the radius of the emission cylinder (1 by default)
  17977. * @param height the height of the emission cylinder (1 by default)
  17978. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17979. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17980. */
  17981. constructor(
  17982. /**
  17983. * The radius of the emission cylinder.
  17984. */
  17985. radius?: number,
  17986. /**
  17987. * The height of the emission cylinder.
  17988. */
  17989. height?: number,
  17990. /**
  17991. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17992. */
  17993. radiusRange?: number,
  17994. /**
  17995. * How much to randomize the particle direction [0-1].
  17996. */
  17997. directionRandomizer?: number);
  17998. /**
  17999. * Called by the particle System when the direction is computed for the created particle.
  18000. * @param worldMatrix is the world matrix of the particle system
  18001. * @param directionToUpdate is the direction vector to update with the result
  18002. * @param particle is the particle we are computed the direction for
  18003. */
  18004. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18005. /**
  18006. * Called by the particle System when the position is computed for the created particle.
  18007. * @param worldMatrix is the world matrix of the particle system
  18008. * @param positionToUpdate is the position vector to update with the result
  18009. * @param particle is the particle we are computed the position for
  18010. */
  18011. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18012. /**
  18013. * Clones the current emitter and returns a copy of it
  18014. * @returns the new emitter
  18015. */
  18016. clone(): CylinderParticleEmitter;
  18017. /**
  18018. * Called by the GPUParticleSystem to setup the update shader
  18019. * @param effect defines the update shader
  18020. */
  18021. applyToShader(effect: Effect): void;
  18022. /**
  18023. * Returns a string to use to update the GPU particles update shader
  18024. * @returns a string containng the defines string
  18025. */
  18026. getEffectDefines(): string;
  18027. /**
  18028. * Returns the string "CylinderParticleEmitter"
  18029. * @returns a string containing the class name
  18030. */
  18031. getClassName(): string;
  18032. /**
  18033. * Serializes the particle system to a JSON object.
  18034. * @returns the JSON object
  18035. */
  18036. serialize(): any;
  18037. /**
  18038. * Parse properties from a JSON object
  18039. * @param serializationObject defines the JSON object
  18040. */
  18041. parse(serializationObject: any): void;
  18042. }
  18043. /**
  18044. * Particle emitter emitting particles from the inside of a cylinder.
  18045. * It emits the particles randomly between two vectors.
  18046. */
  18047. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18048. /**
  18049. * The min limit of the emission direction.
  18050. */
  18051. direction1: Vector3;
  18052. /**
  18053. * The max limit of the emission direction.
  18054. */
  18055. direction2: Vector3;
  18056. /**
  18057. * Creates a new instance CylinderDirectedParticleEmitter
  18058. * @param radius the radius of the emission cylinder (1 by default)
  18059. * @param height the height of the emission cylinder (1 by default)
  18060. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18061. * @param direction1 the min limit of the emission direction (up vector by default)
  18062. * @param direction2 the max limit of the emission direction (up vector by default)
  18063. */
  18064. constructor(radius?: number, height?: number, radiusRange?: number,
  18065. /**
  18066. * The min limit of the emission direction.
  18067. */
  18068. direction1?: Vector3,
  18069. /**
  18070. * The max limit of the emission direction.
  18071. */
  18072. direction2?: Vector3);
  18073. /**
  18074. * Called by the particle System when the direction is computed for the created particle.
  18075. * @param worldMatrix is the world matrix of the particle system
  18076. * @param directionToUpdate is the direction vector to update with the result
  18077. * @param particle is the particle we are computed the direction for
  18078. */
  18079. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18080. /**
  18081. * Clones the current emitter and returns a copy of it
  18082. * @returns the new emitter
  18083. */
  18084. clone(): CylinderDirectedParticleEmitter;
  18085. /**
  18086. * Called by the GPUParticleSystem to setup the update shader
  18087. * @param effect defines the update shader
  18088. */
  18089. applyToShader(effect: Effect): void;
  18090. /**
  18091. * Returns a string to use to update the GPU particles update shader
  18092. * @returns a string containng the defines string
  18093. */
  18094. getEffectDefines(): string;
  18095. /**
  18096. * Returns the string "CylinderDirectedParticleEmitter"
  18097. * @returns a string containing the class name
  18098. */
  18099. getClassName(): string;
  18100. /**
  18101. * Serializes the particle system to a JSON object.
  18102. * @returns the JSON object
  18103. */
  18104. serialize(): any;
  18105. /**
  18106. * Parse properties from a JSON object
  18107. * @param serializationObject defines the JSON object
  18108. */
  18109. parse(serializationObject: any): void;
  18110. }
  18111. }
  18112. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18113. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18114. import { Effect } from "babylonjs/Materials/effect";
  18115. import { Particle } from "babylonjs/Particles/particle";
  18116. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18117. /**
  18118. * Particle emitter emitting particles from the inside of a hemisphere.
  18119. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18120. */
  18121. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18122. /**
  18123. * The radius of the emission hemisphere.
  18124. */
  18125. radius: number;
  18126. /**
  18127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18128. */
  18129. radiusRange: number;
  18130. /**
  18131. * How much to randomize the particle direction [0-1].
  18132. */
  18133. directionRandomizer: number;
  18134. /**
  18135. * Creates a new instance HemisphericParticleEmitter
  18136. * @param radius the radius of the emission hemisphere (1 by default)
  18137. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18138. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18139. */
  18140. constructor(
  18141. /**
  18142. * The radius of the emission hemisphere.
  18143. */
  18144. radius?: number,
  18145. /**
  18146. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18147. */
  18148. radiusRange?: number,
  18149. /**
  18150. * How much to randomize the particle direction [0-1].
  18151. */
  18152. directionRandomizer?: number);
  18153. /**
  18154. * Called by the particle System when the direction is computed for the created particle.
  18155. * @param worldMatrix is the world matrix of the particle system
  18156. * @param directionToUpdate is the direction vector to update with the result
  18157. * @param particle is the particle we are computed the direction for
  18158. */
  18159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18160. /**
  18161. * Called by the particle System when the position is computed for the created particle.
  18162. * @param worldMatrix is the world matrix of the particle system
  18163. * @param positionToUpdate is the position vector to update with the result
  18164. * @param particle is the particle we are computed the position for
  18165. */
  18166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18167. /**
  18168. * Clones the current emitter and returns a copy of it
  18169. * @returns the new emitter
  18170. */
  18171. clone(): HemisphericParticleEmitter;
  18172. /**
  18173. * Called by the GPUParticleSystem to setup the update shader
  18174. * @param effect defines the update shader
  18175. */
  18176. applyToShader(effect: Effect): void;
  18177. /**
  18178. * Returns a string to use to update the GPU particles update shader
  18179. * @returns a string containng the defines string
  18180. */
  18181. getEffectDefines(): string;
  18182. /**
  18183. * Returns the string "HemisphericParticleEmitter"
  18184. * @returns a string containing the class name
  18185. */
  18186. getClassName(): string;
  18187. /**
  18188. * Serializes the particle system to a JSON object.
  18189. * @returns the JSON object
  18190. */
  18191. serialize(): any;
  18192. /**
  18193. * Parse properties from a JSON object
  18194. * @param serializationObject defines the JSON object
  18195. */
  18196. parse(serializationObject: any): void;
  18197. }
  18198. }
  18199. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18200. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18201. import { Effect } from "babylonjs/Materials/effect";
  18202. import { Particle } from "babylonjs/Particles/particle";
  18203. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18204. /**
  18205. * Particle emitter emitting particles from a point.
  18206. * It emits the particles randomly between 2 given directions.
  18207. */
  18208. export class PointParticleEmitter implements IParticleEmitterType {
  18209. /**
  18210. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18211. */
  18212. direction1: Vector3;
  18213. /**
  18214. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18215. */
  18216. direction2: Vector3;
  18217. /**
  18218. * Creates a new instance PointParticleEmitter
  18219. */
  18220. constructor();
  18221. /**
  18222. * Called by the particle System when the direction is computed for the created particle.
  18223. * @param worldMatrix is the world matrix of the particle system
  18224. * @param directionToUpdate is the direction vector to update with the result
  18225. * @param particle is the particle we are computed the direction for
  18226. */
  18227. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18228. /**
  18229. * Called by the particle System when the position is computed for the created particle.
  18230. * @param worldMatrix is the world matrix of the particle system
  18231. * @param positionToUpdate is the position vector to update with the result
  18232. * @param particle is the particle we are computed the position for
  18233. */
  18234. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18235. /**
  18236. * Clones the current emitter and returns a copy of it
  18237. * @returns the new emitter
  18238. */
  18239. clone(): PointParticleEmitter;
  18240. /**
  18241. * Called by the GPUParticleSystem to setup the update shader
  18242. * @param effect defines the update shader
  18243. */
  18244. applyToShader(effect: Effect): void;
  18245. /**
  18246. * Returns a string to use to update the GPU particles update shader
  18247. * @returns a string containng the defines string
  18248. */
  18249. getEffectDefines(): string;
  18250. /**
  18251. * Returns the string "PointParticleEmitter"
  18252. * @returns a string containing the class name
  18253. */
  18254. getClassName(): string;
  18255. /**
  18256. * Serializes the particle system to a JSON object.
  18257. * @returns the JSON object
  18258. */
  18259. serialize(): any;
  18260. /**
  18261. * Parse properties from a JSON object
  18262. * @param serializationObject defines the JSON object
  18263. */
  18264. parse(serializationObject: any): void;
  18265. }
  18266. }
  18267. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18268. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18269. import { Effect } from "babylonjs/Materials/effect";
  18270. import { Particle } from "babylonjs/Particles/particle";
  18271. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18272. /**
  18273. * Particle emitter emitting particles from the inside of a sphere.
  18274. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18275. */
  18276. export class SphereParticleEmitter implements IParticleEmitterType {
  18277. /**
  18278. * The radius of the emission sphere.
  18279. */
  18280. radius: number;
  18281. /**
  18282. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18283. */
  18284. radiusRange: number;
  18285. /**
  18286. * How much to randomize the particle direction [0-1].
  18287. */
  18288. directionRandomizer: number;
  18289. /**
  18290. * Creates a new instance SphereParticleEmitter
  18291. * @param radius the radius of the emission sphere (1 by default)
  18292. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18293. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18294. */
  18295. constructor(
  18296. /**
  18297. * The radius of the emission sphere.
  18298. */
  18299. radius?: number,
  18300. /**
  18301. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18302. */
  18303. radiusRange?: number,
  18304. /**
  18305. * How much to randomize the particle direction [0-1].
  18306. */
  18307. directionRandomizer?: number);
  18308. /**
  18309. * Called by the particle System when the direction is computed for the created particle.
  18310. * @param worldMatrix is the world matrix of the particle system
  18311. * @param directionToUpdate is the direction vector to update with the result
  18312. * @param particle is the particle we are computed the direction for
  18313. */
  18314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18315. /**
  18316. * Called by the particle System when the position is computed for the created particle.
  18317. * @param worldMatrix is the world matrix of the particle system
  18318. * @param positionToUpdate is the position vector to update with the result
  18319. * @param particle is the particle we are computed the position for
  18320. */
  18321. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18322. /**
  18323. * Clones the current emitter and returns a copy of it
  18324. * @returns the new emitter
  18325. */
  18326. clone(): SphereParticleEmitter;
  18327. /**
  18328. * Called by the GPUParticleSystem to setup the update shader
  18329. * @param effect defines the update shader
  18330. */
  18331. applyToShader(effect: Effect): void;
  18332. /**
  18333. * Returns a string to use to update the GPU particles update shader
  18334. * @returns a string containng the defines string
  18335. */
  18336. getEffectDefines(): string;
  18337. /**
  18338. * Returns the string "SphereParticleEmitter"
  18339. * @returns a string containing the class name
  18340. */
  18341. getClassName(): string;
  18342. /**
  18343. * Serializes the particle system to a JSON object.
  18344. * @returns the JSON object
  18345. */
  18346. serialize(): any;
  18347. /**
  18348. * Parse properties from a JSON object
  18349. * @param serializationObject defines the JSON object
  18350. */
  18351. parse(serializationObject: any): void;
  18352. }
  18353. /**
  18354. * Particle emitter emitting particles from the inside of a sphere.
  18355. * It emits the particles randomly between two vectors.
  18356. */
  18357. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18358. /**
  18359. * The min limit of the emission direction.
  18360. */
  18361. direction1: Vector3;
  18362. /**
  18363. * The max limit of the emission direction.
  18364. */
  18365. direction2: Vector3;
  18366. /**
  18367. * Creates a new instance SphereDirectedParticleEmitter
  18368. * @param radius the radius of the emission sphere (1 by default)
  18369. * @param direction1 the min limit of the emission direction (up vector by default)
  18370. * @param direction2 the max limit of the emission direction (up vector by default)
  18371. */
  18372. constructor(radius?: number,
  18373. /**
  18374. * The min limit of the emission direction.
  18375. */
  18376. direction1?: Vector3,
  18377. /**
  18378. * The max limit of the emission direction.
  18379. */
  18380. direction2?: Vector3);
  18381. /**
  18382. * Called by the particle System when the direction is computed for the created particle.
  18383. * @param worldMatrix is the world matrix of the particle system
  18384. * @param directionToUpdate is the direction vector to update with the result
  18385. * @param particle is the particle we are computed the direction for
  18386. */
  18387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18388. /**
  18389. * Clones the current emitter and returns a copy of it
  18390. * @returns the new emitter
  18391. */
  18392. clone(): SphereDirectedParticleEmitter;
  18393. /**
  18394. * Called by the GPUParticleSystem to setup the update shader
  18395. * @param effect defines the update shader
  18396. */
  18397. applyToShader(effect: Effect): void;
  18398. /**
  18399. * Returns a string to use to update the GPU particles update shader
  18400. * @returns a string containng the defines string
  18401. */
  18402. getEffectDefines(): string;
  18403. /**
  18404. * Returns the string "SphereDirectedParticleEmitter"
  18405. * @returns a string containing the class name
  18406. */
  18407. getClassName(): string;
  18408. /**
  18409. * Serializes the particle system to a JSON object.
  18410. * @returns the JSON object
  18411. */
  18412. serialize(): any;
  18413. /**
  18414. * Parse properties from a JSON object
  18415. * @param serializationObject defines the JSON object
  18416. */
  18417. parse(serializationObject: any): void;
  18418. }
  18419. }
  18420. declare module "babylonjs/Particles/EmitterTypes/index" {
  18421. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18422. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18423. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18424. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18425. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18426. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18427. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18428. }
  18429. declare module "babylonjs/Particles/IParticleSystem" {
  18430. import { Nullable } from "babylonjs/types";
  18431. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18432. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18435. import { Texture } from "babylonjs/Materials/Textures/texture";
  18436. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18437. import { Scene } from "babylonjs/scene";
  18438. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18439. import { Animation } from "babylonjs/Animations/animation";
  18440. /**
  18441. * Interface representing a particle system in Babylon.js.
  18442. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18443. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18444. */
  18445. export interface IParticleSystem {
  18446. /**
  18447. * List of animations used by the particle system.
  18448. */
  18449. animations: Animation[];
  18450. /**
  18451. * The id of the Particle system.
  18452. */
  18453. id: string;
  18454. /**
  18455. * The name of the Particle system.
  18456. */
  18457. name: string;
  18458. /**
  18459. * The emitter represents the Mesh or position we are attaching the particle system to.
  18460. */
  18461. emitter: Nullable<AbstractMesh | Vector3>;
  18462. /**
  18463. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18464. */
  18465. isBillboardBased: boolean;
  18466. /**
  18467. * The rendering group used by the Particle system to chose when to render.
  18468. */
  18469. renderingGroupId: number;
  18470. /**
  18471. * The layer mask we are rendering the particles through.
  18472. */
  18473. layerMask: number;
  18474. /**
  18475. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18476. */
  18477. updateSpeed: number;
  18478. /**
  18479. * The amount of time the particle system is running (depends of the overall update speed).
  18480. */
  18481. targetStopDuration: number;
  18482. /**
  18483. * The texture used to render each particle. (this can be a spritesheet)
  18484. */
  18485. particleTexture: Nullable<Texture>;
  18486. /**
  18487. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18488. */
  18489. blendMode: number;
  18490. /**
  18491. * Minimum life time of emitting particles.
  18492. */
  18493. minLifeTime: number;
  18494. /**
  18495. * Maximum life time of emitting particles.
  18496. */
  18497. maxLifeTime: number;
  18498. /**
  18499. * Minimum Size of emitting particles.
  18500. */
  18501. minSize: number;
  18502. /**
  18503. * Maximum Size of emitting particles.
  18504. */
  18505. maxSize: number;
  18506. /**
  18507. * Minimum scale of emitting particles on X axis.
  18508. */
  18509. minScaleX: number;
  18510. /**
  18511. * Maximum scale of emitting particles on X axis.
  18512. */
  18513. maxScaleX: number;
  18514. /**
  18515. * Minimum scale of emitting particles on Y axis.
  18516. */
  18517. minScaleY: number;
  18518. /**
  18519. * Maximum scale of emitting particles on Y axis.
  18520. */
  18521. maxScaleY: number;
  18522. /**
  18523. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18524. */
  18525. color1: Color4;
  18526. /**
  18527. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18528. */
  18529. color2: Color4;
  18530. /**
  18531. * Color the particle will have at the end of its lifetime.
  18532. */
  18533. colorDead: Color4;
  18534. /**
  18535. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18536. */
  18537. emitRate: number;
  18538. /**
  18539. * You can use gravity if you want to give an orientation to your particles.
  18540. */
  18541. gravity: Vector3;
  18542. /**
  18543. * Minimum power of emitting particles.
  18544. */
  18545. minEmitPower: number;
  18546. /**
  18547. * Maximum power of emitting particles.
  18548. */
  18549. maxEmitPower: number;
  18550. /**
  18551. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18552. */
  18553. minAngularSpeed: number;
  18554. /**
  18555. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18556. */
  18557. maxAngularSpeed: number;
  18558. /**
  18559. * Gets or sets the minimal initial rotation in radians.
  18560. */
  18561. minInitialRotation: number;
  18562. /**
  18563. * Gets or sets the maximal initial rotation in radians.
  18564. */
  18565. maxInitialRotation: number;
  18566. /**
  18567. * The particle emitter type defines the emitter used by the particle system.
  18568. * It can be for example box, sphere, or cone...
  18569. */
  18570. particleEmitterType: Nullable<IParticleEmitterType>;
  18571. /**
  18572. * Defines the delay in milliseconds before starting the system (0 by default)
  18573. */
  18574. startDelay: number;
  18575. /**
  18576. * 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
  18577. */
  18578. preWarmCycles: number;
  18579. /**
  18580. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18581. */
  18582. preWarmStepOffset: number;
  18583. /**
  18584. * 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)
  18585. */
  18586. spriteCellChangeSpeed: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18589. */
  18590. startSpriteCellID: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18593. */
  18594. endSpriteCellID: number;
  18595. /**
  18596. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18597. */
  18598. spriteCellWidth: number;
  18599. /**
  18600. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18601. */
  18602. spriteCellHeight: number;
  18603. /**
  18604. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18605. */
  18606. spriteRandomStartCell: boolean;
  18607. /**
  18608. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18609. */
  18610. isAnimationSheetEnabled: boolean;
  18611. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18612. translationPivot: Vector2;
  18613. /**
  18614. * Gets or sets a texture used to add random noise to particle positions
  18615. */
  18616. noiseTexture: Nullable<BaseTexture>;
  18617. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18618. noiseStrength: Vector3;
  18619. /**
  18620. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18621. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18622. */
  18623. billboardMode: number;
  18624. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18625. limitVelocityDamping: number;
  18626. /**
  18627. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18628. */
  18629. beginAnimationOnStart: boolean;
  18630. /**
  18631. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationFrom: number;
  18634. /**
  18635. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18636. */
  18637. beginAnimationTo: number;
  18638. /**
  18639. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18640. */
  18641. beginAnimationLoop: boolean;
  18642. /**
  18643. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18644. */
  18645. disposeOnStop: boolean;
  18646. /**
  18647. * Gets the maximum number of particles active at the same time.
  18648. * @returns The max number of active particles.
  18649. */
  18650. getCapacity(): number;
  18651. /**
  18652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18653. * @returns True if it has been started, otherwise false.
  18654. */
  18655. isStarted(): boolean;
  18656. /**
  18657. * Animates the particle system for this frame.
  18658. */
  18659. animate(): void;
  18660. /**
  18661. * Renders the particle system in its current state.
  18662. * @returns the current number of particles
  18663. */
  18664. render(): number;
  18665. /**
  18666. * Dispose the particle system and frees its associated resources.
  18667. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18668. */
  18669. dispose(disposeTexture?: boolean): void;
  18670. /**
  18671. * Clones the particle system.
  18672. * @param name The name of the cloned object
  18673. * @param newEmitter The new emitter to use
  18674. * @returns the cloned particle system
  18675. */
  18676. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18677. /**
  18678. * Serializes the particle system to a JSON object.
  18679. * @returns the JSON object
  18680. */
  18681. serialize(): any;
  18682. /**
  18683. * Rebuild the particle system
  18684. */
  18685. rebuild(): void;
  18686. /**
  18687. * Starts the particle system and begins to emit
  18688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18689. */
  18690. start(delay?: number): void;
  18691. /**
  18692. * Stops the particle system.
  18693. */
  18694. stop(): void;
  18695. /**
  18696. * Remove all active particles
  18697. */
  18698. reset(): void;
  18699. /**
  18700. * Is this system ready to be used/rendered
  18701. * @return true if the system is ready
  18702. */
  18703. isReady(): boolean;
  18704. /**
  18705. * Adds a new color gradient
  18706. * @param gradient defines the gradient to use (between 0 and 1)
  18707. * @param color1 defines the color to affect to the specified gradient
  18708. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18709. * @returns the current particle system
  18710. */
  18711. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18712. /**
  18713. * Remove a specific color gradient
  18714. * @param gradient defines the gradient to remove
  18715. * @returns the current particle system
  18716. */
  18717. removeColorGradient(gradient: number): IParticleSystem;
  18718. /**
  18719. * Adds a new size gradient
  18720. * @param gradient defines the gradient to use (between 0 and 1)
  18721. * @param factor defines the size factor to affect to the specified gradient
  18722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18723. * @returns the current particle system
  18724. */
  18725. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18726. /**
  18727. * Remove a specific size gradient
  18728. * @param gradient defines the gradient to remove
  18729. * @returns the current particle system
  18730. */
  18731. removeSizeGradient(gradient: number): IParticleSystem;
  18732. /**
  18733. * Gets the current list of color gradients.
  18734. * You must use addColorGradient and removeColorGradient to udpate this list
  18735. * @returns the list of color gradients
  18736. */
  18737. getColorGradients(): Nullable<Array<ColorGradient>>;
  18738. /**
  18739. * Gets the current list of size gradients.
  18740. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18741. * @returns the list of size gradients
  18742. */
  18743. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18744. /**
  18745. * Gets the current list of angular speed gradients.
  18746. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18747. * @returns the list of angular speed gradients
  18748. */
  18749. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18750. /**
  18751. * Adds a new angular speed gradient
  18752. * @param gradient defines the gradient to use (between 0 and 1)
  18753. * @param factor defines the angular speed to affect to the specified gradient
  18754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18755. * @returns the current particle system
  18756. */
  18757. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18758. /**
  18759. * Remove a specific angular speed gradient
  18760. * @param gradient defines the gradient to remove
  18761. * @returns the current particle system
  18762. */
  18763. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18764. /**
  18765. * Gets the current list of velocity gradients.
  18766. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18767. * @returns the list of velocity gradients
  18768. */
  18769. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18770. /**
  18771. * Adds a new velocity gradient
  18772. * @param gradient defines the gradient to use (between 0 and 1)
  18773. * @param factor defines the velocity to affect to the specified gradient
  18774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18775. * @returns the current particle system
  18776. */
  18777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18778. /**
  18779. * Remove a specific velocity gradient
  18780. * @param gradient defines the gradient to remove
  18781. * @returns the current particle system
  18782. */
  18783. removeVelocityGradient(gradient: number): IParticleSystem;
  18784. /**
  18785. * Gets the current list of limit velocity gradients.
  18786. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18787. * @returns the list of limit velocity gradients
  18788. */
  18789. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18790. /**
  18791. * Adds a new limit velocity gradient
  18792. * @param gradient defines the gradient to use (between 0 and 1)
  18793. * @param factor defines the limit velocity to affect to the specified gradient
  18794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18795. * @returns the current particle system
  18796. */
  18797. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18798. /**
  18799. * Remove a specific limit velocity gradient
  18800. * @param gradient defines the gradient to remove
  18801. * @returns the current particle system
  18802. */
  18803. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18804. /**
  18805. * Adds a new drag gradient
  18806. * @param gradient defines the gradient to use (between 0 and 1)
  18807. * @param factor defines the drag to affect to the specified gradient
  18808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18809. * @returns the current particle system
  18810. */
  18811. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18812. /**
  18813. * Remove a specific drag gradient
  18814. * @param gradient defines the gradient to remove
  18815. * @returns the current particle system
  18816. */
  18817. removeDragGradient(gradient: number): IParticleSystem;
  18818. /**
  18819. * Gets the current list of drag gradients.
  18820. * You must use addDragGradient and removeDragGradient to udpate this list
  18821. * @returns the list of drag gradients
  18822. */
  18823. getDragGradients(): Nullable<Array<FactorGradient>>;
  18824. /**
  18825. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18826. * @param gradient defines the gradient to use (between 0 and 1)
  18827. * @param factor defines the emit rate to affect to the specified gradient
  18828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18829. * @returns the current particle system
  18830. */
  18831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18832. /**
  18833. * Remove a specific emit rate gradient
  18834. * @param gradient defines the gradient to remove
  18835. * @returns the current particle system
  18836. */
  18837. removeEmitRateGradient(gradient: number): IParticleSystem;
  18838. /**
  18839. * Gets the current list of emit rate gradients.
  18840. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18841. * @returns the list of emit rate gradients
  18842. */
  18843. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18844. /**
  18845. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18846. * @param gradient defines the gradient to use (between 0 and 1)
  18847. * @param factor defines the start size to affect to the specified gradient
  18848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18849. * @returns the current particle system
  18850. */
  18851. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18852. /**
  18853. * Remove a specific start size gradient
  18854. * @param gradient defines the gradient to remove
  18855. * @returns the current particle system
  18856. */
  18857. removeStartSizeGradient(gradient: number): IParticleSystem;
  18858. /**
  18859. * Gets the current list of start size gradients.
  18860. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18861. * @returns the list of start size gradients
  18862. */
  18863. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18864. /**
  18865. * Adds a new life time gradient
  18866. * @param gradient defines the gradient to use (between 0 and 1)
  18867. * @param factor defines the life time factor to affect to the specified gradient
  18868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18869. * @returns the current particle system
  18870. */
  18871. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18872. /**
  18873. * Remove a specific life time gradient
  18874. * @param gradient defines the gradient to remove
  18875. * @returns the current particle system
  18876. */
  18877. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18878. /**
  18879. * Gets the current list of life time gradients.
  18880. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18881. * @returns the list of life time gradients
  18882. */
  18883. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18884. /**
  18885. * Gets the current list of color gradients.
  18886. * You must use addColorGradient and removeColorGradient to udpate this list
  18887. * @returns the list of color gradients
  18888. */
  18889. getColorGradients(): Nullable<Array<ColorGradient>>;
  18890. /**
  18891. * Adds a new ramp gradient used to remap particle colors
  18892. * @param gradient defines the gradient to use (between 0 and 1)
  18893. * @param color defines the color to affect to the specified gradient
  18894. * @returns the current particle system
  18895. */
  18896. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18897. /**
  18898. * Gets the current list of ramp gradients.
  18899. * You must use addRampGradient and removeRampGradient to udpate this list
  18900. * @returns the list of ramp gradients
  18901. */
  18902. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18903. /** Gets or sets a boolean indicating that ramp gradients must be used
  18904. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18905. */
  18906. useRampGradients: boolean;
  18907. /**
  18908. * Adds a new color remap gradient
  18909. * @param gradient defines the gradient to use (between 0 and 1)
  18910. * @param min defines the color remap minimal range
  18911. * @param max defines the color remap maximal range
  18912. * @returns the current particle system
  18913. */
  18914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18915. /**
  18916. * Gets the current list of color remap gradients.
  18917. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18918. * @returns the list of color remap gradients
  18919. */
  18920. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18921. /**
  18922. * Adds a new alpha remap gradient
  18923. * @param gradient defines the gradient to use (between 0 and 1)
  18924. * @param min defines the alpha remap minimal range
  18925. * @param max defines the alpha remap maximal range
  18926. * @returns the current particle system
  18927. */
  18928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of alpha remap gradients.
  18931. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18932. * @returns the list of alpha remap gradients
  18933. */
  18934. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18937. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18938. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18939. * @returns the emitter
  18940. */
  18941. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18942. /**
  18943. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18944. * @param radius The radius of the hemisphere to emit from
  18945. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18946. * @returns the emitter
  18947. */
  18948. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18949. /**
  18950. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18951. * @param radius The radius of the sphere to emit from
  18952. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18953. * @returns the emitter
  18954. */
  18955. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18956. /**
  18957. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18958. * @param radius The radius of the sphere to emit from
  18959. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18960. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18961. * @returns the emitter
  18962. */
  18963. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18964. /**
  18965. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18966. * @param radius The radius of the emission cylinder
  18967. * @param height The height of the emission cylinder
  18968. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18969. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18970. * @returns the emitter
  18971. */
  18972. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18973. /**
  18974. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18975. * @param radius The radius of the cylinder to emit from
  18976. * @param height The height of the emission cylinder
  18977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18978. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18979. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18980. * @returns the emitter
  18981. */
  18982. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18983. /**
  18984. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18985. * @param radius The radius of the cone to emit from
  18986. * @param angle The base angle of the cone
  18987. * @returns the emitter
  18988. */
  18989. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18990. /**
  18991. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18992. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18993. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18994. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18995. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18996. * @returns the emitter
  18997. */
  18998. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18999. /**
  19000. * Get hosting scene
  19001. * @returns the scene
  19002. */
  19003. getScene(): Scene;
  19004. }
  19005. }
  19006. declare module "babylonjs/Meshes/instancedMesh" {
  19007. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19008. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19009. import { Camera } from "babylonjs/Cameras/camera";
  19010. import { Node } from "babylonjs/node";
  19011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19012. import { Mesh } from "babylonjs/Meshes/mesh";
  19013. import { Material } from "babylonjs/Materials/material";
  19014. import { Skeleton } from "babylonjs/Bones/skeleton";
  19015. import { Light } from "babylonjs/Lights/light";
  19016. /**
  19017. * Creates an instance based on a source mesh.
  19018. */
  19019. export class InstancedMesh extends AbstractMesh {
  19020. private _sourceMesh;
  19021. private _currentLOD;
  19022. /** @hidden */
  19023. _indexInSourceMeshInstanceArray: number;
  19024. constructor(name: string, source: Mesh);
  19025. /**
  19026. * Returns the string "InstancedMesh".
  19027. */
  19028. getClassName(): string;
  19029. /** Gets the list of lights affecting that mesh */
  19030. readonly lightSources: Light[];
  19031. _resyncLightSources(): void;
  19032. _resyncLighSource(light: Light): void;
  19033. _removeLightSource(light: Light): void;
  19034. /**
  19035. * If the source mesh receives shadows
  19036. */
  19037. readonly receiveShadows: boolean;
  19038. /**
  19039. * The material of the source mesh
  19040. */
  19041. readonly material: Nullable<Material>;
  19042. /**
  19043. * Visibility of the source mesh
  19044. */
  19045. readonly visibility: number;
  19046. /**
  19047. * Skeleton of the source mesh
  19048. */
  19049. readonly skeleton: Nullable<Skeleton>;
  19050. /**
  19051. * Rendering ground id of the source mesh
  19052. */
  19053. renderingGroupId: number;
  19054. /**
  19055. * Returns the total number of vertices (integer).
  19056. */
  19057. getTotalVertices(): number;
  19058. /**
  19059. * Returns a positive integer : the total number of indices in this mesh geometry.
  19060. * @returns the numner of indices or zero if the mesh has no geometry.
  19061. */
  19062. getTotalIndices(): number;
  19063. /**
  19064. * The source mesh of the instance
  19065. */
  19066. readonly sourceMesh: Mesh;
  19067. /**
  19068. * Is this node ready to be used/rendered
  19069. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19070. * @return {boolean} is it ready
  19071. */
  19072. isReady(completeCheck?: boolean): boolean;
  19073. /**
  19074. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19075. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19076. * @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.
  19077. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19078. */
  19079. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19080. /**
  19081. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19082. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19083. * The `data` are either a numeric array either a Float32Array.
  19084. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19085. * 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).
  19086. * Note that a new underlying VertexBuffer object is created each call.
  19087. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19088. *
  19089. * Possible `kind` values :
  19090. * - VertexBuffer.PositionKind
  19091. * - VertexBuffer.UVKind
  19092. * - VertexBuffer.UV2Kind
  19093. * - VertexBuffer.UV3Kind
  19094. * - VertexBuffer.UV4Kind
  19095. * - VertexBuffer.UV5Kind
  19096. * - VertexBuffer.UV6Kind
  19097. * - VertexBuffer.ColorKind
  19098. * - VertexBuffer.MatricesIndicesKind
  19099. * - VertexBuffer.MatricesIndicesExtraKind
  19100. * - VertexBuffer.MatricesWeightsKind
  19101. * - VertexBuffer.MatricesWeightsExtraKind
  19102. *
  19103. * Returns the Mesh.
  19104. */
  19105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19106. /**
  19107. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19108. * If the mesh has no geometry, it is simply returned as it is.
  19109. * The `data` are either a numeric array either a Float32Array.
  19110. * No new underlying VertexBuffer object is created.
  19111. * 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.
  19112. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19113. *
  19114. * Possible `kind` values :
  19115. * - VertexBuffer.PositionKind
  19116. * - VertexBuffer.UVKind
  19117. * - VertexBuffer.UV2Kind
  19118. * - VertexBuffer.UV3Kind
  19119. * - VertexBuffer.UV4Kind
  19120. * - VertexBuffer.UV5Kind
  19121. * - VertexBuffer.UV6Kind
  19122. * - VertexBuffer.ColorKind
  19123. * - VertexBuffer.MatricesIndicesKind
  19124. * - VertexBuffer.MatricesIndicesExtraKind
  19125. * - VertexBuffer.MatricesWeightsKind
  19126. * - VertexBuffer.MatricesWeightsExtraKind
  19127. *
  19128. * Returns the Mesh.
  19129. */
  19130. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19131. /**
  19132. * Sets the mesh indices.
  19133. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19134. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19135. * This method creates a new index buffer each call.
  19136. * Returns the Mesh.
  19137. */
  19138. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19139. /**
  19140. * Boolean : True if the mesh owns the requested kind of data.
  19141. */
  19142. isVerticesDataPresent(kind: string): boolean;
  19143. /**
  19144. * Returns an array of indices (IndicesArray).
  19145. */
  19146. getIndices(): Nullable<IndicesArray>;
  19147. readonly _positions: Nullable<Vector3[]>;
  19148. /**
  19149. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19150. * This means the mesh underlying bounding box and sphere are recomputed.
  19151. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19152. * @returns the current mesh
  19153. */
  19154. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19155. /** @hidden */
  19156. _preActivate(): InstancedMesh;
  19157. /** @hidden */
  19158. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19159. /** @hidden */
  19160. _postActivate(): void;
  19161. getWorldMatrix(): Matrix;
  19162. readonly isAnInstance: boolean;
  19163. /**
  19164. * Returns the current associated LOD AbstractMesh.
  19165. */
  19166. getLOD(camera: Camera): AbstractMesh;
  19167. /** @hidden */
  19168. _syncSubMeshes(): InstancedMesh;
  19169. /** @hidden */
  19170. _generatePointsArray(): boolean;
  19171. /**
  19172. * Creates a new InstancedMesh from the current mesh.
  19173. * - name (string) : the cloned mesh name
  19174. * - newParent (optional Node) : the optional Node to parent the clone to.
  19175. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19176. *
  19177. * Returns the clone.
  19178. */
  19179. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19180. /**
  19181. * Disposes the InstancedMesh.
  19182. * Returns nothing.
  19183. */
  19184. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19185. }
  19186. }
  19187. declare module "babylonjs/Materials/shaderMaterial" {
  19188. import { Scene } from "babylonjs/scene";
  19189. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19191. import { Mesh } from "babylonjs/Meshes/mesh";
  19192. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19194. import { Texture } from "babylonjs/Materials/Textures/texture";
  19195. import { Material } from "babylonjs/Materials/material";
  19196. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19197. /**
  19198. * Defines the options associated with the creation of a shader material.
  19199. */
  19200. export interface IShaderMaterialOptions {
  19201. /**
  19202. * Does the material work in alpha blend mode
  19203. */
  19204. needAlphaBlending: boolean;
  19205. /**
  19206. * Does the material work in alpha test mode
  19207. */
  19208. needAlphaTesting: boolean;
  19209. /**
  19210. * The list of attribute names used in the shader
  19211. */
  19212. attributes: string[];
  19213. /**
  19214. * The list of unifrom names used in the shader
  19215. */
  19216. uniforms: string[];
  19217. /**
  19218. * The list of UBO names used in the shader
  19219. */
  19220. uniformBuffers: string[];
  19221. /**
  19222. * The list of sampler names used in the shader
  19223. */
  19224. samplers: string[];
  19225. /**
  19226. * The list of defines used in the shader
  19227. */
  19228. defines: string[];
  19229. }
  19230. /**
  19231. * 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.
  19232. *
  19233. * This returned material effects how the mesh will look based on the code in the shaders.
  19234. *
  19235. * @see http://doc.babylonjs.com/how_to/shader_material
  19236. */
  19237. export class ShaderMaterial extends Material {
  19238. private _shaderPath;
  19239. private _options;
  19240. private _textures;
  19241. private _textureArrays;
  19242. private _floats;
  19243. private _ints;
  19244. private _floatsArrays;
  19245. private _colors3;
  19246. private _colors3Arrays;
  19247. private _colors4;
  19248. private _colors4Arrays;
  19249. private _vectors2;
  19250. private _vectors3;
  19251. private _vectors4;
  19252. private _matrices;
  19253. private _matrices3x3;
  19254. private _matrices2x2;
  19255. private _vectors2Arrays;
  19256. private _vectors3Arrays;
  19257. private _vectors4Arrays;
  19258. private _cachedWorldViewMatrix;
  19259. private _cachedWorldViewProjectionMatrix;
  19260. private _renderId;
  19261. /**
  19262. * Instantiate a new shader material.
  19263. * 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.
  19264. * This returned material effects how the mesh will look based on the code in the shaders.
  19265. * @see http://doc.babylonjs.com/how_to/shader_material
  19266. * @param name Define the name of the material in the scene
  19267. * @param scene Define the scene the material belongs to
  19268. * @param shaderPath Defines the route to the shader code in one of three ways:
  19269. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19270. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19271. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19272. * @param options Define the options used to create the shader
  19273. */
  19274. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19275. /**
  19276. * Gets the options used to compile the shader.
  19277. * They can be modified to trigger a new compilation
  19278. */
  19279. readonly options: IShaderMaterialOptions;
  19280. /**
  19281. * Gets the current class name of the material e.g. "ShaderMaterial"
  19282. * Mainly use in serialization.
  19283. * @returns the class name
  19284. */
  19285. getClassName(): string;
  19286. /**
  19287. * Specifies if the material will require alpha blending
  19288. * @returns a boolean specifying if alpha blending is needed
  19289. */
  19290. needAlphaBlending(): boolean;
  19291. /**
  19292. * Specifies if this material should be rendered in alpha test mode
  19293. * @returns a boolean specifying if an alpha test is needed.
  19294. */
  19295. needAlphaTesting(): boolean;
  19296. private _checkUniform;
  19297. /**
  19298. * Set a texture in the shader.
  19299. * @param name Define the name of the uniform samplers as defined in the shader
  19300. * @param texture Define the texture to bind to this sampler
  19301. * @return the material itself allowing "fluent" like uniform updates
  19302. */
  19303. setTexture(name: string, texture: Texture): ShaderMaterial;
  19304. /**
  19305. * Set a texture array in the shader.
  19306. * @param name Define the name of the uniform sampler array as defined in the shader
  19307. * @param textures Define the list of textures to bind to this sampler
  19308. * @return the material itself allowing "fluent" like uniform updates
  19309. */
  19310. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19311. /**
  19312. * Set a float in the shader.
  19313. * @param name Define the name of the uniform as defined in the shader
  19314. * @param value Define the value to give to the uniform
  19315. * @return the material itself allowing "fluent" like uniform updates
  19316. */
  19317. setFloat(name: string, value: number): ShaderMaterial;
  19318. /**
  19319. * Set a int in the shader.
  19320. * @param name Define the name of the uniform as defined in the shader
  19321. * @param value Define the value to give to the uniform
  19322. * @return the material itself allowing "fluent" like uniform updates
  19323. */
  19324. setInt(name: string, value: number): ShaderMaterial;
  19325. /**
  19326. * Set an array of floats in the shader.
  19327. * @param name Define the name of the uniform as defined in the shader
  19328. * @param value Define the value to give to the uniform
  19329. * @return the material itself allowing "fluent" like uniform updates
  19330. */
  19331. setFloats(name: string, value: number[]): ShaderMaterial;
  19332. /**
  19333. * Set a vec3 in the shader from a Color3.
  19334. * @param name Define the name of the uniform as defined in the shader
  19335. * @param value Define the value to give to the uniform
  19336. * @return the material itself allowing "fluent" like uniform updates
  19337. */
  19338. setColor3(name: string, value: Color3): ShaderMaterial;
  19339. /**
  19340. * Set a vec3 array in the shader from a Color3 array.
  19341. * @param name Define the name of the uniform as defined in the shader
  19342. * @param value Define the value to give to the uniform
  19343. * @return the material itself allowing "fluent" like uniform updates
  19344. */
  19345. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19346. /**
  19347. * Set a vec4 in the shader from a Color4.
  19348. * @param name Define the name of the uniform as defined in the shader
  19349. * @param value Define the value to give to the uniform
  19350. * @return the material itself allowing "fluent" like uniform updates
  19351. */
  19352. setColor4(name: string, value: Color4): ShaderMaterial;
  19353. /**
  19354. * Set a vec4 array in the shader from a Color4 array.
  19355. * @param name Define the name of the uniform as defined in the shader
  19356. * @param value Define the value to give to the uniform
  19357. * @return the material itself allowing "fluent" like uniform updates
  19358. */
  19359. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19360. /**
  19361. * Set a vec2 in the shader from a Vector2.
  19362. * @param name Define the name of the uniform as defined in the shader
  19363. * @param value Define the value to give to the uniform
  19364. * @return the material itself allowing "fluent" like uniform updates
  19365. */
  19366. setVector2(name: string, value: Vector2): ShaderMaterial;
  19367. /**
  19368. * Set a vec3 in the shader from a Vector3.
  19369. * @param name Define the name of the uniform as defined in the shader
  19370. * @param value Define the value to give to the uniform
  19371. * @return the material itself allowing "fluent" like uniform updates
  19372. */
  19373. setVector3(name: string, value: Vector3): ShaderMaterial;
  19374. /**
  19375. * Set a vec4 in the shader from a Vector4.
  19376. * @param name Define the name of the uniform as defined in the shader
  19377. * @param value Define the value to give to the uniform
  19378. * @return the material itself allowing "fluent" like uniform updates
  19379. */
  19380. setVector4(name: string, value: Vector4): ShaderMaterial;
  19381. /**
  19382. * Set a mat4 in the shader from a Matrix.
  19383. * @param name Define the name of the uniform as defined in the shader
  19384. * @param value Define the value to give to the uniform
  19385. * @return the material itself allowing "fluent" like uniform updates
  19386. */
  19387. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19388. /**
  19389. * Set a mat3 in the shader from a Float32Array.
  19390. * @param name Define the name of the uniform as defined in the shader
  19391. * @param value Define the value to give to the uniform
  19392. * @return the material itself allowing "fluent" like uniform updates
  19393. */
  19394. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19395. /**
  19396. * Set a mat2 in the shader from a Float32Array.
  19397. * @param name Define the name of the uniform as defined in the shader
  19398. * @param value Define the value to give to the uniform
  19399. * @return the material itself allowing "fluent" like uniform updates
  19400. */
  19401. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19402. /**
  19403. * Set a vec2 array in the shader from a number array.
  19404. * @param name Define the name of the uniform as defined in the shader
  19405. * @param value Define the value to give to the uniform
  19406. * @return the material itself allowing "fluent" like uniform updates
  19407. */
  19408. setArray2(name: string, value: number[]): ShaderMaterial;
  19409. /**
  19410. * Set a vec3 array in the shader from a number array.
  19411. * @param name Define the name of the uniform as defined in the shader
  19412. * @param value Define the value to give to the uniform
  19413. * @return the material itself allowing "fluent" like uniform updates
  19414. */
  19415. setArray3(name: string, value: number[]): ShaderMaterial;
  19416. /**
  19417. * Set a vec4 array in the shader from a number array.
  19418. * @param name Define the name of the uniform as defined in the shader
  19419. * @param value Define the value to give to the uniform
  19420. * @return the material itself allowing "fluent" like uniform updates
  19421. */
  19422. setArray4(name: string, value: number[]): ShaderMaterial;
  19423. private _checkCache;
  19424. /**
  19425. * Specifies that the submesh is ready to be used
  19426. * @param mesh defines the mesh to check
  19427. * @param subMesh defines which submesh to check
  19428. * @param useInstances specifies that instances should be used
  19429. * @returns a boolean indicating that the submesh is ready or not
  19430. */
  19431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19432. /**
  19433. * Checks if the material is ready to render the requested mesh
  19434. * @param mesh Define the mesh to render
  19435. * @param useInstances Define whether or not the material is used with instances
  19436. * @returns true if ready, otherwise false
  19437. */
  19438. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19439. /**
  19440. * Binds the world matrix to the material
  19441. * @param world defines the world transformation matrix
  19442. */
  19443. bindOnlyWorldMatrix(world: Matrix): void;
  19444. /**
  19445. * Binds the material to the mesh
  19446. * @param world defines the world transformation matrix
  19447. * @param mesh defines the mesh to bind the material to
  19448. */
  19449. bind(world: Matrix, mesh?: Mesh): void;
  19450. /**
  19451. * Gets the active textures from the material
  19452. * @returns an array of textures
  19453. */
  19454. getActiveTextures(): BaseTexture[];
  19455. /**
  19456. * Specifies if the material uses a texture
  19457. * @param texture defines the texture to check against the material
  19458. * @returns a boolean specifying if the material uses the texture
  19459. */
  19460. hasTexture(texture: BaseTexture): boolean;
  19461. /**
  19462. * Makes a duplicate of the material, and gives it a new name
  19463. * @param name defines the new name for the duplicated material
  19464. * @returns the cloned material
  19465. */
  19466. clone(name: string): ShaderMaterial;
  19467. /**
  19468. * Disposes the material
  19469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19472. */
  19473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19474. /**
  19475. * Serializes this material in a JSON representation
  19476. * @returns the serialized material object
  19477. */
  19478. serialize(): any;
  19479. /**
  19480. * Creates a shader material from parsed shader material data
  19481. * @param source defines the JSON represnetation of the material
  19482. * @param scene defines the hosting scene
  19483. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19484. * @returns a new material
  19485. */
  19486. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19487. }
  19488. }
  19489. declare module "babylonjs/Shaders/color.fragment" {
  19490. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19491. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19492. /** @hidden */
  19493. export var colorPixelShader: {
  19494. name: string;
  19495. shader: string;
  19496. };
  19497. }
  19498. declare module "babylonjs/Shaders/color.vertex" {
  19499. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19500. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19501. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19502. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19503. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19505. /** @hidden */
  19506. export var colorVertexShader: {
  19507. name: string;
  19508. shader: string;
  19509. };
  19510. }
  19511. declare module "babylonjs/Meshes/linesMesh" {
  19512. import { Nullable } from "babylonjs/types";
  19513. import { Scene } from "babylonjs/scene";
  19514. import { Color3 } from "babylonjs/Maths/math.color";
  19515. import { Node } from "babylonjs/node";
  19516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19517. import { Mesh } from "babylonjs/Meshes/mesh";
  19518. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19519. import { Effect } from "babylonjs/Materials/effect";
  19520. import { Material } from "babylonjs/Materials/material";
  19521. import "babylonjs/Shaders/color.fragment";
  19522. import "babylonjs/Shaders/color.vertex";
  19523. /**
  19524. * Line mesh
  19525. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19526. */
  19527. export class LinesMesh extends Mesh {
  19528. /**
  19529. * If vertex color should be applied to the mesh
  19530. */
  19531. readonly useVertexColor?: boolean | undefined;
  19532. /**
  19533. * If vertex alpha should be applied to the mesh
  19534. */
  19535. readonly useVertexAlpha?: boolean | undefined;
  19536. /**
  19537. * Color of the line (Default: White)
  19538. */
  19539. color: Color3;
  19540. /**
  19541. * Alpha of the line (Default: 1)
  19542. */
  19543. alpha: number;
  19544. /**
  19545. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19546. * This margin is expressed in world space coordinates, so its value may vary.
  19547. * Default value is 0.1
  19548. */
  19549. intersectionThreshold: number;
  19550. private _colorShader;
  19551. private color4;
  19552. /**
  19553. * Creates a new LinesMesh
  19554. * @param name defines the name
  19555. * @param scene defines the hosting scene
  19556. * @param parent defines the parent mesh if any
  19557. * @param source defines the optional source LinesMesh used to clone data from
  19558. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19559. * When false, achieved by calling a clone(), also passing False.
  19560. * This will make creation of children, recursive.
  19561. * @param useVertexColor defines if this LinesMesh supports vertex color
  19562. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19563. */
  19564. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19565. /**
  19566. * If vertex color should be applied to the mesh
  19567. */
  19568. useVertexColor?: boolean | undefined,
  19569. /**
  19570. * If vertex alpha should be applied to the mesh
  19571. */
  19572. useVertexAlpha?: boolean | undefined);
  19573. private _addClipPlaneDefine;
  19574. private _removeClipPlaneDefine;
  19575. isReady(): boolean;
  19576. /**
  19577. * Returns the string "LineMesh"
  19578. */
  19579. getClassName(): string;
  19580. /**
  19581. * @hidden
  19582. */
  19583. /**
  19584. * @hidden
  19585. */
  19586. material: Material;
  19587. /**
  19588. * @hidden
  19589. */
  19590. readonly checkCollisions: boolean;
  19591. /** @hidden */
  19592. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19593. /** @hidden */
  19594. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19595. /**
  19596. * Disposes of the line mesh
  19597. * @param doNotRecurse If children should be disposed
  19598. */
  19599. dispose(doNotRecurse?: boolean): void;
  19600. /**
  19601. * Returns a new LineMesh object cloned from the current one.
  19602. */
  19603. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19604. /**
  19605. * Creates a new InstancedLinesMesh object from the mesh model.
  19606. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19607. * @param name defines the name of the new instance
  19608. * @returns a new InstancedLinesMesh
  19609. */
  19610. createInstance(name: string): InstancedLinesMesh;
  19611. }
  19612. /**
  19613. * Creates an instance based on a source LinesMesh
  19614. */
  19615. export class InstancedLinesMesh extends InstancedMesh {
  19616. /**
  19617. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19618. * This margin is expressed in world space coordinates, so its value may vary.
  19619. * Initilized with the intersectionThreshold value of the source LinesMesh
  19620. */
  19621. intersectionThreshold: number;
  19622. constructor(name: string, source: LinesMesh);
  19623. /**
  19624. * Returns the string "InstancedLinesMesh".
  19625. */
  19626. getClassName(): string;
  19627. }
  19628. }
  19629. declare module "babylonjs/Shaders/line.fragment" {
  19630. /** @hidden */
  19631. export var linePixelShader: {
  19632. name: string;
  19633. shader: string;
  19634. };
  19635. }
  19636. declare module "babylonjs/Shaders/line.vertex" {
  19637. /** @hidden */
  19638. export var lineVertexShader: {
  19639. name: string;
  19640. shader: string;
  19641. };
  19642. }
  19643. declare module "babylonjs/Rendering/edgesRenderer" {
  19644. import { Nullable } from "babylonjs/types";
  19645. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19647. import { Vector3 } from "babylonjs/Maths/math.vector";
  19648. import { IDisposable } from "babylonjs/scene";
  19649. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19650. import "babylonjs/Shaders/line.fragment";
  19651. import "babylonjs/Shaders/line.vertex";
  19652. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19653. module "babylonjs/Meshes/abstractMesh" {
  19654. interface AbstractMesh {
  19655. /**
  19656. * Gets the edgesRenderer associated with the mesh
  19657. */
  19658. edgesRenderer: Nullable<EdgesRenderer>;
  19659. }
  19660. }
  19661. module "babylonjs/Meshes/linesMesh" {
  19662. interface LinesMesh {
  19663. /**
  19664. * Enables the edge rendering mode on the mesh.
  19665. * This mode makes the mesh edges visible
  19666. * @param epsilon defines the maximal distance between two angles to detect a face
  19667. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19668. * @returns the currentAbstractMesh
  19669. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19670. */
  19671. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19672. }
  19673. }
  19674. module "babylonjs/Meshes/linesMesh" {
  19675. interface InstancedLinesMesh {
  19676. /**
  19677. * Enables the edge rendering mode on the mesh.
  19678. * This mode makes the mesh edges visible
  19679. * @param epsilon defines the maximal distance between two angles to detect a face
  19680. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19681. * @returns the current InstancedLinesMesh
  19682. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19683. */
  19684. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19685. }
  19686. }
  19687. /**
  19688. * Defines the minimum contract an Edges renderer should follow.
  19689. */
  19690. export interface IEdgesRenderer extends IDisposable {
  19691. /**
  19692. * Gets or sets a boolean indicating if the edgesRenderer is active
  19693. */
  19694. isEnabled: boolean;
  19695. /**
  19696. * Renders the edges of the attached mesh,
  19697. */
  19698. render(): void;
  19699. /**
  19700. * Checks wether or not the edges renderer is ready to render.
  19701. * @return true if ready, otherwise false.
  19702. */
  19703. isReady(): boolean;
  19704. }
  19705. /**
  19706. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19707. */
  19708. export class EdgesRenderer implements IEdgesRenderer {
  19709. /**
  19710. * Define the size of the edges with an orthographic camera
  19711. */
  19712. edgesWidthScalerForOrthographic: number;
  19713. /**
  19714. * Define the size of the edges with a perspective camera
  19715. */
  19716. edgesWidthScalerForPerspective: number;
  19717. protected _source: AbstractMesh;
  19718. protected _linesPositions: number[];
  19719. protected _linesNormals: number[];
  19720. protected _linesIndices: number[];
  19721. protected _epsilon: number;
  19722. protected _indicesCount: number;
  19723. protected _lineShader: ShaderMaterial;
  19724. protected _ib: DataBuffer;
  19725. protected _buffers: {
  19726. [key: string]: Nullable<VertexBuffer>;
  19727. };
  19728. protected _checkVerticesInsteadOfIndices: boolean;
  19729. private _meshRebuildObserver;
  19730. private _meshDisposeObserver;
  19731. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19732. isEnabled: boolean;
  19733. /**
  19734. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19735. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19736. * @param source Mesh used to create edges
  19737. * @param epsilon sum of angles in adjacency to check for edge
  19738. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19739. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19740. */
  19741. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19742. protected _prepareRessources(): void;
  19743. /** @hidden */
  19744. _rebuild(): void;
  19745. /**
  19746. * Releases the required resources for the edges renderer
  19747. */
  19748. dispose(): void;
  19749. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19750. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19751. /**
  19752. * Checks if the pair of p0 and p1 is en edge
  19753. * @param faceIndex
  19754. * @param edge
  19755. * @param faceNormals
  19756. * @param p0
  19757. * @param p1
  19758. * @private
  19759. */
  19760. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19761. /**
  19762. * push line into the position, normal and index buffer
  19763. * @protected
  19764. */
  19765. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19766. /**
  19767. * Generates lines edges from adjacencjes
  19768. * @private
  19769. */
  19770. _generateEdgesLines(): void;
  19771. /**
  19772. * Checks wether or not the edges renderer is ready to render.
  19773. * @return true if ready, otherwise false.
  19774. */
  19775. isReady(): boolean;
  19776. /**
  19777. * Renders the edges of the attached mesh,
  19778. */
  19779. render(): void;
  19780. }
  19781. /**
  19782. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19783. */
  19784. export class LineEdgesRenderer extends EdgesRenderer {
  19785. /**
  19786. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19787. * @param source LineMesh used to generate edges
  19788. * @param epsilon not important (specified angle for edge detection)
  19789. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19790. */
  19791. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19792. /**
  19793. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19794. */
  19795. _generateEdgesLines(): void;
  19796. }
  19797. }
  19798. declare module "babylonjs/Rendering/renderingGroup" {
  19799. import { SmartArray } from "babylonjs/Misc/smartArray";
  19800. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19802. import { Nullable } from "babylonjs/types";
  19803. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19804. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19805. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19806. import { Material } from "babylonjs/Materials/material";
  19807. import { Scene } from "babylonjs/scene";
  19808. /**
  19809. * This represents the object necessary to create a rendering group.
  19810. * This is exclusively used and created by the rendering manager.
  19811. * To modify the behavior, you use the available helpers in your scene or meshes.
  19812. * @hidden
  19813. */
  19814. export class RenderingGroup {
  19815. index: number;
  19816. private static _zeroVector;
  19817. private _scene;
  19818. private _opaqueSubMeshes;
  19819. private _transparentSubMeshes;
  19820. private _alphaTestSubMeshes;
  19821. private _depthOnlySubMeshes;
  19822. private _particleSystems;
  19823. private _spriteManagers;
  19824. private _opaqueSortCompareFn;
  19825. private _alphaTestSortCompareFn;
  19826. private _transparentSortCompareFn;
  19827. private _renderOpaque;
  19828. private _renderAlphaTest;
  19829. private _renderTransparent;
  19830. /** @hidden */
  19831. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19832. onBeforeTransparentRendering: () => void;
  19833. /**
  19834. * Set the opaque sort comparison function.
  19835. * If null the sub meshes will be render in the order they were created
  19836. */
  19837. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19838. /**
  19839. * Set the alpha test sort comparison function.
  19840. * If null the sub meshes will be render in the order they were created
  19841. */
  19842. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19843. /**
  19844. * Set the transparent sort comparison function.
  19845. * If null the sub meshes will be render in the order they were created
  19846. */
  19847. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19848. /**
  19849. * Creates a new rendering group.
  19850. * @param index The rendering group index
  19851. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19852. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19853. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19854. */
  19855. 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>);
  19856. /**
  19857. * Render all the sub meshes contained in the group.
  19858. * @param customRenderFunction Used to override the default render behaviour of the group.
  19859. * @returns true if rendered some submeshes.
  19860. */
  19861. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19862. /**
  19863. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19864. * @param subMeshes The submeshes to render
  19865. */
  19866. private renderOpaqueSorted;
  19867. /**
  19868. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19869. * @param subMeshes The submeshes to render
  19870. */
  19871. private renderAlphaTestSorted;
  19872. /**
  19873. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19874. * @param subMeshes The submeshes to render
  19875. */
  19876. private renderTransparentSorted;
  19877. /**
  19878. * Renders the submeshes in a specified order.
  19879. * @param subMeshes The submeshes to sort before render
  19880. * @param sortCompareFn The comparison function use to sort
  19881. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19882. * @param transparent Specifies to activate blending if true
  19883. */
  19884. private static renderSorted;
  19885. /**
  19886. * Renders the submeshes in the order they were dispatched (no sort applied).
  19887. * @param subMeshes The submeshes to render
  19888. */
  19889. private static renderUnsorted;
  19890. /**
  19891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19892. * are rendered back to front if in the same alpha index.
  19893. *
  19894. * @param a The first submesh
  19895. * @param b The second submesh
  19896. * @returns The result of the comparison
  19897. */
  19898. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19899. /**
  19900. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19901. * are rendered back to front.
  19902. *
  19903. * @param a The first submesh
  19904. * @param b The second submesh
  19905. * @returns The result of the comparison
  19906. */
  19907. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19908. /**
  19909. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19910. * are rendered front to back (prevent overdraw).
  19911. *
  19912. * @param a The first submesh
  19913. * @param b The second submesh
  19914. * @returns The result of the comparison
  19915. */
  19916. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19917. /**
  19918. * Resets the different lists of submeshes to prepare a new frame.
  19919. */
  19920. prepare(): void;
  19921. dispose(): void;
  19922. /**
  19923. * Inserts the submesh in its correct queue depending on its material.
  19924. * @param subMesh The submesh to dispatch
  19925. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19926. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19927. */
  19928. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19929. dispatchSprites(spriteManager: ISpriteManager): void;
  19930. dispatchParticles(particleSystem: IParticleSystem): void;
  19931. private _renderParticles;
  19932. private _renderSprites;
  19933. }
  19934. }
  19935. declare module "babylonjs/Rendering/renderingManager" {
  19936. import { Nullable } from "babylonjs/types";
  19937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19939. import { SmartArray } from "babylonjs/Misc/smartArray";
  19940. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19941. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19942. import { Material } from "babylonjs/Materials/material";
  19943. import { Scene } from "babylonjs/scene";
  19944. import { Camera } from "babylonjs/Cameras/camera";
  19945. /**
  19946. * Interface describing the different options available in the rendering manager
  19947. * regarding Auto Clear between groups.
  19948. */
  19949. export interface IRenderingManagerAutoClearSetup {
  19950. /**
  19951. * Defines whether or not autoclear is enable.
  19952. */
  19953. autoClear: boolean;
  19954. /**
  19955. * Defines whether or not to autoclear the depth buffer.
  19956. */
  19957. depth: boolean;
  19958. /**
  19959. * Defines whether or not to autoclear the stencil buffer.
  19960. */
  19961. stencil: boolean;
  19962. }
  19963. /**
  19964. * This class is used by the onRenderingGroupObservable
  19965. */
  19966. export class RenderingGroupInfo {
  19967. /**
  19968. * The Scene that being rendered
  19969. */
  19970. scene: Scene;
  19971. /**
  19972. * The camera currently used for the rendering pass
  19973. */
  19974. camera: Nullable<Camera>;
  19975. /**
  19976. * The ID of the renderingGroup being processed
  19977. */
  19978. renderingGroupId: number;
  19979. }
  19980. /**
  19981. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19982. * It is enable to manage the different groups as well as the different necessary sort functions.
  19983. * This should not be used directly aside of the few static configurations
  19984. */
  19985. export class RenderingManager {
  19986. /**
  19987. * The max id used for rendering groups (not included)
  19988. */
  19989. static MAX_RENDERINGGROUPS: number;
  19990. /**
  19991. * The min id used for rendering groups (included)
  19992. */
  19993. static MIN_RENDERINGGROUPS: number;
  19994. /**
  19995. * Used to globally prevent autoclearing scenes.
  19996. */
  19997. static AUTOCLEAR: boolean;
  19998. /**
  19999. * @hidden
  20000. */
  20001. _useSceneAutoClearSetup: boolean;
  20002. private _scene;
  20003. private _renderingGroups;
  20004. private _depthStencilBufferAlreadyCleaned;
  20005. private _autoClearDepthStencil;
  20006. private _customOpaqueSortCompareFn;
  20007. private _customAlphaTestSortCompareFn;
  20008. private _customTransparentSortCompareFn;
  20009. private _renderingGroupInfo;
  20010. /**
  20011. * Instantiates a new rendering group for a particular scene
  20012. * @param scene Defines the scene the groups belongs to
  20013. */
  20014. constructor(scene: Scene);
  20015. private _clearDepthStencilBuffer;
  20016. /**
  20017. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20018. * @hidden
  20019. */
  20020. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20021. /**
  20022. * Resets the different information of the group to prepare a new frame
  20023. * @hidden
  20024. */
  20025. reset(): void;
  20026. /**
  20027. * Dispose and release the group and its associated resources.
  20028. * @hidden
  20029. */
  20030. dispose(): void;
  20031. /**
  20032. * Clear the info related to rendering groups preventing retention points during dispose.
  20033. */
  20034. freeRenderingGroups(): void;
  20035. private _prepareRenderingGroup;
  20036. /**
  20037. * Add a sprite manager to the rendering manager in order to render it this frame.
  20038. * @param spriteManager Define the sprite manager to render
  20039. */
  20040. dispatchSprites(spriteManager: ISpriteManager): void;
  20041. /**
  20042. * Add a particle system to the rendering manager in order to render it this frame.
  20043. * @param particleSystem Define the particle system to render
  20044. */
  20045. dispatchParticles(particleSystem: IParticleSystem): void;
  20046. /**
  20047. * Add a submesh to the manager in order to render it this frame
  20048. * @param subMesh The submesh to dispatch
  20049. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20050. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20051. */
  20052. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20053. /**
  20054. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20055. * This allowed control for front to back rendering or reversly depending of the special needs.
  20056. *
  20057. * @param renderingGroupId The rendering group id corresponding to its index
  20058. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20059. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20060. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20061. */
  20062. 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;
  20063. /**
  20064. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20065. *
  20066. * @param renderingGroupId The rendering group id corresponding to its index
  20067. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20068. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20069. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20070. */
  20071. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20072. /**
  20073. * Gets the current auto clear configuration for one rendering group of the rendering
  20074. * manager.
  20075. * @param index the rendering group index to get the information for
  20076. * @returns The auto clear setup for the requested rendering group
  20077. */
  20078. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20079. }
  20080. }
  20081. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20082. import { Observable } from "babylonjs/Misc/observable";
  20083. import { SmartArray } from "babylonjs/Misc/smartArray";
  20084. import { Nullable } from "babylonjs/types";
  20085. import { Camera } from "babylonjs/Cameras/camera";
  20086. import { Scene } from "babylonjs/scene";
  20087. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20088. import { Color4 } from "babylonjs/Maths/math.color";
  20089. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20091. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20092. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20093. import { Texture } from "babylonjs/Materials/Textures/texture";
  20094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20095. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20096. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20097. import { Engine } from "babylonjs/Engines/engine";
  20098. /**
  20099. * This Helps creating a texture that will be created from a camera in your scene.
  20100. * It is basically a dynamic texture that could be used to create special effects for instance.
  20101. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20102. */
  20103. export class RenderTargetTexture extends Texture {
  20104. isCube: boolean;
  20105. /**
  20106. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20107. */
  20108. static readonly REFRESHRATE_RENDER_ONCE: number;
  20109. /**
  20110. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20111. */
  20112. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20113. /**
  20114. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20115. * the central point of your effect and can save a lot of performances.
  20116. */
  20117. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20118. /**
  20119. * Use this predicate to dynamically define the list of mesh you want to render.
  20120. * If set, the renderList property will be overwritten.
  20121. */
  20122. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20123. private _renderList;
  20124. /**
  20125. * Use this list to define the list of mesh you want to render.
  20126. */
  20127. renderList: Nullable<Array<AbstractMesh>>;
  20128. private _hookArray;
  20129. /**
  20130. * Define if particles should be rendered in your texture.
  20131. */
  20132. renderParticles: boolean;
  20133. /**
  20134. * Define if sprites should be rendered in your texture.
  20135. */
  20136. renderSprites: boolean;
  20137. /**
  20138. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20139. */
  20140. coordinatesMode: number;
  20141. /**
  20142. * Define the camera used to render the texture.
  20143. */
  20144. activeCamera: Nullable<Camera>;
  20145. /**
  20146. * Override the render function of the texture with your own one.
  20147. */
  20148. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20149. /**
  20150. * Define if camera post processes should be use while rendering the texture.
  20151. */
  20152. useCameraPostProcesses: boolean;
  20153. /**
  20154. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20155. */
  20156. ignoreCameraViewport: boolean;
  20157. private _postProcessManager;
  20158. private _postProcesses;
  20159. private _resizeObserver;
  20160. /**
  20161. * An event triggered when the texture is unbind.
  20162. */
  20163. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20164. /**
  20165. * An event triggered when the texture is unbind.
  20166. */
  20167. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20168. private _onAfterUnbindObserver;
  20169. /**
  20170. * Set a after unbind callback in the texture.
  20171. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20172. */
  20173. onAfterUnbind: () => void;
  20174. /**
  20175. * An event triggered before rendering the texture
  20176. */
  20177. onBeforeRenderObservable: Observable<number>;
  20178. private _onBeforeRenderObserver;
  20179. /**
  20180. * Set a before render callback in the texture.
  20181. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20182. */
  20183. onBeforeRender: (faceIndex: number) => void;
  20184. /**
  20185. * An event triggered after rendering the texture
  20186. */
  20187. onAfterRenderObservable: Observable<number>;
  20188. private _onAfterRenderObserver;
  20189. /**
  20190. * Set a after render callback in the texture.
  20191. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20192. */
  20193. onAfterRender: (faceIndex: number) => void;
  20194. /**
  20195. * An event triggered after the texture clear
  20196. */
  20197. onClearObservable: Observable<Engine>;
  20198. private _onClearObserver;
  20199. /**
  20200. * Set a clear callback in the texture.
  20201. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20202. */
  20203. onClear: (Engine: Engine) => void;
  20204. /**
  20205. * An event triggered when the texture is resized.
  20206. */
  20207. onResizeObservable: Observable<RenderTargetTexture>;
  20208. /**
  20209. * Define the clear color of the Render Target if it should be different from the scene.
  20210. */
  20211. clearColor: Color4;
  20212. protected _size: number | {
  20213. width: number;
  20214. height: number;
  20215. };
  20216. protected _initialSizeParameter: number | {
  20217. width: number;
  20218. height: number;
  20219. } | {
  20220. ratio: number;
  20221. };
  20222. protected _sizeRatio: Nullable<number>;
  20223. /** @hidden */
  20224. _generateMipMaps: boolean;
  20225. protected _renderingManager: RenderingManager;
  20226. /** @hidden */
  20227. _waitingRenderList: string[];
  20228. protected _doNotChangeAspectRatio: boolean;
  20229. protected _currentRefreshId: number;
  20230. protected _refreshRate: number;
  20231. protected _textureMatrix: Matrix;
  20232. protected _samples: number;
  20233. protected _renderTargetOptions: RenderTargetCreationOptions;
  20234. /**
  20235. * Gets render target creation options that were used.
  20236. */
  20237. readonly renderTargetOptions: RenderTargetCreationOptions;
  20238. protected _engine: Engine;
  20239. protected _onRatioRescale(): void;
  20240. /**
  20241. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20242. * It must define where the camera used to render the texture is set
  20243. */
  20244. boundingBoxPosition: Vector3;
  20245. private _boundingBoxSize;
  20246. /**
  20247. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20248. * When defined, the cubemap will switch to local mode
  20249. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20250. * @example https://www.babylonjs-playground.com/#RNASML
  20251. */
  20252. boundingBoxSize: Vector3;
  20253. /**
  20254. * In case the RTT has been created with a depth texture, get the associated
  20255. * depth texture.
  20256. * Otherwise, return null.
  20257. */
  20258. depthStencilTexture: Nullable<InternalTexture>;
  20259. /**
  20260. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20261. * or used a shadow, depth texture...
  20262. * @param name The friendly name of the texture
  20263. * @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)
  20264. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20265. * @param generateMipMaps True if mip maps need to be generated after render.
  20266. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20267. * @param type The type of the buffer in the RTT (int, half float, float...)
  20268. * @param isCube True if a cube texture needs to be created
  20269. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20270. * @param generateDepthBuffer True to generate a depth buffer
  20271. * @param generateStencilBuffer True to generate a stencil buffer
  20272. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20273. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20274. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20275. */
  20276. constructor(name: string, size: number | {
  20277. width: number;
  20278. height: number;
  20279. } | {
  20280. ratio: number;
  20281. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20282. /**
  20283. * Creates a depth stencil texture.
  20284. * This is only available in WebGL 2 or with the depth texture extension available.
  20285. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20286. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20287. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20288. */
  20289. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20290. private _processSizeParameter;
  20291. /**
  20292. * Define the number of samples to use in case of MSAA.
  20293. * It defaults to one meaning no MSAA has been enabled.
  20294. */
  20295. samples: number;
  20296. /**
  20297. * Resets the refresh counter of the texture and start bak from scratch.
  20298. * Could be useful to regenerate the texture if it is setup to render only once.
  20299. */
  20300. resetRefreshCounter(): void;
  20301. /**
  20302. * Define the refresh rate of the texture or the rendering frequency.
  20303. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20304. */
  20305. refreshRate: number;
  20306. /**
  20307. * Adds a post process to the render target rendering passes.
  20308. * @param postProcess define the post process to add
  20309. */
  20310. addPostProcess(postProcess: PostProcess): void;
  20311. /**
  20312. * Clear all the post processes attached to the render target
  20313. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20314. */
  20315. clearPostProcesses(dispose?: boolean): void;
  20316. /**
  20317. * Remove one of the post process from the list of attached post processes to the texture
  20318. * @param postProcess define the post process to remove from the list
  20319. */
  20320. removePostProcess(postProcess: PostProcess): void;
  20321. /** @hidden */
  20322. _shouldRender(): boolean;
  20323. /**
  20324. * Gets the actual render size of the texture.
  20325. * @returns the width of the render size
  20326. */
  20327. getRenderSize(): number;
  20328. /**
  20329. * Gets the actual render width of the texture.
  20330. * @returns the width of the render size
  20331. */
  20332. getRenderWidth(): number;
  20333. /**
  20334. * Gets the actual render height of the texture.
  20335. * @returns the height of the render size
  20336. */
  20337. getRenderHeight(): number;
  20338. /**
  20339. * Get if the texture can be rescaled or not.
  20340. */
  20341. readonly canRescale: boolean;
  20342. /**
  20343. * Resize the texture using a ratio.
  20344. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20345. */
  20346. scale(ratio: number): void;
  20347. /**
  20348. * Get the texture reflection matrix used to rotate/transform the reflection.
  20349. * @returns the reflection matrix
  20350. */
  20351. getReflectionTextureMatrix(): Matrix;
  20352. /**
  20353. * Resize the texture to a new desired size.
  20354. * Be carrefull as it will recreate all the data in the new texture.
  20355. * @param size Define the new size. It can be:
  20356. * - a number for squared texture,
  20357. * - an object containing { width: number, height: number }
  20358. * - or an object containing a ratio { ratio: number }
  20359. */
  20360. resize(size: number | {
  20361. width: number;
  20362. height: number;
  20363. } | {
  20364. ratio: number;
  20365. }): void;
  20366. /**
  20367. * Renders all the objects from the render list into the texture.
  20368. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20369. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20370. */
  20371. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20372. private _bestReflectionRenderTargetDimension;
  20373. /**
  20374. * @hidden
  20375. * @param faceIndex face index to bind to if this is a cubetexture
  20376. */
  20377. _bindFrameBuffer(faceIndex?: number): void;
  20378. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20379. private renderToTarget;
  20380. /**
  20381. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20382. * This allowed control for front to back rendering or reversly depending of the special needs.
  20383. *
  20384. * @param renderingGroupId The rendering group id corresponding to its index
  20385. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20386. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20387. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20388. */
  20389. 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;
  20390. /**
  20391. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20392. *
  20393. * @param renderingGroupId The rendering group id corresponding to its index
  20394. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20395. */
  20396. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20397. /**
  20398. * Clones the texture.
  20399. * @returns the cloned texture
  20400. */
  20401. clone(): RenderTargetTexture;
  20402. /**
  20403. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20404. * @returns The JSON representation of the texture
  20405. */
  20406. serialize(): any;
  20407. /**
  20408. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20409. */
  20410. disposeFramebufferObjects(): void;
  20411. /**
  20412. * Dispose the texture and release its associated resources.
  20413. */
  20414. dispose(): void;
  20415. /** @hidden */
  20416. _rebuild(): void;
  20417. /**
  20418. * Clear the info related to rendering groups preventing retention point in material dispose.
  20419. */
  20420. freeRenderingGroups(): void;
  20421. /**
  20422. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20423. * @returns the view count
  20424. */
  20425. getViewCount(): number;
  20426. }
  20427. }
  20428. declare module "babylonjs/Materials/material" {
  20429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20430. import { SmartArray } from "babylonjs/Misc/smartArray";
  20431. import { Observable } from "babylonjs/Misc/observable";
  20432. import { Nullable } from "babylonjs/types";
  20433. import { Scene } from "babylonjs/scene";
  20434. import { Matrix } from "babylonjs/Maths/math.vector";
  20435. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20437. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20438. import { Effect } from "babylonjs/Materials/effect";
  20439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20440. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20441. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20442. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20443. import { Mesh } from "babylonjs/Meshes/mesh";
  20444. import { Animation } from "babylonjs/Animations/animation";
  20445. /**
  20446. * Base class for the main features of a material in Babylon.js
  20447. */
  20448. export class Material implements IAnimatable {
  20449. /**
  20450. * Returns the triangle fill mode
  20451. */
  20452. static readonly TriangleFillMode: number;
  20453. /**
  20454. * Returns the wireframe mode
  20455. */
  20456. static readonly WireFrameFillMode: number;
  20457. /**
  20458. * Returns the point fill mode
  20459. */
  20460. static readonly PointFillMode: number;
  20461. /**
  20462. * Returns the point list draw mode
  20463. */
  20464. static readonly PointListDrawMode: number;
  20465. /**
  20466. * Returns the line list draw mode
  20467. */
  20468. static readonly LineListDrawMode: number;
  20469. /**
  20470. * Returns the line loop draw mode
  20471. */
  20472. static readonly LineLoopDrawMode: number;
  20473. /**
  20474. * Returns the line strip draw mode
  20475. */
  20476. static readonly LineStripDrawMode: number;
  20477. /**
  20478. * Returns the triangle strip draw mode
  20479. */
  20480. static readonly TriangleStripDrawMode: number;
  20481. /**
  20482. * Returns the triangle fan draw mode
  20483. */
  20484. static readonly TriangleFanDrawMode: number;
  20485. /**
  20486. * Stores the clock-wise side orientation
  20487. */
  20488. static readonly ClockWiseSideOrientation: number;
  20489. /**
  20490. * Stores the counter clock-wise side orientation
  20491. */
  20492. static readonly CounterClockWiseSideOrientation: number;
  20493. /**
  20494. * The dirty texture flag value
  20495. */
  20496. static readonly TextureDirtyFlag: number;
  20497. /**
  20498. * The dirty light flag value
  20499. */
  20500. static readonly LightDirtyFlag: number;
  20501. /**
  20502. * The dirty fresnel flag value
  20503. */
  20504. static readonly FresnelDirtyFlag: number;
  20505. /**
  20506. * The dirty attribute flag value
  20507. */
  20508. static readonly AttributesDirtyFlag: number;
  20509. /**
  20510. * The dirty misc flag value
  20511. */
  20512. static readonly MiscDirtyFlag: number;
  20513. /**
  20514. * The all dirty flag value
  20515. */
  20516. static readonly AllDirtyFlag: number;
  20517. /**
  20518. * The ID of the material
  20519. */
  20520. id: string;
  20521. /**
  20522. * Gets or sets the unique id of the material
  20523. */
  20524. uniqueId: number;
  20525. /**
  20526. * The name of the material
  20527. */
  20528. name: string;
  20529. /**
  20530. * Gets or sets user defined metadata
  20531. */
  20532. metadata: any;
  20533. /**
  20534. * For internal use only. Please do not use.
  20535. */
  20536. reservedDataStore: any;
  20537. /**
  20538. * Specifies if the ready state should be checked on each call
  20539. */
  20540. checkReadyOnEveryCall: boolean;
  20541. /**
  20542. * Specifies if the ready state should be checked once
  20543. */
  20544. checkReadyOnlyOnce: boolean;
  20545. /**
  20546. * The state of the material
  20547. */
  20548. state: string;
  20549. /**
  20550. * The alpha value of the material
  20551. */
  20552. protected _alpha: number;
  20553. /**
  20554. * List of inspectable custom properties (used by the Inspector)
  20555. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20556. */
  20557. inspectableCustomProperties: IInspectable[];
  20558. /**
  20559. * Sets the alpha value of the material
  20560. */
  20561. /**
  20562. * Gets the alpha value of the material
  20563. */
  20564. alpha: number;
  20565. /**
  20566. * Specifies if back face culling is enabled
  20567. */
  20568. protected _backFaceCulling: boolean;
  20569. /**
  20570. * Sets the back-face culling state
  20571. */
  20572. /**
  20573. * Gets the back-face culling state
  20574. */
  20575. backFaceCulling: boolean;
  20576. /**
  20577. * Stores the value for side orientation
  20578. */
  20579. sideOrientation: number;
  20580. /**
  20581. * Callback triggered when the material is compiled
  20582. */
  20583. onCompiled: Nullable<(effect: Effect) => void>;
  20584. /**
  20585. * Callback triggered when an error occurs
  20586. */
  20587. onError: Nullable<(effect: Effect, errors: string) => void>;
  20588. /**
  20589. * Callback triggered to get the render target textures
  20590. */
  20591. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20592. /**
  20593. * Gets a boolean indicating that current material needs to register RTT
  20594. */
  20595. readonly hasRenderTargetTextures: boolean;
  20596. /**
  20597. * Specifies if the material should be serialized
  20598. */
  20599. doNotSerialize: boolean;
  20600. /**
  20601. * @hidden
  20602. */
  20603. _storeEffectOnSubMeshes: boolean;
  20604. /**
  20605. * Stores the animations for the material
  20606. */
  20607. animations: Nullable<Array<Animation>>;
  20608. /**
  20609. * An event triggered when the material is disposed
  20610. */
  20611. onDisposeObservable: Observable<Material>;
  20612. /**
  20613. * An observer which watches for dispose events
  20614. */
  20615. private _onDisposeObserver;
  20616. private _onUnBindObservable;
  20617. /**
  20618. * Called during a dispose event
  20619. */
  20620. onDispose: () => void;
  20621. private _onBindObservable;
  20622. /**
  20623. * An event triggered when the material is bound
  20624. */
  20625. readonly onBindObservable: Observable<AbstractMesh>;
  20626. /**
  20627. * An observer which watches for bind events
  20628. */
  20629. private _onBindObserver;
  20630. /**
  20631. * Called during a bind event
  20632. */
  20633. onBind: (Mesh: AbstractMesh) => void;
  20634. /**
  20635. * An event triggered when the material is unbound
  20636. */
  20637. readonly onUnBindObservable: Observable<Material>;
  20638. /**
  20639. * Stores the value of the alpha mode
  20640. */
  20641. private _alphaMode;
  20642. /**
  20643. * Sets the value of the alpha mode.
  20644. *
  20645. * | Value | Type | Description |
  20646. * | --- | --- | --- |
  20647. * | 0 | ALPHA_DISABLE | |
  20648. * | 1 | ALPHA_ADD | |
  20649. * | 2 | ALPHA_COMBINE | |
  20650. * | 3 | ALPHA_SUBTRACT | |
  20651. * | 4 | ALPHA_MULTIPLY | |
  20652. * | 5 | ALPHA_MAXIMIZED | |
  20653. * | 6 | ALPHA_ONEONE | |
  20654. * | 7 | ALPHA_PREMULTIPLIED | |
  20655. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20656. * | 9 | ALPHA_INTERPOLATE | |
  20657. * | 10 | ALPHA_SCREENMODE | |
  20658. *
  20659. */
  20660. /**
  20661. * Gets the value of the alpha mode
  20662. */
  20663. alphaMode: number;
  20664. /**
  20665. * Stores the state of the need depth pre-pass value
  20666. */
  20667. private _needDepthPrePass;
  20668. /**
  20669. * Sets the need depth pre-pass value
  20670. */
  20671. /**
  20672. * Gets the depth pre-pass value
  20673. */
  20674. needDepthPrePass: boolean;
  20675. /**
  20676. * Specifies if depth writing should be disabled
  20677. */
  20678. disableDepthWrite: boolean;
  20679. /**
  20680. * Specifies if depth writing should be forced
  20681. */
  20682. forceDepthWrite: boolean;
  20683. /**
  20684. * Specifies if there should be a separate pass for culling
  20685. */
  20686. separateCullingPass: boolean;
  20687. /**
  20688. * Stores the state specifing if fog should be enabled
  20689. */
  20690. private _fogEnabled;
  20691. /**
  20692. * Sets the state for enabling fog
  20693. */
  20694. /**
  20695. * Gets the value of the fog enabled state
  20696. */
  20697. fogEnabled: boolean;
  20698. /**
  20699. * Stores the size of points
  20700. */
  20701. pointSize: number;
  20702. /**
  20703. * Stores the z offset value
  20704. */
  20705. zOffset: number;
  20706. /**
  20707. * Gets a value specifying if wireframe mode is enabled
  20708. */
  20709. /**
  20710. * Sets the state of wireframe mode
  20711. */
  20712. wireframe: boolean;
  20713. /**
  20714. * Gets the value specifying if point clouds are enabled
  20715. */
  20716. /**
  20717. * Sets the state of point cloud mode
  20718. */
  20719. pointsCloud: boolean;
  20720. /**
  20721. * Gets the material fill mode
  20722. */
  20723. /**
  20724. * Sets the material fill mode
  20725. */
  20726. fillMode: number;
  20727. /**
  20728. * @hidden
  20729. * Stores the effects for the material
  20730. */
  20731. _effect: Nullable<Effect>;
  20732. /**
  20733. * @hidden
  20734. * Specifies if the material was previously ready
  20735. */
  20736. _wasPreviouslyReady: boolean;
  20737. /**
  20738. * Specifies if uniform buffers should be used
  20739. */
  20740. private _useUBO;
  20741. /**
  20742. * Stores a reference to the scene
  20743. */
  20744. private _scene;
  20745. /**
  20746. * Stores the fill mode state
  20747. */
  20748. private _fillMode;
  20749. /**
  20750. * Specifies if the depth write state should be cached
  20751. */
  20752. private _cachedDepthWriteState;
  20753. /**
  20754. * Stores the uniform buffer
  20755. */
  20756. protected _uniformBuffer: UniformBuffer;
  20757. /** @hidden */
  20758. _indexInSceneMaterialArray: number;
  20759. /** @hidden */
  20760. meshMap: Nullable<{
  20761. [id: string]: AbstractMesh | undefined;
  20762. }>;
  20763. /**
  20764. * Creates a material instance
  20765. * @param name defines the name of the material
  20766. * @param scene defines the scene to reference
  20767. * @param doNotAdd specifies if the material should be added to the scene
  20768. */
  20769. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20770. /**
  20771. * Returns a string representation of the current material
  20772. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20773. * @returns a string with material information
  20774. */
  20775. toString(fullDetails?: boolean): string;
  20776. /**
  20777. * Gets the class name of the material
  20778. * @returns a string with the class name of the material
  20779. */
  20780. getClassName(): string;
  20781. /**
  20782. * Specifies if updates for the material been locked
  20783. */
  20784. readonly isFrozen: boolean;
  20785. /**
  20786. * Locks updates for the material
  20787. */
  20788. freeze(): void;
  20789. /**
  20790. * Unlocks updates for the material
  20791. */
  20792. unfreeze(): void;
  20793. /**
  20794. * Specifies if the material is ready to be used
  20795. * @param mesh defines the mesh to check
  20796. * @param useInstances specifies if instances should be used
  20797. * @returns a boolean indicating if the material is ready to be used
  20798. */
  20799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20800. /**
  20801. * Specifies that the submesh is ready to be used
  20802. * @param mesh defines the mesh to check
  20803. * @param subMesh defines which submesh to check
  20804. * @param useInstances specifies that instances should be used
  20805. * @returns a boolean indicating that the submesh is ready or not
  20806. */
  20807. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20808. /**
  20809. * Returns the material effect
  20810. * @returns the effect associated with the material
  20811. */
  20812. getEffect(): Nullable<Effect>;
  20813. /**
  20814. * Returns the current scene
  20815. * @returns a Scene
  20816. */
  20817. getScene(): Scene;
  20818. /**
  20819. * Specifies if the material will require alpha blending
  20820. * @returns a boolean specifying if alpha blending is needed
  20821. */
  20822. needAlphaBlending(): boolean;
  20823. /**
  20824. * Specifies if the mesh will require alpha blending
  20825. * @param mesh defines the mesh to check
  20826. * @returns a boolean specifying if alpha blending is needed for the mesh
  20827. */
  20828. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20829. /**
  20830. * Specifies if this material should be rendered in alpha test mode
  20831. * @returns a boolean specifying if an alpha test is needed.
  20832. */
  20833. needAlphaTesting(): boolean;
  20834. /**
  20835. * Gets the texture used for the alpha test
  20836. * @returns the texture to use for alpha testing
  20837. */
  20838. getAlphaTestTexture(): Nullable<BaseTexture>;
  20839. /**
  20840. * Marks the material to indicate that it needs to be re-calculated
  20841. */
  20842. markDirty(): void;
  20843. /** @hidden */
  20844. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20845. /**
  20846. * Binds the material to the mesh
  20847. * @param world defines the world transformation matrix
  20848. * @param mesh defines the mesh to bind the material to
  20849. */
  20850. bind(world: Matrix, mesh?: Mesh): void;
  20851. /**
  20852. * Binds the submesh to the material
  20853. * @param world defines the world transformation matrix
  20854. * @param mesh defines the mesh containing the submesh
  20855. * @param subMesh defines the submesh to bind the material to
  20856. */
  20857. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20858. /**
  20859. * Binds the world matrix to the material
  20860. * @param world defines the world transformation matrix
  20861. */
  20862. bindOnlyWorldMatrix(world: Matrix): void;
  20863. /**
  20864. * Binds the scene's uniform buffer to the effect.
  20865. * @param effect defines the effect to bind to the scene uniform buffer
  20866. * @param sceneUbo defines the uniform buffer storing scene data
  20867. */
  20868. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20869. /**
  20870. * Binds the view matrix to the effect
  20871. * @param effect defines the effect to bind the view matrix to
  20872. */
  20873. bindView(effect: Effect): void;
  20874. /**
  20875. * Binds the view projection matrix to the effect
  20876. * @param effect defines the effect to bind the view projection matrix to
  20877. */
  20878. bindViewProjection(effect: Effect): void;
  20879. /**
  20880. * Specifies if material alpha testing should be turned on for the mesh
  20881. * @param mesh defines the mesh to check
  20882. */
  20883. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20884. /**
  20885. * Processes to execute after binding the material to a mesh
  20886. * @param mesh defines the rendered mesh
  20887. */
  20888. protected _afterBind(mesh?: Mesh): void;
  20889. /**
  20890. * Unbinds the material from the mesh
  20891. */
  20892. unbind(): void;
  20893. /**
  20894. * Gets the active textures from the material
  20895. * @returns an array of textures
  20896. */
  20897. getActiveTextures(): BaseTexture[];
  20898. /**
  20899. * Specifies if the material uses a texture
  20900. * @param texture defines the texture to check against the material
  20901. * @returns a boolean specifying if the material uses the texture
  20902. */
  20903. hasTexture(texture: BaseTexture): boolean;
  20904. /**
  20905. * Makes a duplicate of the material, and gives it a new name
  20906. * @param name defines the new name for the duplicated material
  20907. * @returns the cloned material
  20908. */
  20909. clone(name: string): Nullable<Material>;
  20910. /**
  20911. * Gets the meshes bound to the material
  20912. * @returns an array of meshes bound to the material
  20913. */
  20914. getBindedMeshes(): AbstractMesh[];
  20915. /**
  20916. * Force shader compilation
  20917. * @param mesh defines the mesh associated with this material
  20918. * @param onCompiled defines a function to execute once the material is compiled
  20919. * @param options defines the options to configure the compilation
  20920. */
  20921. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20922. clipPlane: boolean;
  20923. }>): void;
  20924. /**
  20925. * Force shader compilation
  20926. * @param mesh defines the mesh that will use this material
  20927. * @param options defines additional options for compiling the shaders
  20928. * @returns a promise that resolves when the compilation completes
  20929. */
  20930. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20931. clipPlane: boolean;
  20932. }>): Promise<void>;
  20933. private static readonly _AllDirtyCallBack;
  20934. private static readonly _ImageProcessingDirtyCallBack;
  20935. private static readonly _TextureDirtyCallBack;
  20936. private static readonly _FresnelDirtyCallBack;
  20937. private static readonly _MiscDirtyCallBack;
  20938. private static readonly _LightsDirtyCallBack;
  20939. private static readonly _AttributeDirtyCallBack;
  20940. private static _FresnelAndMiscDirtyCallBack;
  20941. private static _TextureAndMiscDirtyCallBack;
  20942. private static readonly _DirtyCallbackArray;
  20943. private static readonly _RunDirtyCallBacks;
  20944. /**
  20945. * Marks a define in the material to indicate that it needs to be re-computed
  20946. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20947. */
  20948. markAsDirty(flag: number): void;
  20949. /**
  20950. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20951. * @param func defines a function which checks material defines against the submeshes
  20952. */
  20953. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20954. /**
  20955. * Indicates that we need to re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsAllDirty(): void;
  20958. /**
  20959. * Indicates that image processing needs to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20962. /**
  20963. * Indicates that textures need to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsTexturesDirty(): void;
  20966. /**
  20967. * Indicates that fresnel needs to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsFresnelDirty(): void;
  20970. /**
  20971. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20974. /**
  20975. * Indicates that lights need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsLightsDirty(): void;
  20978. /**
  20979. * Indicates that attributes need to be re-calculated for all submeshes
  20980. */
  20981. protected _markAllSubMeshesAsAttributesDirty(): void;
  20982. /**
  20983. * Indicates that misc needs to be re-calculated for all submeshes
  20984. */
  20985. protected _markAllSubMeshesAsMiscDirty(): void;
  20986. /**
  20987. * Indicates that textures and misc need to be re-calculated for all submeshes
  20988. */
  20989. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20990. /**
  20991. * Disposes the material
  20992. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20993. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20994. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20995. */
  20996. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20997. /** @hidden */
  20998. private releaseVertexArrayObject;
  20999. /**
  21000. * Serializes this material
  21001. * @returns the serialized material object
  21002. */
  21003. serialize(): any;
  21004. /**
  21005. * Creates a material from parsed material data
  21006. * @param parsedMaterial defines parsed material data
  21007. * @param scene defines the hosting scene
  21008. * @param rootUrl defines the root URL to use to load textures
  21009. * @returns a new material
  21010. */
  21011. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21012. }
  21013. }
  21014. declare module "babylonjs/Materials/multiMaterial" {
  21015. import { Nullable } from "babylonjs/types";
  21016. import { Scene } from "babylonjs/scene";
  21017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21018. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21020. import { Material } from "babylonjs/Materials/material";
  21021. /**
  21022. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21023. * separate meshes. This can be use to improve performances.
  21024. * @see http://doc.babylonjs.com/how_to/multi_materials
  21025. */
  21026. export class MultiMaterial extends Material {
  21027. private _subMaterials;
  21028. /**
  21029. * Gets or Sets the list of Materials used within the multi material.
  21030. * They need to be ordered according to the submeshes order in the associated mesh
  21031. */
  21032. subMaterials: Nullable<Material>[];
  21033. /**
  21034. * Function used to align with Node.getChildren()
  21035. * @returns the list of Materials used within the multi material
  21036. */
  21037. getChildren(): Nullable<Material>[];
  21038. /**
  21039. * Instantiates a new Multi Material
  21040. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21041. * separate meshes. This can be use to improve performances.
  21042. * @see http://doc.babylonjs.com/how_to/multi_materials
  21043. * @param name Define the name in the scene
  21044. * @param scene Define the scene the material belongs to
  21045. */
  21046. constructor(name: string, scene: Scene);
  21047. private _hookArray;
  21048. /**
  21049. * Get one of the submaterial by its index in the submaterials array
  21050. * @param index The index to look the sub material at
  21051. * @returns The Material if the index has been defined
  21052. */
  21053. getSubMaterial(index: number): Nullable<Material>;
  21054. /**
  21055. * Get the list of active textures for the whole sub materials list.
  21056. * @returns All the textures that will be used during the rendering
  21057. */
  21058. getActiveTextures(): BaseTexture[];
  21059. /**
  21060. * Gets the current class name of the material e.g. "MultiMaterial"
  21061. * Mainly use in serialization.
  21062. * @returns the class name
  21063. */
  21064. getClassName(): string;
  21065. /**
  21066. * Checks if the material is ready to render the requested sub mesh
  21067. * @param mesh Define the mesh the submesh belongs to
  21068. * @param subMesh Define the sub mesh to look readyness for
  21069. * @param useInstances Define whether or not the material is used with instances
  21070. * @returns true if ready, otherwise false
  21071. */
  21072. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21073. /**
  21074. * Clones the current material and its related sub materials
  21075. * @param name Define the name of the newly cloned material
  21076. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21077. * @returns the cloned material
  21078. */
  21079. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21080. /**
  21081. * Serializes the materials into a JSON representation.
  21082. * @returns the JSON representation
  21083. */
  21084. serialize(): any;
  21085. /**
  21086. * Dispose the material and release its associated resources
  21087. * @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)
  21088. * @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)
  21089. * @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)
  21090. */
  21091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21092. /**
  21093. * Creates a MultiMaterial from parsed MultiMaterial data.
  21094. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21095. * @param scene defines the hosting scene
  21096. * @returns a new MultiMaterial
  21097. */
  21098. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21099. }
  21100. }
  21101. declare module "babylonjs/Meshes/subMesh" {
  21102. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21103. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21104. import { Engine } from "babylonjs/Engines/engine";
  21105. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21106. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21107. import { Effect } from "babylonjs/Materials/effect";
  21108. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21109. import { Plane } from "babylonjs/Maths/math.plane";
  21110. import { Collider } from "babylonjs/Collisions/collider";
  21111. import { Material } from "babylonjs/Materials/material";
  21112. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21114. import { Mesh } from "babylonjs/Meshes/mesh";
  21115. import { Ray } from "babylonjs/Culling/ray";
  21116. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21117. /**
  21118. * Base class for submeshes
  21119. */
  21120. export class BaseSubMesh {
  21121. /** @hidden */
  21122. _materialDefines: Nullable<MaterialDefines>;
  21123. /** @hidden */
  21124. _materialEffect: Nullable<Effect>;
  21125. /**
  21126. * Gets associated effect
  21127. */
  21128. readonly effect: Nullable<Effect>;
  21129. /**
  21130. * Sets associated effect (effect used to render this submesh)
  21131. * @param effect defines the effect to associate with
  21132. * @param defines defines the set of defines used to compile this effect
  21133. */
  21134. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21135. }
  21136. /**
  21137. * Defines a subdivision inside a mesh
  21138. */
  21139. export class SubMesh extends BaseSubMesh implements ICullable {
  21140. /** the material index to use */
  21141. materialIndex: number;
  21142. /** vertex index start */
  21143. verticesStart: number;
  21144. /** vertices count */
  21145. verticesCount: number;
  21146. /** index start */
  21147. indexStart: number;
  21148. /** indices count */
  21149. indexCount: number;
  21150. /** @hidden */
  21151. _linesIndexCount: number;
  21152. private _mesh;
  21153. private _renderingMesh;
  21154. private _boundingInfo;
  21155. private _linesIndexBuffer;
  21156. /** @hidden */
  21157. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21158. /** @hidden */
  21159. _trianglePlanes: Plane[];
  21160. /** @hidden */
  21161. _lastColliderTransformMatrix: Nullable<Matrix>;
  21162. /** @hidden */
  21163. _renderId: number;
  21164. /** @hidden */
  21165. _alphaIndex: number;
  21166. /** @hidden */
  21167. _distanceToCamera: number;
  21168. /** @hidden */
  21169. _id: number;
  21170. private _currentMaterial;
  21171. /**
  21172. * Add a new submesh to a mesh
  21173. * @param materialIndex defines the material index to use
  21174. * @param verticesStart defines vertex index start
  21175. * @param verticesCount defines vertices count
  21176. * @param indexStart defines index start
  21177. * @param indexCount defines indices count
  21178. * @param mesh defines the parent mesh
  21179. * @param renderingMesh defines an optional rendering mesh
  21180. * @param createBoundingBox defines if bounding box should be created for this submesh
  21181. * @returns the new submesh
  21182. */
  21183. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21184. /**
  21185. * Creates a new submesh
  21186. * @param materialIndex defines the material index to use
  21187. * @param verticesStart defines vertex index start
  21188. * @param verticesCount defines vertices count
  21189. * @param indexStart defines index start
  21190. * @param indexCount defines indices count
  21191. * @param mesh defines the parent mesh
  21192. * @param renderingMesh defines an optional rendering mesh
  21193. * @param createBoundingBox defines if bounding box should be created for this submesh
  21194. */
  21195. constructor(
  21196. /** the material index to use */
  21197. materialIndex: number,
  21198. /** vertex index start */
  21199. verticesStart: number,
  21200. /** vertices count */
  21201. verticesCount: number,
  21202. /** index start */
  21203. indexStart: number,
  21204. /** indices count */
  21205. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21206. /**
  21207. * Returns true if this submesh covers the entire parent mesh
  21208. * @ignorenaming
  21209. */
  21210. readonly IsGlobal: boolean;
  21211. /**
  21212. * Returns the submesh BoudingInfo object
  21213. * @returns current bounding info (or mesh's one if the submesh is global)
  21214. */
  21215. getBoundingInfo(): BoundingInfo;
  21216. /**
  21217. * Sets the submesh BoundingInfo
  21218. * @param boundingInfo defines the new bounding info to use
  21219. * @returns the SubMesh
  21220. */
  21221. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21222. /**
  21223. * Returns the mesh of the current submesh
  21224. * @return the parent mesh
  21225. */
  21226. getMesh(): AbstractMesh;
  21227. /**
  21228. * Returns the rendering mesh of the submesh
  21229. * @returns the rendering mesh (could be different from parent mesh)
  21230. */
  21231. getRenderingMesh(): Mesh;
  21232. /**
  21233. * Returns the submesh material
  21234. * @returns null or the current material
  21235. */
  21236. getMaterial(): Nullable<Material>;
  21237. /**
  21238. * Sets a new updated BoundingInfo object to the submesh
  21239. * @param data defines an optional position array to use to determine the bounding info
  21240. * @returns the SubMesh
  21241. */
  21242. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21243. /** @hidden */
  21244. _checkCollision(collider: Collider): boolean;
  21245. /**
  21246. * Updates the submesh BoundingInfo
  21247. * @param world defines the world matrix to use to update the bounding info
  21248. * @returns the submesh
  21249. */
  21250. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21251. /**
  21252. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21253. * @param frustumPlanes defines the frustum planes
  21254. * @returns true if the submesh is intersecting with the frustum
  21255. */
  21256. isInFrustum(frustumPlanes: Plane[]): boolean;
  21257. /**
  21258. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21259. * @param frustumPlanes defines the frustum planes
  21260. * @returns true if the submesh is inside the frustum
  21261. */
  21262. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21263. /**
  21264. * Renders the submesh
  21265. * @param enableAlphaMode defines if alpha needs to be used
  21266. * @returns the submesh
  21267. */
  21268. render(enableAlphaMode: boolean): SubMesh;
  21269. /**
  21270. * @hidden
  21271. */
  21272. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21273. /**
  21274. * Checks if the submesh intersects with a ray
  21275. * @param ray defines the ray to test
  21276. * @returns true is the passed ray intersects the submesh bounding box
  21277. */
  21278. canIntersects(ray: Ray): boolean;
  21279. /**
  21280. * Intersects current submesh with a ray
  21281. * @param ray defines the ray to test
  21282. * @param positions defines mesh's positions array
  21283. * @param indices defines mesh's indices array
  21284. * @param fastCheck defines if only bounding info should be used
  21285. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21286. * @returns intersection info or null if no intersection
  21287. */
  21288. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21289. /** @hidden */
  21290. private _intersectLines;
  21291. /** @hidden */
  21292. private _intersectUnIndexedLines;
  21293. /** @hidden */
  21294. private _intersectTriangles;
  21295. /** @hidden */
  21296. private _intersectUnIndexedTriangles;
  21297. /** @hidden */
  21298. _rebuild(): void;
  21299. /**
  21300. * Creates a new submesh from the passed mesh
  21301. * @param newMesh defines the new hosting mesh
  21302. * @param newRenderingMesh defines an optional rendering mesh
  21303. * @returns the new submesh
  21304. */
  21305. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21306. /**
  21307. * Release associated resources
  21308. */
  21309. dispose(): void;
  21310. /**
  21311. * Gets the class name
  21312. * @returns the string "SubMesh".
  21313. */
  21314. getClassName(): string;
  21315. /**
  21316. * Creates a new submesh from indices data
  21317. * @param materialIndex the index of the main mesh material
  21318. * @param startIndex the index where to start the copy in the mesh indices array
  21319. * @param indexCount the number of indices to copy then from the startIndex
  21320. * @param mesh the main mesh to create the submesh from
  21321. * @param renderingMesh the optional rendering mesh
  21322. * @returns a new submesh
  21323. */
  21324. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21325. }
  21326. }
  21327. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21328. /**
  21329. * Class used to represent data loading progression
  21330. */
  21331. export class SceneLoaderFlags {
  21332. private static _ForceFullSceneLoadingForIncremental;
  21333. private static _ShowLoadingScreen;
  21334. private static _CleanBoneMatrixWeights;
  21335. private static _loggingLevel;
  21336. /**
  21337. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21338. */
  21339. static ForceFullSceneLoadingForIncremental: boolean;
  21340. /**
  21341. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21342. */
  21343. static ShowLoadingScreen: boolean;
  21344. /**
  21345. * Defines the current logging level (while loading the scene)
  21346. * @ignorenaming
  21347. */
  21348. static loggingLevel: number;
  21349. /**
  21350. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21351. */
  21352. static CleanBoneMatrixWeights: boolean;
  21353. }
  21354. }
  21355. declare module "babylonjs/Meshes/geometry" {
  21356. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21357. import { Scene } from "babylonjs/scene";
  21358. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21359. import { Engine } from "babylonjs/Engines/engine";
  21360. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21361. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21362. import { Effect } from "babylonjs/Materials/effect";
  21363. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21365. import { Mesh } from "babylonjs/Meshes/mesh";
  21366. /**
  21367. * Class used to store geometry data (vertex buffers + index buffer)
  21368. */
  21369. export class Geometry implements IGetSetVerticesData {
  21370. /**
  21371. * Gets or sets the ID of the geometry
  21372. */
  21373. id: string;
  21374. /**
  21375. * Gets or sets the unique ID of the geometry
  21376. */
  21377. uniqueId: number;
  21378. /**
  21379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21380. */
  21381. delayLoadState: number;
  21382. /**
  21383. * Gets the file containing the data to load when running in delay load state
  21384. */
  21385. delayLoadingFile: Nullable<string>;
  21386. /**
  21387. * Callback called when the geometry is updated
  21388. */
  21389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21390. private _scene;
  21391. private _engine;
  21392. private _meshes;
  21393. private _totalVertices;
  21394. /** @hidden */
  21395. _indices: IndicesArray;
  21396. /** @hidden */
  21397. _vertexBuffers: {
  21398. [key: string]: VertexBuffer;
  21399. };
  21400. private _isDisposed;
  21401. private _extend;
  21402. private _boundingBias;
  21403. /** @hidden */
  21404. _delayInfo: Array<string>;
  21405. private _indexBuffer;
  21406. private _indexBufferIsUpdatable;
  21407. /** @hidden */
  21408. _boundingInfo: Nullable<BoundingInfo>;
  21409. /** @hidden */
  21410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21411. /** @hidden */
  21412. _softwareSkinningFrameId: number;
  21413. private _vertexArrayObjects;
  21414. private _updatable;
  21415. /** @hidden */
  21416. _positions: Nullable<Vector3[]>;
  21417. /**
  21418. * 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
  21419. */
  21420. /**
  21421. * 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
  21422. */
  21423. boundingBias: Vector2;
  21424. /**
  21425. * Static function used to attach a new empty geometry to a mesh
  21426. * @param mesh defines the mesh to attach the geometry to
  21427. * @returns the new Geometry
  21428. */
  21429. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21430. /**
  21431. * Creates a new geometry
  21432. * @param id defines the unique ID
  21433. * @param scene defines the hosting scene
  21434. * @param vertexData defines the VertexData used to get geometry data
  21435. * @param updatable defines if geometry must be updatable (false by default)
  21436. * @param mesh defines the mesh that will be associated with the geometry
  21437. */
  21438. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21439. /**
  21440. * Gets the current extend of the geometry
  21441. */
  21442. readonly extend: {
  21443. minimum: Vector3;
  21444. maximum: Vector3;
  21445. };
  21446. /**
  21447. * Gets the hosting scene
  21448. * @returns the hosting Scene
  21449. */
  21450. getScene(): Scene;
  21451. /**
  21452. * Gets the hosting engine
  21453. * @returns the hosting Engine
  21454. */
  21455. getEngine(): Engine;
  21456. /**
  21457. * Defines if the geometry is ready to use
  21458. * @returns true if the geometry is ready to be used
  21459. */
  21460. isReady(): boolean;
  21461. /**
  21462. * Gets a value indicating that the geometry should not be serialized
  21463. */
  21464. readonly doNotSerialize: boolean;
  21465. /** @hidden */
  21466. _rebuild(): void;
  21467. /**
  21468. * Affects all geometry data in one call
  21469. * @param vertexData defines the geometry data
  21470. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21471. */
  21472. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21473. /**
  21474. * Set specific vertex data
  21475. * @param kind defines the data kind (Position, normal, etc...)
  21476. * @param data defines the vertex data to use
  21477. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21478. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21479. */
  21480. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21481. /**
  21482. * Removes a specific vertex data
  21483. * @param kind defines the data kind (Position, normal, etc...)
  21484. */
  21485. removeVerticesData(kind: string): void;
  21486. /**
  21487. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21488. * @param buffer defines the vertex buffer to use
  21489. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21490. */
  21491. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21492. /**
  21493. * Update a specific vertex buffer
  21494. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21495. * It will do nothing if the buffer is not updatable
  21496. * @param kind defines the data kind (Position, normal, etc...)
  21497. * @param data defines the data to use
  21498. * @param offset defines the offset in the target buffer where to store the data
  21499. * @param useBytes set to true if the offset is in bytes
  21500. */
  21501. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21502. /**
  21503. * Update a specific vertex buffer
  21504. * This function will create a new buffer if the current one is not updatable
  21505. * @param kind defines the data kind (Position, normal, etc...)
  21506. * @param data defines the data to use
  21507. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21508. */
  21509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21510. private _updateBoundingInfo;
  21511. /** @hidden */
  21512. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21513. /**
  21514. * Gets total number of vertices
  21515. * @returns the total number of vertices
  21516. */
  21517. getTotalVertices(): number;
  21518. /**
  21519. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21520. * @param kind defines the data kind (Position, normal, etc...)
  21521. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21522. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21523. * @returns a float array containing vertex data
  21524. */
  21525. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21526. /**
  21527. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21528. * @param kind defines the data kind (Position, normal, etc...)
  21529. * @returns true if the vertex buffer with the specified kind is updatable
  21530. */
  21531. isVertexBufferUpdatable(kind: string): boolean;
  21532. /**
  21533. * Gets a specific vertex buffer
  21534. * @param kind defines the data kind (Position, normal, etc...)
  21535. * @returns a VertexBuffer
  21536. */
  21537. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21538. /**
  21539. * Returns all vertex buffers
  21540. * @return an object holding all vertex buffers indexed by kind
  21541. */
  21542. getVertexBuffers(): Nullable<{
  21543. [key: string]: VertexBuffer;
  21544. }>;
  21545. /**
  21546. * Gets a boolean indicating if specific vertex buffer is present
  21547. * @param kind defines the data kind (Position, normal, etc...)
  21548. * @returns true if data is present
  21549. */
  21550. isVerticesDataPresent(kind: string): boolean;
  21551. /**
  21552. * Gets a list of all attached data kinds (Position, normal, etc...)
  21553. * @returns a list of string containing all kinds
  21554. */
  21555. getVerticesDataKinds(): string[];
  21556. /**
  21557. * Update index buffer
  21558. * @param indices defines the indices to store in the index buffer
  21559. * @param offset defines the offset in the target buffer where to store the data
  21560. * @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)
  21561. */
  21562. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21563. /**
  21564. * Creates a new index buffer
  21565. * @param indices defines the indices to store in the index buffer
  21566. * @param totalVertices defines the total number of vertices (could be null)
  21567. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21568. */
  21569. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21570. /**
  21571. * Return the total number of indices
  21572. * @returns the total number of indices
  21573. */
  21574. getTotalIndices(): number;
  21575. /**
  21576. * Gets the index buffer array
  21577. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21578. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21579. * @returns the index buffer array
  21580. */
  21581. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21582. /**
  21583. * Gets the index buffer
  21584. * @return the index buffer
  21585. */
  21586. getIndexBuffer(): Nullable<DataBuffer>;
  21587. /** @hidden */
  21588. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21589. /**
  21590. * Release the associated resources for a specific mesh
  21591. * @param mesh defines the source mesh
  21592. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21593. */
  21594. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21595. /**
  21596. * Apply current geometry to a given mesh
  21597. * @param mesh defines the mesh to apply geometry to
  21598. */
  21599. applyToMesh(mesh: Mesh): void;
  21600. private _updateExtend;
  21601. private _applyToMesh;
  21602. private notifyUpdate;
  21603. /**
  21604. * Load the geometry if it was flagged as delay loaded
  21605. * @param scene defines the hosting scene
  21606. * @param onLoaded defines a callback called when the geometry is loaded
  21607. */
  21608. load(scene: Scene, onLoaded?: () => void): void;
  21609. private _queueLoad;
  21610. /**
  21611. * Invert the geometry to move from a right handed system to a left handed one.
  21612. */
  21613. toLeftHanded(): void;
  21614. /** @hidden */
  21615. _resetPointsArrayCache(): void;
  21616. /** @hidden */
  21617. _generatePointsArray(): boolean;
  21618. /**
  21619. * Gets a value indicating if the geometry is disposed
  21620. * @returns true if the geometry was disposed
  21621. */
  21622. isDisposed(): boolean;
  21623. private _disposeVertexArrayObjects;
  21624. /**
  21625. * Free all associated resources
  21626. */
  21627. dispose(): void;
  21628. /**
  21629. * Clone the current geometry into a new geometry
  21630. * @param id defines the unique ID of the new geometry
  21631. * @returns a new geometry object
  21632. */
  21633. copy(id: string): Geometry;
  21634. /**
  21635. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21636. * @return a JSON representation of the current geometry data (without the vertices data)
  21637. */
  21638. serialize(): any;
  21639. private toNumberArray;
  21640. /**
  21641. * Serialize all vertices data into a JSON oject
  21642. * @returns a JSON representation of the current geometry data
  21643. */
  21644. serializeVerticeData(): any;
  21645. /**
  21646. * Extracts a clone of a mesh geometry
  21647. * @param mesh defines the source mesh
  21648. * @param id defines the unique ID of the new geometry object
  21649. * @returns the new geometry object
  21650. */
  21651. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21652. /**
  21653. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21654. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21655. * Be aware Math.random() could cause collisions, but:
  21656. * "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"
  21657. * @returns a string containing a new GUID
  21658. */
  21659. static RandomId(): string;
  21660. /** @hidden */
  21661. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21662. private static _CleanMatricesWeights;
  21663. /**
  21664. * Create a new geometry from persisted data (Using .babylon file format)
  21665. * @param parsedVertexData defines the persisted data
  21666. * @param scene defines the hosting scene
  21667. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21668. * @returns the new geometry object
  21669. */
  21670. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21671. }
  21672. }
  21673. declare module "babylonjs/Meshes/mesh.vertexData" {
  21674. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21675. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21676. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21677. import { Geometry } from "babylonjs/Meshes/geometry";
  21678. import { Mesh } from "babylonjs/Meshes/mesh";
  21679. /**
  21680. * Define an interface for all classes that will get and set the data on vertices
  21681. */
  21682. export interface IGetSetVerticesData {
  21683. /**
  21684. * Gets a boolean indicating if specific vertex data is present
  21685. * @param kind defines the vertex data kind to use
  21686. * @returns true is data kind is present
  21687. */
  21688. isVerticesDataPresent(kind: string): boolean;
  21689. /**
  21690. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21691. * @param kind defines the data kind (Position, normal, etc...)
  21692. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21694. * @returns a float array containing vertex data
  21695. */
  21696. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21697. /**
  21698. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21699. * @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.
  21700. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21701. * @returns the indices array or an empty array if the mesh has no geometry
  21702. */
  21703. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21704. /**
  21705. * Set specific vertex data
  21706. * @param kind defines the data kind (Position, normal, etc...)
  21707. * @param data defines the vertex data to use
  21708. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21709. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21710. */
  21711. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21712. /**
  21713. * Update a specific associated vertex buffer
  21714. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21715. * - VertexBuffer.PositionKind
  21716. * - VertexBuffer.UVKind
  21717. * - VertexBuffer.UV2Kind
  21718. * - VertexBuffer.UV3Kind
  21719. * - VertexBuffer.UV4Kind
  21720. * - VertexBuffer.UV5Kind
  21721. * - VertexBuffer.UV6Kind
  21722. * - VertexBuffer.ColorKind
  21723. * - VertexBuffer.MatricesIndicesKind
  21724. * - VertexBuffer.MatricesIndicesExtraKind
  21725. * - VertexBuffer.MatricesWeightsKind
  21726. * - VertexBuffer.MatricesWeightsExtraKind
  21727. * @param data defines the data source
  21728. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21729. * @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)
  21730. */
  21731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21732. /**
  21733. * Creates a new index buffer
  21734. * @param indices defines the indices to store in the index buffer
  21735. * @param totalVertices defines the total number of vertices (could be null)
  21736. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21737. */
  21738. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21739. }
  21740. /**
  21741. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21742. */
  21743. export class VertexData {
  21744. /**
  21745. * Mesh side orientation : usually the external or front surface
  21746. */
  21747. static readonly FRONTSIDE: number;
  21748. /**
  21749. * Mesh side orientation : usually the internal or back surface
  21750. */
  21751. static readonly BACKSIDE: number;
  21752. /**
  21753. * Mesh side orientation : both internal and external or front and back surfaces
  21754. */
  21755. static readonly DOUBLESIDE: number;
  21756. /**
  21757. * Mesh side orientation : by default, `FRONTSIDE`
  21758. */
  21759. static readonly DEFAULTSIDE: number;
  21760. /**
  21761. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21762. */
  21763. positions: Nullable<FloatArray>;
  21764. /**
  21765. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21766. */
  21767. normals: Nullable<FloatArray>;
  21768. /**
  21769. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21770. */
  21771. tangents: Nullable<FloatArray>;
  21772. /**
  21773. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs: Nullable<FloatArray>;
  21776. /**
  21777. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs2: Nullable<FloatArray>;
  21780. /**
  21781. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs3: Nullable<FloatArray>;
  21784. /**
  21785. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21786. */
  21787. uvs4: Nullable<FloatArray>;
  21788. /**
  21789. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21790. */
  21791. uvs5: Nullable<FloatArray>;
  21792. /**
  21793. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21794. */
  21795. uvs6: Nullable<FloatArray>;
  21796. /**
  21797. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21798. */
  21799. colors: Nullable<FloatArray>;
  21800. /**
  21801. * 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).
  21802. */
  21803. matricesIndices: Nullable<FloatArray>;
  21804. /**
  21805. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21806. */
  21807. matricesWeights: Nullable<FloatArray>;
  21808. /**
  21809. * An array extending the number of possible indices
  21810. */
  21811. matricesIndicesExtra: Nullable<FloatArray>;
  21812. /**
  21813. * An array extending the number of possible weights when the number of indices is extended
  21814. */
  21815. matricesWeightsExtra: Nullable<FloatArray>;
  21816. /**
  21817. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21818. */
  21819. indices: Nullable<IndicesArray>;
  21820. /**
  21821. * Uses the passed data array to set the set the values for the specified kind of data
  21822. * @param data a linear array of floating numbers
  21823. * @param kind the type of data that is being set, eg positions, colors etc
  21824. */
  21825. set(data: FloatArray, kind: string): void;
  21826. /**
  21827. * Associates the vertexData to the passed Mesh.
  21828. * Sets it as updatable or not (default `false`)
  21829. * @param mesh the mesh the vertexData is applied to
  21830. * @param updatable when used and having the value true allows new data to update the vertexData
  21831. * @returns the VertexData
  21832. */
  21833. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21834. /**
  21835. * Associates the vertexData to the passed Geometry.
  21836. * Sets it as updatable or not (default `false`)
  21837. * @param geometry the geometry the vertexData is applied to
  21838. * @param updatable when used and having the value true allows new data to update the vertexData
  21839. * @returns VertexData
  21840. */
  21841. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21842. /**
  21843. * Updates the associated mesh
  21844. * @param mesh the mesh to be updated
  21845. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21846. * @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
  21847. * @returns VertexData
  21848. */
  21849. updateMesh(mesh: Mesh): VertexData;
  21850. /**
  21851. * Updates the associated geometry
  21852. * @param geometry the geometry to be updated
  21853. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21854. * @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
  21855. * @returns VertexData.
  21856. */
  21857. updateGeometry(geometry: Geometry): VertexData;
  21858. private _applyTo;
  21859. private _update;
  21860. /**
  21861. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21862. * @param matrix the transforming matrix
  21863. * @returns the VertexData
  21864. */
  21865. transform(matrix: Matrix): VertexData;
  21866. /**
  21867. * Merges the passed VertexData into the current one
  21868. * @param other the VertexData to be merged into the current one
  21869. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21870. * @returns the modified VertexData
  21871. */
  21872. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21873. private _mergeElement;
  21874. private _validate;
  21875. /**
  21876. * Serializes the VertexData
  21877. * @returns a serialized object
  21878. */
  21879. serialize(): any;
  21880. /**
  21881. * Extracts the vertexData from a mesh
  21882. * @param mesh the mesh from which to extract the VertexData
  21883. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21884. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21885. * @returns the object VertexData associated to the passed mesh
  21886. */
  21887. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21888. /**
  21889. * Extracts the vertexData from the geometry
  21890. * @param geometry the geometry from which to extract the VertexData
  21891. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21892. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21893. * @returns the object VertexData associated to the passed mesh
  21894. */
  21895. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21896. private static _ExtractFrom;
  21897. /**
  21898. * Creates the VertexData for a Ribbon
  21899. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21900. * * pathArray array of paths, each of which an array of successive Vector3
  21901. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21902. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21903. * * 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
  21904. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21905. * * 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)
  21906. * * 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)
  21907. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21908. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21909. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21910. * @returns the VertexData of the ribbon
  21911. */
  21912. static CreateRibbon(options: {
  21913. pathArray: Vector3[][];
  21914. closeArray?: boolean;
  21915. closePath?: boolean;
  21916. offset?: number;
  21917. sideOrientation?: number;
  21918. frontUVs?: Vector4;
  21919. backUVs?: Vector4;
  21920. invertUV?: boolean;
  21921. uvs?: Vector2[];
  21922. colors?: Color4[];
  21923. }): VertexData;
  21924. /**
  21925. * Creates the VertexData for a box
  21926. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21927. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21928. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21929. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21930. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21931. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21932. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21934. * * 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)
  21935. * * 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)
  21936. * @returns the VertexData of the box
  21937. */
  21938. static CreateBox(options: {
  21939. size?: number;
  21940. width?: number;
  21941. height?: number;
  21942. depth?: number;
  21943. faceUV?: Vector4[];
  21944. faceColors?: Color4[];
  21945. sideOrientation?: number;
  21946. frontUVs?: Vector4;
  21947. backUVs?: Vector4;
  21948. }): VertexData;
  21949. /**
  21950. * Creates the VertexData for a tiled box
  21951. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21952. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21953. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21954. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21956. * @returns the VertexData of the box
  21957. */
  21958. static CreateTiledBox(options: {
  21959. pattern?: number;
  21960. width?: number;
  21961. height?: number;
  21962. depth?: number;
  21963. tileSize?: number;
  21964. tileWidth?: number;
  21965. tileHeight?: number;
  21966. alignHorizontal?: number;
  21967. alignVertical?: number;
  21968. faceUV?: Vector4[];
  21969. faceColors?: Color4[];
  21970. sideOrientation?: number;
  21971. }): VertexData;
  21972. /**
  21973. * Creates the VertexData for a tiled plane
  21974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21975. * * pattern a limited pattern arrangement depending on the number
  21976. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21977. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21978. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21979. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21980. * * 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)
  21981. * * 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)
  21982. * @returns the VertexData of the tiled plane
  21983. */
  21984. static CreateTiledPlane(options: {
  21985. pattern?: number;
  21986. tileSize?: number;
  21987. tileWidth?: number;
  21988. tileHeight?: number;
  21989. size?: number;
  21990. width?: number;
  21991. height?: number;
  21992. alignHorizontal?: number;
  21993. alignVertical?: number;
  21994. sideOrientation?: number;
  21995. frontUVs?: Vector4;
  21996. backUVs?: Vector4;
  21997. }): VertexData;
  21998. /**
  21999. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22001. * * segments sets the number of horizontal strips optional, default 32
  22002. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22003. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22004. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22005. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22006. * * 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
  22007. * * 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
  22008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22009. * * 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)
  22010. * * 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)
  22011. * @returns the VertexData of the ellipsoid
  22012. */
  22013. static CreateSphere(options: {
  22014. segments?: number;
  22015. diameter?: number;
  22016. diameterX?: number;
  22017. diameterY?: number;
  22018. diameterZ?: number;
  22019. arc?: number;
  22020. slice?: number;
  22021. sideOrientation?: number;
  22022. frontUVs?: Vector4;
  22023. backUVs?: Vector4;
  22024. }): VertexData;
  22025. /**
  22026. * Creates the VertexData for a cylinder, cone or prism
  22027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22028. * * height sets the height (y direction) of the cylinder, optional, default 2
  22029. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22030. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22031. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22032. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22033. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22034. * * 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
  22035. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22036. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22037. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22038. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22040. * * 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)
  22041. * * 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)
  22042. * @returns the VertexData of the cylinder, cone or prism
  22043. */
  22044. static CreateCylinder(options: {
  22045. height?: number;
  22046. diameterTop?: number;
  22047. diameterBottom?: number;
  22048. diameter?: number;
  22049. tessellation?: number;
  22050. subdivisions?: number;
  22051. arc?: number;
  22052. faceColors?: Color4[];
  22053. faceUV?: Vector4[];
  22054. hasRings?: boolean;
  22055. enclose?: boolean;
  22056. sideOrientation?: number;
  22057. frontUVs?: Vector4;
  22058. backUVs?: Vector4;
  22059. }): VertexData;
  22060. /**
  22061. * Creates the VertexData for a torus
  22062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22063. * * diameter the diameter of the torus, optional default 1
  22064. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22065. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22067. * * 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)
  22068. * * 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)
  22069. * @returns the VertexData of the torus
  22070. */
  22071. static CreateTorus(options: {
  22072. diameter?: number;
  22073. thickness?: number;
  22074. tessellation?: number;
  22075. sideOrientation?: number;
  22076. frontUVs?: Vector4;
  22077. backUVs?: Vector4;
  22078. }): VertexData;
  22079. /**
  22080. * Creates the VertexData of the LineSystem
  22081. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22082. * - lines an array of lines, each line being an array of successive Vector3
  22083. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22084. * @returns the VertexData of the LineSystem
  22085. */
  22086. static CreateLineSystem(options: {
  22087. lines: Vector3[][];
  22088. colors?: Nullable<Color4[][]>;
  22089. }): VertexData;
  22090. /**
  22091. * Create the VertexData for a DashedLines
  22092. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22093. * - points an array successive Vector3
  22094. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22095. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22096. * - dashNb the intended total number of dashes, optional, default 200
  22097. * @returns the VertexData for the DashedLines
  22098. */
  22099. static CreateDashedLines(options: {
  22100. points: Vector3[];
  22101. dashSize?: number;
  22102. gapSize?: number;
  22103. dashNb?: number;
  22104. }): VertexData;
  22105. /**
  22106. * Creates the VertexData for a Ground
  22107. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22108. * - width the width (x direction) of the ground, optional, default 1
  22109. * - height the height (z direction) of the ground, optional, default 1
  22110. * - subdivisions the number of subdivisions per side, optional, default 1
  22111. * @returns the VertexData of the Ground
  22112. */
  22113. static CreateGround(options: {
  22114. width?: number;
  22115. height?: number;
  22116. subdivisions?: number;
  22117. subdivisionsX?: number;
  22118. subdivisionsY?: number;
  22119. }): VertexData;
  22120. /**
  22121. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22122. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22123. * * xmin the ground minimum X coordinate, optional, default -1
  22124. * * zmin the ground minimum Z coordinate, optional, default -1
  22125. * * xmax the ground maximum X coordinate, optional, default 1
  22126. * * zmax the ground maximum Z coordinate, optional, default 1
  22127. * * 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}
  22128. * * 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}
  22129. * @returns the VertexData of the TiledGround
  22130. */
  22131. static CreateTiledGround(options: {
  22132. xmin: number;
  22133. zmin: number;
  22134. xmax: number;
  22135. zmax: number;
  22136. subdivisions?: {
  22137. w: number;
  22138. h: number;
  22139. };
  22140. precision?: {
  22141. w: number;
  22142. h: number;
  22143. };
  22144. }): VertexData;
  22145. /**
  22146. * Creates the VertexData of the Ground designed from a heightmap
  22147. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22148. * * width the width (x direction) of the ground
  22149. * * height the height (z direction) of the ground
  22150. * * subdivisions the number of subdivisions per side
  22151. * * minHeight the minimum altitude on the ground, optional, default 0
  22152. * * maxHeight the maximum altitude on the ground, optional default 1
  22153. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22154. * * buffer the array holding the image color data
  22155. * * bufferWidth the width of image
  22156. * * bufferHeight the height of image
  22157. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22158. * @returns the VertexData of the Ground designed from a heightmap
  22159. */
  22160. static CreateGroundFromHeightMap(options: {
  22161. width: number;
  22162. height: number;
  22163. subdivisions: number;
  22164. minHeight: number;
  22165. maxHeight: number;
  22166. colorFilter: Color3;
  22167. buffer: Uint8Array;
  22168. bufferWidth: number;
  22169. bufferHeight: number;
  22170. alphaFilter: number;
  22171. }): VertexData;
  22172. /**
  22173. * Creates the VertexData for a Plane
  22174. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22175. * * size sets the width and height of the plane to the value of size, optional default 1
  22176. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22177. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22179. * * 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)
  22180. * * 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)
  22181. * @returns the VertexData of the box
  22182. */
  22183. static CreatePlane(options: {
  22184. size?: number;
  22185. width?: number;
  22186. height?: number;
  22187. sideOrientation?: number;
  22188. frontUVs?: Vector4;
  22189. backUVs?: Vector4;
  22190. }): VertexData;
  22191. /**
  22192. * Creates the VertexData of the Disc or regular Polygon
  22193. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22194. * * radius the radius of the disc, optional default 0.5
  22195. * * tessellation the number of polygon sides, optional, default 64
  22196. * * 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
  22197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22198. * * 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)
  22199. * * 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)
  22200. * @returns the VertexData of the box
  22201. */
  22202. static CreateDisc(options: {
  22203. radius?: number;
  22204. tessellation?: number;
  22205. arc?: number;
  22206. sideOrientation?: number;
  22207. frontUVs?: Vector4;
  22208. backUVs?: Vector4;
  22209. }): VertexData;
  22210. /**
  22211. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22212. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22213. * @param polygon a mesh built from polygonTriangulation.build()
  22214. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22216. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22217. * @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)
  22218. * @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)
  22219. * @returns the VertexData of the Polygon
  22220. */
  22221. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22222. /**
  22223. * Creates the VertexData of the IcoSphere
  22224. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22225. * * radius the radius of the IcoSphere, optional default 1
  22226. * * radiusX allows stretching in the x direction, optional, default radius
  22227. * * radiusY allows stretching in the y direction, optional, default radius
  22228. * * radiusZ allows stretching in the z direction, optional, default radius
  22229. * * flat when true creates a flat shaded mesh, optional, default true
  22230. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22232. * * 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)
  22233. * * 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)
  22234. * @returns the VertexData of the IcoSphere
  22235. */
  22236. static CreateIcoSphere(options: {
  22237. radius?: number;
  22238. radiusX?: number;
  22239. radiusY?: number;
  22240. radiusZ?: number;
  22241. flat?: boolean;
  22242. subdivisions?: number;
  22243. sideOrientation?: number;
  22244. frontUVs?: Vector4;
  22245. backUVs?: Vector4;
  22246. }): VertexData;
  22247. /**
  22248. * Creates the VertexData for a Polyhedron
  22249. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22250. * * type provided types are:
  22251. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22252. * * 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)
  22253. * * size the size of the IcoSphere, optional default 1
  22254. * * sizeX allows stretching in the x direction, optional, default size
  22255. * * sizeY allows stretching in the y direction, optional, default size
  22256. * * sizeZ allows stretching in the z direction, optional, default size
  22257. * * 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
  22258. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22259. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22260. * * flat when true creates a flat shaded mesh, optional, default true
  22261. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22262. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22263. * * 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)
  22264. * * 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)
  22265. * @returns the VertexData of the Polyhedron
  22266. */
  22267. static CreatePolyhedron(options: {
  22268. type?: number;
  22269. size?: number;
  22270. sizeX?: number;
  22271. sizeY?: number;
  22272. sizeZ?: number;
  22273. custom?: any;
  22274. faceUV?: Vector4[];
  22275. faceColors?: Color4[];
  22276. flat?: boolean;
  22277. sideOrientation?: number;
  22278. frontUVs?: Vector4;
  22279. backUVs?: Vector4;
  22280. }): VertexData;
  22281. /**
  22282. * Creates the VertexData for a TorusKnot
  22283. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22284. * * radius the radius of the torus knot, optional, default 2
  22285. * * tube the thickness of the tube, optional, default 0.5
  22286. * * radialSegments the number of sides on each tube segments, optional, default 32
  22287. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22288. * * p the number of windings around the z axis, optional, default 2
  22289. * * q the number of windings around the x axis, optional, default 3
  22290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22291. * * 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)
  22292. * * 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)
  22293. * @returns the VertexData of the Torus Knot
  22294. */
  22295. static CreateTorusKnot(options: {
  22296. radius?: number;
  22297. tube?: number;
  22298. radialSegments?: number;
  22299. tubularSegments?: number;
  22300. p?: number;
  22301. q?: number;
  22302. sideOrientation?: number;
  22303. frontUVs?: Vector4;
  22304. backUVs?: Vector4;
  22305. }): VertexData;
  22306. /**
  22307. * Compute normals for given positions and indices
  22308. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22309. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22310. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22311. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22312. * * facetNormals : optional array of facet normals (vector3)
  22313. * * facetPositions : optional array of facet positions (vector3)
  22314. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22315. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22316. * * bInfo : optional bounding info, required for facetPartitioning computation
  22317. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22318. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22319. * * useRightHandedSystem: optional boolean to for right handed system computation
  22320. * * depthSort : optional boolean to enable the facet depth sort computation
  22321. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22322. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22323. */
  22324. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22325. facetNormals?: any;
  22326. facetPositions?: any;
  22327. facetPartitioning?: any;
  22328. ratio?: number;
  22329. bInfo?: any;
  22330. bbSize?: Vector3;
  22331. subDiv?: any;
  22332. useRightHandedSystem?: boolean;
  22333. depthSort?: boolean;
  22334. distanceTo?: Vector3;
  22335. depthSortedFacets?: any;
  22336. }): void;
  22337. /** @hidden */
  22338. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22339. /**
  22340. * Applies VertexData created from the imported parameters to the geometry
  22341. * @param parsedVertexData the parsed data from an imported file
  22342. * @param geometry the geometry to apply the VertexData to
  22343. */
  22344. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22345. }
  22346. }
  22347. declare module "babylonjs/Morph/morphTarget" {
  22348. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22349. import { Observable } from "babylonjs/Misc/observable";
  22350. import { Nullable, FloatArray } from "babylonjs/types";
  22351. import { Scene } from "babylonjs/scene";
  22352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22353. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22354. /**
  22355. * Defines a target to use with MorphTargetManager
  22356. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22357. */
  22358. export class MorphTarget implements IAnimatable {
  22359. /** defines the name of the target */
  22360. name: string;
  22361. /**
  22362. * Gets or sets the list of animations
  22363. */
  22364. animations: import("babylonjs/Animations/animation").Animation[];
  22365. private _scene;
  22366. private _positions;
  22367. private _normals;
  22368. private _tangents;
  22369. private _uvs;
  22370. private _influence;
  22371. /**
  22372. * Observable raised when the influence changes
  22373. */
  22374. onInfluenceChanged: Observable<boolean>;
  22375. /** @hidden */
  22376. _onDataLayoutChanged: Observable<void>;
  22377. /**
  22378. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22379. */
  22380. influence: number;
  22381. /**
  22382. * Gets or sets the id of the morph Target
  22383. */
  22384. id: string;
  22385. private _animationPropertiesOverride;
  22386. /**
  22387. * Gets or sets the animation properties override
  22388. */
  22389. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22390. /**
  22391. * Creates a new MorphTarget
  22392. * @param name defines the name of the target
  22393. * @param influence defines the influence to use
  22394. * @param scene defines the scene the morphtarget belongs to
  22395. */
  22396. constructor(
  22397. /** defines the name of the target */
  22398. name: string, influence?: number, scene?: Nullable<Scene>);
  22399. /**
  22400. * Gets a boolean defining if the target contains position data
  22401. */
  22402. readonly hasPositions: boolean;
  22403. /**
  22404. * Gets a boolean defining if the target contains normal data
  22405. */
  22406. readonly hasNormals: boolean;
  22407. /**
  22408. * Gets a boolean defining if the target contains tangent data
  22409. */
  22410. readonly hasTangents: boolean;
  22411. /**
  22412. * Gets a boolean defining if the target contains texture coordinates data
  22413. */
  22414. readonly hasUVs: boolean;
  22415. /**
  22416. * Affects position data to this target
  22417. * @param data defines the position data to use
  22418. */
  22419. setPositions(data: Nullable<FloatArray>): void;
  22420. /**
  22421. * Gets the position data stored in this target
  22422. * @returns a FloatArray containing the position data (or null if not present)
  22423. */
  22424. getPositions(): Nullable<FloatArray>;
  22425. /**
  22426. * Affects normal data to this target
  22427. * @param data defines the normal data to use
  22428. */
  22429. setNormals(data: Nullable<FloatArray>): void;
  22430. /**
  22431. * Gets the normal data stored in this target
  22432. * @returns a FloatArray containing the normal data (or null if not present)
  22433. */
  22434. getNormals(): Nullable<FloatArray>;
  22435. /**
  22436. * Affects tangent data to this target
  22437. * @param data defines the tangent data to use
  22438. */
  22439. setTangents(data: Nullable<FloatArray>): void;
  22440. /**
  22441. * Gets the tangent data stored in this target
  22442. * @returns a FloatArray containing the tangent data (or null if not present)
  22443. */
  22444. getTangents(): Nullable<FloatArray>;
  22445. /**
  22446. * Affects texture coordinates data to this target
  22447. * @param data defines the texture coordinates data to use
  22448. */
  22449. setUVs(data: Nullable<FloatArray>): void;
  22450. /**
  22451. * Gets the texture coordinates data stored in this target
  22452. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22453. */
  22454. getUVs(): Nullable<FloatArray>;
  22455. /**
  22456. * Serializes the current target into a Serialization object
  22457. * @returns the serialized object
  22458. */
  22459. serialize(): any;
  22460. /**
  22461. * Returns the string "MorphTarget"
  22462. * @returns "MorphTarget"
  22463. */
  22464. getClassName(): string;
  22465. /**
  22466. * Creates a new target from serialized data
  22467. * @param serializationObject defines the serialized data to use
  22468. * @returns a new MorphTarget
  22469. */
  22470. static Parse(serializationObject: any): MorphTarget;
  22471. /**
  22472. * Creates a MorphTarget from mesh data
  22473. * @param mesh defines the source mesh
  22474. * @param name defines the name to use for the new target
  22475. * @param influence defines the influence to attach to the target
  22476. * @returns a new MorphTarget
  22477. */
  22478. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22479. }
  22480. }
  22481. declare module "babylonjs/Morph/morphTargetManager" {
  22482. import { Nullable } from "babylonjs/types";
  22483. import { Scene } from "babylonjs/scene";
  22484. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22485. /**
  22486. * This class is used to deform meshes using morphing between different targets
  22487. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22488. */
  22489. export class MorphTargetManager {
  22490. private _targets;
  22491. private _targetInfluenceChangedObservers;
  22492. private _targetDataLayoutChangedObservers;
  22493. private _activeTargets;
  22494. private _scene;
  22495. private _influences;
  22496. private _supportsNormals;
  22497. private _supportsTangents;
  22498. private _supportsUVs;
  22499. private _vertexCount;
  22500. private _uniqueId;
  22501. private _tempInfluences;
  22502. /**
  22503. * Gets or sets a boolean indicating if normals must be morphed
  22504. */
  22505. enableNormalMorphing: boolean;
  22506. /**
  22507. * Gets or sets a boolean indicating if tangents must be morphed
  22508. */
  22509. enableTangentMorphing: boolean;
  22510. /**
  22511. * Gets or sets a boolean indicating if UV must be morphed
  22512. */
  22513. enableUVMorphing: boolean;
  22514. /**
  22515. * Creates a new MorphTargetManager
  22516. * @param scene defines the current scene
  22517. */
  22518. constructor(scene?: Nullable<Scene>);
  22519. /**
  22520. * Gets the unique ID of this manager
  22521. */
  22522. readonly uniqueId: number;
  22523. /**
  22524. * Gets the number of vertices handled by this manager
  22525. */
  22526. readonly vertexCount: number;
  22527. /**
  22528. * Gets a boolean indicating if this manager supports morphing of normals
  22529. */
  22530. readonly supportsNormals: boolean;
  22531. /**
  22532. * Gets a boolean indicating if this manager supports morphing of tangents
  22533. */
  22534. readonly supportsTangents: boolean;
  22535. /**
  22536. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22537. */
  22538. readonly supportsUVs: boolean;
  22539. /**
  22540. * Gets the number of targets stored in this manager
  22541. */
  22542. readonly numTargets: number;
  22543. /**
  22544. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22545. */
  22546. readonly numInfluencers: number;
  22547. /**
  22548. * Gets the list of influences (one per target)
  22549. */
  22550. readonly influences: Float32Array;
  22551. /**
  22552. * Gets the active target at specified index. An active target is a target with an influence > 0
  22553. * @param index defines the index to check
  22554. * @returns the requested target
  22555. */
  22556. getActiveTarget(index: number): MorphTarget;
  22557. /**
  22558. * Gets the target at specified index
  22559. * @param index defines the index to check
  22560. * @returns the requested target
  22561. */
  22562. getTarget(index: number): MorphTarget;
  22563. /**
  22564. * Add a new target to this manager
  22565. * @param target defines the target to add
  22566. */
  22567. addTarget(target: MorphTarget): void;
  22568. /**
  22569. * Removes a target from the manager
  22570. * @param target defines the target to remove
  22571. */
  22572. removeTarget(target: MorphTarget): void;
  22573. /**
  22574. * Serializes the current manager into a Serialization object
  22575. * @returns the serialized object
  22576. */
  22577. serialize(): any;
  22578. private _syncActiveTargets;
  22579. /**
  22580. * Syncrhonize the targets with all the meshes using this morph target manager
  22581. */
  22582. synchronize(): void;
  22583. /**
  22584. * Creates a new MorphTargetManager from serialized data
  22585. * @param serializationObject defines the serialized data
  22586. * @param scene defines the hosting scene
  22587. * @returns the new MorphTargetManager
  22588. */
  22589. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22590. }
  22591. }
  22592. declare module "babylonjs/Meshes/meshLODLevel" {
  22593. import { Mesh } from "babylonjs/Meshes/mesh";
  22594. import { Nullable } from "babylonjs/types";
  22595. /**
  22596. * Class used to represent a specific level of detail of a mesh
  22597. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22598. */
  22599. export class MeshLODLevel {
  22600. /** Defines the distance where this level should star being displayed */
  22601. distance: number;
  22602. /** Defines the mesh to use to render this level */
  22603. mesh: Nullable<Mesh>;
  22604. /**
  22605. * Creates a new LOD level
  22606. * @param distance defines the distance where this level should star being displayed
  22607. * @param mesh defines the mesh to use to render this level
  22608. */
  22609. constructor(
  22610. /** Defines the distance where this level should star being displayed */
  22611. distance: number,
  22612. /** Defines the mesh to use to render this level */
  22613. mesh: Nullable<Mesh>);
  22614. }
  22615. }
  22616. declare module "babylonjs/Meshes/groundMesh" {
  22617. import { Scene } from "babylonjs/scene";
  22618. import { Vector3 } from "babylonjs/Maths/math.vector";
  22619. import { Mesh } from "babylonjs/Meshes/mesh";
  22620. /**
  22621. * Mesh representing the gorund
  22622. */
  22623. export class GroundMesh extends Mesh {
  22624. /** If octree should be generated */
  22625. generateOctree: boolean;
  22626. private _heightQuads;
  22627. /** @hidden */
  22628. _subdivisionsX: number;
  22629. /** @hidden */
  22630. _subdivisionsY: number;
  22631. /** @hidden */
  22632. _width: number;
  22633. /** @hidden */
  22634. _height: number;
  22635. /** @hidden */
  22636. _minX: number;
  22637. /** @hidden */
  22638. _maxX: number;
  22639. /** @hidden */
  22640. _minZ: number;
  22641. /** @hidden */
  22642. _maxZ: number;
  22643. constructor(name: string, scene: Scene);
  22644. /**
  22645. * "GroundMesh"
  22646. * @returns "GroundMesh"
  22647. */
  22648. getClassName(): string;
  22649. /**
  22650. * The minimum of x and y subdivisions
  22651. */
  22652. readonly subdivisions: number;
  22653. /**
  22654. * X subdivisions
  22655. */
  22656. readonly subdivisionsX: number;
  22657. /**
  22658. * Y subdivisions
  22659. */
  22660. readonly subdivisionsY: number;
  22661. /**
  22662. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22663. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22664. * @param chunksCount the number of subdivisions for x and y
  22665. * @param octreeBlocksSize (Default: 32)
  22666. */
  22667. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22668. /**
  22669. * Returns a height (y) value in the Worl system :
  22670. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22671. * @param x x coordinate
  22672. * @param z z coordinate
  22673. * @returns the ground y position if (x, z) are outside the ground surface.
  22674. */
  22675. getHeightAtCoordinates(x: number, z: number): number;
  22676. /**
  22677. * Returns a normalized vector (Vector3) orthogonal to the ground
  22678. * at the ground coordinates (x, z) expressed in the World system.
  22679. * @param x x coordinate
  22680. * @param z z coordinate
  22681. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22682. */
  22683. getNormalAtCoordinates(x: number, z: number): Vector3;
  22684. /**
  22685. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22686. * at the ground coordinates (x, z) expressed in the World system.
  22687. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22688. * @param x x coordinate
  22689. * @param z z coordinate
  22690. * @param ref vector to store the result
  22691. * @returns the GroundMesh.
  22692. */
  22693. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22694. /**
  22695. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22696. * if the ground has been updated.
  22697. * This can be used in the render loop.
  22698. * @returns the GroundMesh.
  22699. */
  22700. updateCoordinateHeights(): GroundMesh;
  22701. private _getFacetAt;
  22702. private _initHeightQuads;
  22703. private _computeHeightQuads;
  22704. /**
  22705. * Serializes this ground mesh
  22706. * @param serializationObject object to write serialization to
  22707. */
  22708. serialize(serializationObject: any): void;
  22709. /**
  22710. * Parses a serialized ground mesh
  22711. * @param parsedMesh the serialized mesh
  22712. * @param scene the scene to create the ground mesh in
  22713. * @returns the created ground mesh
  22714. */
  22715. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22716. }
  22717. }
  22718. declare module "babylonjs/Physics/physicsJoint" {
  22719. import { Vector3 } from "babylonjs/Maths/math.vector";
  22720. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22721. /**
  22722. * Interface for Physics-Joint data
  22723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22724. */
  22725. export interface PhysicsJointData {
  22726. /**
  22727. * The main pivot of the joint
  22728. */
  22729. mainPivot?: Vector3;
  22730. /**
  22731. * The connected pivot of the joint
  22732. */
  22733. connectedPivot?: Vector3;
  22734. /**
  22735. * The main axis of the joint
  22736. */
  22737. mainAxis?: Vector3;
  22738. /**
  22739. * The connected axis of the joint
  22740. */
  22741. connectedAxis?: Vector3;
  22742. /**
  22743. * The collision of the joint
  22744. */
  22745. collision?: boolean;
  22746. /**
  22747. * Native Oimo/Cannon/Energy data
  22748. */
  22749. nativeParams?: any;
  22750. }
  22751. /**
  22752. * This is a holder class for the physics joint created by the physics plugin
  22753. * It holds a set of functions to control the underlying joint
  22754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22755. */
  22756. export class PhysicsJoint {
  22757. /**
  22758. * The type of the physics joint
  22759. */
  22760. type: number;
  22761. /**
  22762. * The data for the physics joint
  22763. */
  22764. jointData: PhysicsJointData;
  22765. private _physicsJoint;
  22766. protected _physicsPlugin: IPhysicsEnginePlugin;
  22767. /**
  22768. * Initializes the physics joint
  22769. * @param type The type of the physics joint
  22770. * @param jointData The data for the physics joint
  22771. */
  22772. constructor(
  22773. /**
  22774. * The type of the physics joint
  22775. */
  22776. type: number,
  22777. /**
  22778. * The data for the physics joint
  22779. */
  22780. jointData: PhysicsJointData);
  22781. /**
  22782. * Gets the physics joint
  22783. */
  22784. /**
  22785. * Sets the physics joint
  22786. */
  22787. physicsJoint: any;
  22788. /**
  22789. * Sets the physics plugin
  22790. */
  22791. physicsPlugin: IPhysicsEnginePlugin;
  22792. /**
  22793. * Execute a function that is physics-plugin specific.
  22794. * @param {Function} func the function that will be executed.
  22795. * It accepts two parameters: the physics world and the physics joint
  22796. */
  22797. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22798. /**
  22799. * Distance-Joint type
  22800. */
  22801. static DistanceJoint: number;
  22802. /**
  22803. * Hinge-Joint type
  22804. */
  22805. static HingeJoint: number;
  22806. /**
  22807. * Ball-and-Socket joint type
  22808. */
  22809. static BallAndSocketJoint: number;
  22810. /**
  22811. * Wheel-Joint type
  22812. */
  22813. static WheelJoint: number;
  22814. /**
  22815. * Slider-Joint type
  22816. */
  22817. static SliderJoint: number;
  22818. /**
  22819. * Prismatic-Joint type
  22820. */
  22821. static PrismaticJoint: number;
  22822. /**
  22823. * Universal-Joint type
  22824. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22825. */
  22826. static UniversalJoint: number;
  22827. /**
  22828. * Hinge-Joint 2 type
  22829. */
  22830. static Hinge2Joint: number;
  22831. /**
  22832. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22833. */
  22834. static PointToPointJoint: number;
  22835. /**
  22836. * Spring-Joint type
  22837. */
  22838. static SpringJoint: number;
  22839. /**
  22840. * Lock-Joint type
  22841. */
  22842. static LockJoint: number;
  22843. }
  22844. /**
  22845. * A class representing a physics distance joint
  22846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22847. */
  22848. export class DistanceJoint extends PhysicsJoint {
  22849. /**
  22850. *
  22851. * @param jointData The data for the Distance-Joint
  22852. */
  22853. constructor(jointData: DistanceJointData);
  22854. /**
  22855. * Update the predefined distance.
  22856. * @param maxDistance The maximum preferred distance
  22857. * @param minDistance The minimum preferred distance
  22858. */
  22859. updateDistance(maxDistance: number, minDistance?: number): void;
  22860. }
  22861. /**
  22862. * Represents a Motor-Enabled Joint
  22863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22864. */
  22865. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22866. /**
  22867. * Initializes the Motor-Enabled Joint
  22868. * @param type The type of the joint
  22869. * @param jointData The physica joint data for the joint
  22870. */
  22871. constructor(type: number, jointData: PhysicsJointData);
  22872. /**
  22873. * Set the motor values.
  22874. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22875. * @param force the force to apply
  22876. * @param maxForce max force for this motor.
  22877. */
  22878. setMotor(force?: number, maxForce?: number): void;
  22879. /**
  22880. * Set the motor's limits.
  22881. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22882. * @param upperLimit The upper limit of the motor
  22883. * @param lowerLimit The lower limit of the motor
  22884. */
  22885. setLimit(upperLimit: number, lowerLimit?: number): void;
  22886. }
  22887. /**
  22888. * This class represents a single physics Hinge-Joint
  22889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22890. */
  22891. export class HingeJoint extends MotorEnabledJoint {
  22892. /**
  22893. * Initializes the Hinge-Joint
  22894. * @param jointData The joint data for the Hinge-Joint
  22895. */
  22896. constructor(jointData: PhysicsJointData);
  22897. /**
  22898. * Set the motor values.
  22899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22900. * @param {number} force the force to apply
  22901. * @param {number} maxForce max force for this motor.
  22902. */
  22903. setMotor(force?: number, maxForce?: number): void;
  22904. /**
  22905. * Set the motor's limits.
  22906. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22907. * @param upperLimit The upper limit of the motor
  22908. * @param lowerLimit The lower limit of the motor
  22909. */
  22910. setLimit(upperLimit: number, lowerLimit?: number): void;
  22911. }
  22912. /**
  22913. * This class represents a dual hinge physics joint (same as wheel joint)
  22914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22915. */
  22916. export class Hinge2Joint extends MotorEnabledJoint {
  22917. /**
  22918. * Initializes the Hinge2-Joint
  22919. * @param jointData The joint data for the Hinge2-Joint
  22920. */
  22921. constructor(jointData: PhysicsJointData);
  22922. /**
  22923. * Set the motor values.
  22924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22925. * @param {number} targetSpeed the speed the motor is to reach
  22926. * @param {number} maxForce max force for this motor.
  22927. * @param {motorIndex} the motor's index, 0 or 1.
  22928. */
  22929. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22930. /**
  22931. * Set the motor limits.
  22932. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22933. * @param {number} upperLimit the upper limit
  22934. * @param {number} lowerLimit lower limit
  22935. * @param {motorIndex} the motor's index, 0 or 1.
  22936. */
  22937. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22938. }
  22939. /**
  22940. * Interface for a motor enabled joint
  22941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22942. */
  22943. export interface IMotorEnabledJoint {
  22944. /**
  22945. * Physics joint
  22946. */
  22947. physicsJoint: any;
  22948. /**
  22949. * Sets the motor of the motor-enabled joint
  22950. * @param force The force of the motor
  22951. * @param maxForce The maximum force of the motor
  22952. * @param motorIndex The index of the motor
  22953. */
  22954. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22955. /**
  22956. * Sets the limit of the motor
  22957. * @param upperLimit The upper limit of the motor
  22958. * @param lowerLimit The lower limit of the motor
  22959. * @param motorIndex The index of the motor
  22960. */
  22961. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22962. }
  22963. /**
  22964. * Joint data for a Distance-Joint
  22965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22966. */
  22967. export interface DistanceJointData extends PhysicsJointData {
  22968. /**
  22969. * Max distance the 2 joint objects can be apart
  22970. */
  22971. maxDistance: number;
  22972. }
  22973. /**
  22974. * Joint data from a spring joint
  22975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22976. */
  22977. export interface SpringJointData extends PhysicsJointData {
  22978. /**
  22979. * Length of the spring
  22980. */
  22981. length: number;
  22982. /**
  22983. * Stiffness of the spring
  22984. */
  22985. stiffness: number;
  22986. /**
  22987. * Damping of the spring
  22988. */
  22989. damping: number;
  22990. /** this callback will be called when applying the force to the impostors. */
  22991. forceApplicationCallback: () => void;
  22992. }
  22993. }
  22994. declare module "babylonjs/Physics/physicsRaycastResult" {
  22995. import { Vector3 } from "babylonjs/Maths/math.vector";
  22996. /**
  22997. * Holds the data for the raycast result
  22998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22999. */
  23000. export class PhysicsRaycastResult {
  23001. private _hasHit;
  23002. private _hitDistance;
  23003. private _hitNormalWorld;
  23004. private _hitPointWorld;
  23005. private _rayFromWorld;
  23006. private _rayToWorld;
  23007. /**
  23008. * Gets if there was a hit
  23009. */
  23010. readonly hasHit: boolean;
  23011. /**
  23012. * Gets the distance from the hit
  23013. */
  23014. readonly hitDistance: number;
  23015. /**
  23016. * Gets the hit normal/direction in the world
  23017. */
  23018. readonly hitNormalWorld: Vector3;
  23019. /**
  23020. * Gets the hit point in the world
  23021. */
  23022. readonly hitPointWorld: Vector3;
  23023. /**
  23024. * Gets the ray "start point" of the ray in the world
  23025. */
  23026. readonly rayFromWorld: Vector3;
  23027. /**
  23028. * Gets the ray "end point" of the ray in the world
  23029. */
  23030. readonly rayToWorld: Vector3;
  23031. /**
  23032. * Sets the hit data (normal & point in world space)
  23033. * @param hitNormalWorld defines the normal in world space
  23034. * @param hitPointWorld defines the point in world space
  23035. */
  23036. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23037. /**
  23038. * Sets the distance from the start point to the hit point
  23039. * @param distance
  23040. */
  23041. setHitDistance(distance: number): void;
  23042. /**
  23043. * Calculates the distance manually
  23044. */
  23045. calculateHitDistance(): void;
  23046. /**
  23047. * Resets all the values to default
  23048. * @param from The from point on world space
  23049. * @param to The to point on world space
  23050. */
  23051. reset(from?: Vector3, to?: Vector3): void;
  23052. }
  23053. /**
  23054. * Interface for the size containing width and height
  23055. */
  23056. interface IXYZ {
  23057. /**
  23058. * X
  23059. */
  23060. x: number;
  23061. /**
  23062. * Y
  23063. */
  23064. y: number;
  23065. /**
  23066. * Z
  23067. */
  23068. z: number;
  23069. }
  23070. }
  23071. declare module "babylonjs/Physics/IPhysicsEngine" {
  23072. import { Nullable } from "babylonjs/types";
  23073. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23075. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23076. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23077. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23078. /**
  23079. * Interface used to describe a physics joint
  23080. */
  23081. export interface PhysicsImpostorJoint {
  23082. /** Defines the main impostor to which the joint is linked */
  23083. mainImpostor: PhysicsImpostor;
  23084. /** Defines the impostor that is connected to the main impostor using this joint */
  23085. connectedImpostor: PhysicsImpostor;
  23086. /** Defines the joint itself */
  23087. joint: PhysicsJoint;
  23088. }
  23089. /** @hidden */
  23090. export interface IPhysicsEnginePlugin {
  23091. world: any;
  23092. name: string;
  23093. setGravity(gravity: Vector3): void;
  23094. setTimeStep(timeStep: number): void;
  23095. getTimeStep(): number;
  23096. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23097. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23098. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23099. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23100. removePhysicsBody(impostor: PhysicsImpostor): void;
  23101. generateJoint(joint: PhysicsImpostorJoint): void;
  23102. removeJoint(joint: PhysicsImpostorJoint): void;
  23103. isSupported(): boolean;
  23104. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23105. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23106. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23107. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23108. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23109. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23110. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23111. getBodyMass(impostor: PhysicsImpostor): number;
  23112. getBodyFriction(impostor: PhysicsImpostor): number;
  23113. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23114. getBodyRestitution(impostor: PhysicsImpostor): number;
  23115. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23116. getBodyPressure?(impostor: PhysicsImpostor): number;
  23117. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23118. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23119. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23120. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23121. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23122. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23123. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23124. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23125. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23126. sleepBody(impostor: PhysicsImpostor): void;
  23127. wakeUpBody(impostor: PhysicsImpostor): void;
  23128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23129. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23130. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23131. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23132. getRadius(impostor: PhysicsImpostor): number;
  23133. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23134. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23135. dispose(): void;
  23136. }
  23137. /**
  23138. * Interface used to define a physics engine
  23139. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23140. */
  23141. export interface IPhysicsEngine {
  23142. /**
  23143. * Gets the gravity vector used by the simulation
  23144. */
  23145. gravity: Vector3;
  23146. /**
  23147. * Sets the gravity vector used by the simulation
  23148. * @param gravity defines the gravity vector to use
  23149. */
  23150. setGravity(gravity: Vector3): void;
  23151. /**
  23152. * Set the time step of the physics engine.
  23153. * Default is 1/60.
  23154. * To slow it down, enter 1/600 for example.
  23155. * To speed it up, 1/30
  23156. * @param newTimeStep the new timestep to apply to this world.
  23157. */
  23158. setTimeStep(newTimeStep: number): void;
  23159. /**
  23160. * Get the time step of the physics engine.
  23161. * @returns the current time step
  23162. */
  23163. getTimeStep(): number;
  23164. /**
  23165. * Release all resources
  23166. */
  23167. dispose(): void;
  23168. /**
  23169. * Gets the name of the current physics plugin
  23170. * @returns the name of the plugin
  23171. */
  23172. getPhysicsPluginName(): string;
  23173. /**
  23174. * Adding a new impostor for the impostor tracking.
  23175. * This will be done by the impostor itself.
  23176. * @param impostor the impostor to add
  23177. */
  23178. addImpostor(impostor: PhysicsImpostor): void;
  23179. /**
  23180. * Remove an impostor from the engine.
  23181. * This impostor and its mesh will not longer be updated by the physics engine.
  23182. * @param impostor the impostor to remove
  23183. */
  23184. removeImpostor(impostor: PhysicsImpostor): void;
  23185. /**
  23186. * Add a joint to the physics engine
  23187. * @param mainImpostor defines the main impostor to which the joint is added.
  23188. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23189. * @param joint defines the joint that will connect both impostors.
  23190. */
  23191. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23192. /**
  23193. * Removes a joint from the simulation
  23194. * @param mainImpostor defines the impostor used with the joint
  23195. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23196. * @param joint defines the joint to remove
  23197. */
  23198. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23199. /**
  23200. * Gets the current plugin used to run the simulation
  23201. * @returns current plugin
  23202. */
  23203. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23204. /**
  23205. * Gets the list of physic impostors
  23206. * @returns an array of PhysicsImpostor
  23207. */
  23208. getImpostors(): Array<PhysicsImpostor>;
  23209. /**
  23210. * Gets the impostor for a physics enabled object
  23211. * @param object defines the object impersonated by the impostor
  23212. * @returns the PhysicsImpostor or null if not found
  23213. */
  23214. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23215. /**
  23216. * Gets the impostor for a physics body object
  23217. * @param body defines physics body used by the impostor
  23218. * @returns the PhysicsImpostor or null if not found
  23219. */
  23220. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23221. /**
  23222. * Does a raycast in the physics world
  23223. * @param from when should the ray start?
  23224. * @param to when should the ray end?
  23225. * @returns PhysicsRaycastResult
  23226. */
  23227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23228. /**
  23229. * Called by the scene. No need to call it.
  23230. * @param delta defines the timespam between frames
  23231. */
  23232. _step(delta: number): void;
  23233. }
  23234. }
  23235. declare module "babylonjs/Physics/physicsImpostor" {
  23236. import { Nullable, IndicesArray } from "babylonjs/types";
  23237. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23238. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23240. import { Scene } from "babylonjs/scene";
  23241. import { Bone } from "babylonjs/Bones/bone";
  23242. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23243. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23244. import { Space } from "babylonjs/Maths/math.axis";
  23245. /**
  23246. * The interface for the physics imposter parameters
  23247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23248. */
  23249. export interface PhysicsImpostorParameters {
  23250. /**
  23251. * The mass of the physics imposter
  23252. */
  23253. mass: number;
  23254. /**
  23255. * The friction of the physics imposter
  23256. */
  23257. friction?: number;
  23258. /**
  23259. * The coefficient of restitution of the physics imposter
  23260. */
  23261. restitution?: number;
  23262. /**
  23263. * The native options of the physics imposter
  23264. */
  23265. nativeOptions?: any;
  23266. /**
  23267. * Specifies if the parent should be ignored
  23268. */
  23269. ignoreParent?: boolean;
  23270. /**
  23271. * Specifies if bi-directional transformations should be disabled
  23272. */
  23273. disableBidirectionalTransformation?: boolean;
  23274. /**
  23275. * The pressure inside the physics imposter, soft object only
  23276. */
  23277. pressure?: number;
  23278. /**
  23279. * The stiffness the physics imposter, soft object only
  23280. */
  23281. stiffness?: number;
  23282. /**
  23283. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23284. */
  23285. velocityIterations?: number;
  23286. /**
  23287. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23288. */
  23289. positionIterations?: number;
  23290. /**
  23291. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23292. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23293. * Add to fix multiple points
  23294. */
  23295. fixedPoints?: number;
  23296. /**
  23297. * The collision margin around a soft object
  23298. */
  23299. margin?: number;
  23300. /**
  23301. * The collision margin around a soft object
  23302. */
  23303. damping?: number;
  23304. /**
  23305. * The path for a rope based on an extrusion
  23306. */
  23307. path?: any;
  23308. /**
  23309. * The shape of an extrusion used for a rope based on an extrusion
  23310. */
  23311. shape?: any;
  23312. }
  23313. /**
  23314. * Interface for a physics-enabled object
  23315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23316. */
  23317. export interface IPhysicsEnabledObject {
  23318. /**
  23319. * The position of the physics-enabled object
  23320. */
  23321. position: Vector3;
  23322. /**
  23323. * The rotation of the physics-enabled object
  23324. */
  23325. rotationQuaternion: Nullable<Quaternion>;
  23326. /**
  23327. * The scale of the physics-enabled object
  23328. */
  23329. scaling: Vector3;
  23330. /**
  23331. * The rotation of the physics-enabled object
  23332. */
  23333. rotation?: Vector3;
  23334. /**
  23335. * The parent of the physics-enabled object
  23336. */
  23337. parent?: any;
  23338. /**
  23339. * The bounding info of the physics-enabled object
  23340. * @returns The bounding info of the physics-enabled object
  23341. */
  23342. getBoundingInfo(): BoundingInfo;
  23343. /**
  23344. * Computes the world matrix
  23345. * @param force Specifies if the world matrix should be computed by force
  23346. * @returns A world matrix
  23347. */
  23348. computeWorldMatrix(force: boolean): Matrix;
  23349. /**
  23350. * Gets the world matrix
  23351. * @returns A world matrix
  23352. */
  23353. getWorldMatrix?(): Matrix;
  23354. /**
  23355. * Gets the child meshes
  23356. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23357. * @returns An array of abstract meshes
  23358. */
  23359. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23360. /**
  23361. * Gets the vertex data
  23362. * @param kind The type of vertex data
  23363. * @returns A nullable array of numbers, or a float32 array
  23364. */
  23365. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23366. /**
  23367. * Gets the indices from the mesh
  23368. * @returns A nullable array of index arrays
  23369. */
  23370. getIndices?(): Nullable<IndicesArray>;
  23371. /**
  23372. * Gets the scene from the mesh
  23373. * @returns the indices array or null
  23374. */
  23375. getScene?(): Scene;
  23376. /**
  23377. * Gets the absolute position from the mesh
  23378. * @returns the absolute position
  23379. */
  23380. getAbsolutePosition(): Vector3;
  23381. /**
  23382. * Gets the absolute pivot point from the mesh
  23383. * @returns the absolute pivot point
  23384. */
  23385. getAbsolutePivotPoint(): Vector3;
  23386. /**
  23387. * Rotates the mesh
  23388. * @param axis The axis of rotation
  23389. * @param amount The amount of rotation
  23390. * @param space The space of the rotation
  23391. * @returns The rotation transform node
  23392. */
  23393. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23394. /**
  23395. * Translates the mesh
  23396. * @param axis The axis of translation
  23397. * @param distance The distance of translation
  23398. * @param space The space of the translation
  23399. * @returns The transform node
  23400. */
  23401. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23402. /**
  23403. * Sets the absolute position of the mesh
  23404. * @param absolutePosition The absolute position of the mesh
  23405. * @returns The transform node
  23406. */
  23407. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23408. /**
  23409. * Gets the class name of the mesh
  23410. * @returns The class name
  23411. */
  23412. getClassName(): string;
  23413. }
  23414. /**
  23415. * Represents a physics imposter
  23416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23417. */
  23418. export class PhysicsImpostor {
  23419. /**
  23420. * The physics-enabled object used as the physics imposter
  23421. */
  23422. object: IPhysicsEnabledObject;
  23423. /**
  23424. * The type of the physics imposter
  23425. */
  23426. type: number;
  23427. private _options;
  23428. private _scene?;
  23429. /**
  23430. * The default object size of the imposter
  23431. */
  23432. static DEFAULT_OBJECT_SIZE: Vector3;
  23433. /**
  23434. * The identity quaternion of the imposter
  23435. */
  23436. static IDENTITY_QUATERNION: Quaternion;
  23437. /** @hidden */
  23438. _pluginData: any;
  23439. private _physicsEngine;
  23440. private _physicsBody;
  23441. private _bodyUpdateRequired;
  23442. private _onBeforePhysicsStepCallbacks;
  23443. private _onAfterPhysicsStepCallbacks;
  23444. /** @hidden */
  23445. _onPhysicsCollideCallbacks: Array<{
  23446. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23447. otherImpostors: Array<PhysicsImpostor>;
  23448. }>;
  23449. private _deltaPosition;
  23450. private _deltaRotation;
  23451. private _deltaRotationConjugated;
  23452. /** @hidden */
  23453. _isFromLine: boolean;
  23454. private _parent;
  23455. private _isDisposed;
  23456. private static _tmpVecs;
  23457. private static _tmpQuat;
  23458. /**
  23459. * Specifies if the physics imposter is disposed
  23460. */
  23461. readonly isDisposed: boolean;
  23462. /**
  23463. * Gets the mass of the physics imposter
  23464. */
  23465. mass: number;
  23466. /**
  23467. * Gets the coefficient of friction
  23468. */
  23469. /**
  23470. * Sets the coefficient of friction
  23471. */
  23472. friction: number;
  23473. /**
  23474. * Gets the coefficient of restitution
  23475. */
  23476. /**
  23477. * Sets the coefficient of restitution
  23478. */
  23479. restitution: number;
  23480. /**
  23481. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23482. */
  23483. /**
  23484. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23485. */
  23486. pressure: number;
  23487. /**
  23488. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23489. */
  23490. /**
  23491. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23492. */
  23493. stiffness: number;
  23494. /**
  23495. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23496. */
  23497. /**
  23498. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23499. */
  23500. velocityIterations: number;
  23501. /**
  23502. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23503. */
  23504. /**
  23505. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23506. */
  23507. positionIterations: number;
  23508. /**
  23509. * The unique id of the physics imposter
  23510. * set by the physics engine when adding this impostor to the array
  23511. */
  23512. uniqueId: number;
  23513. /**
  23514. * @hidden
  23515. */
  23516. soft: boolean;
  23517. /**
  23518. * @hidden
  23519. */
  23520. segments: number;
  23521. private _joints;
  23522. /**
  23523. * Initializes the physics imposter
  23524. * @param object The physics-enabled object used as the physics imposter
  23525. * @param type The type of the physics imposter
  23526. * @param _options The options for the physics imposter
  23527. * @param _scene The Babylon scene
  23528. */
  23529. constructor(
  23530. /**
  23531. * The physics-enabled object used as the physics imposter
  23532. */
  23533. object: IPhysicsEnabledObject,
  23534. /**
  23535. * The type of the physics imposter
  23536. */
  23537. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23538. /**
  23539. * This function will completly initialize this impostor.
  23540. * It will create a new body - but only if this mesh has no parent.
  23541. * If it has, this impostor will not be used other than to define the impostor
  23542. * of the child mesh.
  23543. * @hidden
  23544. */
  23545. _init(): void;
  23546. private _getPhysicsParent;
  23547. /**
  23548. * Should a new body be generated.
  23549. * @returns boolean specifying if body initialization is required
  23550. */
  23551. isBodyInitRequired(): boolean;
  23552. /**
  23553. * Sets the updated scaling
  23554. * @param updated Specifies if the scaling is updated
  23555. */
  23556. setScalingUpdated(): void;
  23557. /**
  23558. * Force a regeneration of this or the parent's impostor's body.
  23559. * Use under cautious - This will remove all joints already implemented.
  23560. */
  23561. forceUpdate(): void;
  23562. /**
  23563. * Gets the body that holds this impostor. Either its own, or its parent.
  23564. */
  23565. /**
  23566. * Set the physics body. Used mainly by the physics engine/plugin
  23567. */
  23568. physicsBody: any;
  23569. /**
  23570. * Get the parent of the physics imposter
  23571. * @returns Physics imposter or null
  23572. */
  23573. /**
  23574. * Sets the parent of the physics imposter
  23575. */
  23576. parent: Nullable<PhysicsImpostor>;
  23577. /**
  23578. * Resets the update flags
  23579. */
  23580. resetUpdateFlags(): void;
  23581. /**
  23582. * Gets the object extend size
  23583. * @returns the object extend size
  23584. */
  23585. getObjectExtendSize(): Vector3;
  23586. /**
  23587. * Gets the object center
  23588. * @returns The object center
  23589. */
  23590. getObjectCenter(): Vector3;
  23591. /**
  23592. * Get a specific parametes from the options parameter
  23593. * @param paramName The object parameter name
  23594. * @returns The object parameter
  23595. */
  23596. getParam(paramName: string): any;
  23597. /**
  23598. * Sets a specific parameter in the options given to the physics plugin
  23599. * @param paramName The parameter name
  23600. * @param value The value of the parameter
  23601. */
  23602. setParam(paramName: string, value: number): void;
  23603. /**
  23604. * Specifically change the body's mass option. Won't recreate the physics body object
  23605. * @param mass The mass of the physics imposter
  23606. */
  23607. setMass(mass: number): void;
  23608. /**
  23609. * Gets the linear velocity
  23610. * @returns linear velocity or null
  23611. */
  23612. getLinearVelocity(): Nullable<Vector3>;
  23613. /**
  23614. * Sets the linear velocity
  23615. * @param velocity linear velocity or null
  23616. */
  23617. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23618. /**
  23619. * Gets the angular velocity
  23620. * @returns angular velocity or null
  23621. */
  23622. getAngularVelocity(): Nullable<Vector3>;
  23623. /**
  23624. * Sets the angular velocity
  23625. * @param velocity The velocity or null
  23626. */
  23627. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23628. /**
  23629. * Execute a function with the physics plugin native code
  23630. * Provide a function the will have two variables - the world object and the physics body object
  23631. * @param func The function to execute with the physics plugin native code
  23632. */
  23633. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23634. /**
  23635. * Register a function that will be executed before the physics world is stepping forward
  23636. * @param func The function to execute before the physics world is stepped forward
  23637. */
  23638. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23639. /**
  23640. * Unregister a function that will be executed before the physics world is stepping forward
  23641. * @param func The function to execute before the physics world is stepped forward
  23642. */
  23643. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23644. /**
  23645. * Register a function that will be executed after the physics step
  23646. * @param func The function to execute after physics step
  23647. */
  23648. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23649. /**
  23650. * Unregisters a function that will be executed after the physics step
  23651. * @param func The function to execute after physics step
  23652. */
  23653. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23654. /**
  23655. * register a function that will be executed when this impostor collides against a different body
  23656. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23657. * @param func Callback that is executed on collision
  23658. */
  23659. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23660. /**
  23661. * Unregisters the physics imposter on contact
  23662. * @param collideAgainst The physics object to collide against
  23663. * @param func Callback to execute on collision
  23664. */
  23665. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23666. private _tmpQuat;
  23667. private _tmpQuat2;
  23668. /**
  23669. * Get the parent rotation
  23670. * @returns The parent rotation
  23671. */
  23672. getParentsRotation(): Quaternion;
  23673. /**
  23674. * this function is executed by the physics engine.
  23675. */
  23676. beforeStep: () => void;
  23677. /**
  23678. * this function is executed by the physics engine
  23679. */
  23680. afterStep: () => void;
  23681. /**
  23682. * Legacy collision detection event support
  23683. */
  23684. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23685. /**
  23686. * event and body object due to cannon's event-based architecture.
  23687. */
  23688. onCollide: (e: {
  23689. body: any;
  23690. }) => void;
  23691. /**
  23692. * Apply a force
  23693. * @param force The force to apply
  23694. * @param contactPoint The contact point for the force
  23695. * @returns The physics imposter
  23696. */
  23697. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23698. /**
  23699. * Apply an impulse
  23700. * @param force The impulse force
  23701. * @param contactPoint The contact point for the impulse force
  23702. * @returns The physics imposter
  23703. */
  23704. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23705. /**
  23706. * A help function to create a joint
  23707. * @param otherImpostor A physics imposter used to create a joint
  23708. * @param jointType The type of joint
  23709. * @param jointData The data for the joint
  23710. * @returns The physics imposter
  23711. */
  23712. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23713. /**
  23714. * Add a joint to this impostor with a different impostor
  23715. * @param otherImpostor A physics imposter used to add a joint
  23716. * @param joint The joint to add
  23717. * @returns The physics imposter
  23718. */
  23719. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23720. /**
  23721. * Add an anchor to a cloth impostor
  23722. * @param otherImpostor rigid impostor to anchor to
  23723. * @param width ratio across width from 0 to 1
  23724. * @param height ratio up height from 0 to 1
  23725. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23726. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23727. * @returns impostor the soft imposter
  23728. */
  23729. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23730. /**
  23731. * Add a hook to a rope impostor
  23732. * @param otherImpostor rigid impostor to anchor to
  23733. * @param length ratio across rope from 0 to 1
  23734. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23735. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23736. * @returns impostor the rope imposter
  23737. */
  23738. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23739. /**
  23740. * Will keep this body still, in a sleep mode.
  23741. * @returns the physics imposter
  23742. */
  23743. sleep(): PhysicsImpostor;
  23744. /**
  23745. * Wake the body up.
  23746. * @returns The physics imposter
  23747. */
  23748. wakeUp(): PhysicsImpostor;
  23749. /**
  23750. * Clones the physics imposter
  23751. * @param newObject The physics imposter clones to this physics-enabled object
  23752. * @returns A nullable physics imposter
  23753. */
  23754. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23755. /**
  23756. * Disposes the physics imposter
  23757. */
  23758. dispose(): void;
  23759. /**
  23760. * Sets the delta position
  23761. * @param position The delta position amount
  23762. */
  23763. setDeltaPosition(position: Vector3): void;
  23764. /**
  23765. * Sets the delta rotation
  23766. * @param rotation The delta rotation amount
  23767. */
  23768. setDeltaRotation(rotation: Quaternion): void;
  23769. /**
  23770. * Gets the box size of the physics imposter and stores the result in the input parameter
  23771. * @param result Stores the box size
  23772. * @returns The physics imposter
  23773. */
  23774. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23775. /**
  23776. * Gets the radius of the physics imposter
  23777. * @returns Radius of the physics imposter
  23778. */
  23779. getRadius(): number;
  23780. /**
  23781. * Sync a bone with this impostor
  23782. * @param bone The bone to sync to the impostor.
  23783. * @param boneMesh The mesh that the bone is influencing.
  23784. * @param jointPivot The pivot of the joint / bone in local space.
  23785. * @param distToJoint Optional distance from the impostor to the joint.
  23786. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23787. */
  23788. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23789. /**
  23790. * Sync impostor to a bone
  23791. * @param bone The bone that the impostor will be synced to.
  23792. * @param boneMesh The mesh that the bone is influencing.
  23793. * @param jointPivot The pivot of the joint / bone in local space.
  23794. * @param distToJoint Optional distance from the impostor to the joint.
  23795. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23796. * @param boneAxis Optional vector3 axis the bone is aligned with
  23797. */
  23798. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23799. /**
  23800. * No-Imposter type
  23801. */
  23802. static NoImpostor: number;
  23803. /**
  23804. * Sphere-Imposter type
  23805. */
  23806. static SphereImpostor: number;
  23807. /**
  23808. * Box-Imposter type
  23809. */
  23810. static BoxImpostor: number;
  23811. /**
  23812. * Plane-Imposter type
  23813. */
  23814. static PlaneImpostor: number;
  23815. /**
  23816. * Mesh-imposter type
  23817. */
  23818. static MeshImpostor: number;
  23819. /**
  23820. * Capsule-Impostor type (Ammo.js plugin only)
  23821. */
  23822. static CapsuleImpostor: number;
  23823. /**
  23824. * Cylinder-Imposter type
  23825. */
  23826. static CylinderImpostor: number;
  23827. /**
  23828. * Particle-Imposter type
  23829. */
  23830. static ParticleImpostor: number;
  23831. /**
  23832. * Heightmap-Imposter type
  23833. */
  23834. static HeightmapImpostor: number;
  23835. /**
  23836. * ConvexHull-Impostor type (Ammo.js plugin only)
  23837. */
  23838. static ConvexHullImpostor: number;
  23839. /**
  23840. * Rope-Imposter type
  23841. */
  23842. static RopeImpostor: number;
  23843. /**
  23844. * Cloth-Imposter type
  23845. */
  23846. static ClothImpostor: number;
  23847. /**
  23848. * Softbody-Imposter type
  23849. */
  23850. static SoftbodyImpostor: number;
  23851. }
  23852. }
  23853. declare module "babylonjs/Meshes/mesh" {
  23854. import { Observable } from "babylonjs/Misc/observable";
  23855. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23856. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23857. import { Camera } from "babylonjs/Cameras/camera";
  23858. import { Scene } from "babylonjs/scene";
  23859. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23860. import { Color4 } from "babylonjs/Maths/math.color";
  23861. import { Engine } from "babylonjs/Engines/engine";
  23862. import { Node } from "babylonjs/node";
  23863. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23864. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23865. import { Buffer } from "babylonjs/Meshes/buffer";
  23866. import { Geometry } from "babylonjs/Meshes/geometry";
  23867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23868. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23869. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23870. import { Effect } from "babylonjs/Materials/effect";
  23871. import { Material } from "babylonjs/Materials/material";
  23872. import { Skeleton } from "babylonjs/Bones/skeleton";
  23873. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23874. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23875. import { Path3D } from "babylonjs/Maths/math.path";
  23876. import { Plane } from "babylonjs/Maths/math.plane";
  23877. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23878. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23879. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23880. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23881. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23882. /**
  23883. * @hidden
  23884. **/
  23885. export class _CreationDataStorage {
  23886. closePath?: boolean;
  23887. closeArray?: boolean;
  23888. idx: number[];
  23889. dashSize: number;
  23890. gapSize: number;
  23891. path3D: Path3D;
  23892. pathArray: Vector3[][];
  23893. arc: number;
  23894. radius: number;
  23895. cap: number;
  23896. tessellation: number;
  23897. }
  23898. /**
  23899. * @hidden
  23900. **/
  23901. class _InstanceDataStorage {
  23902. visibleInstances: any;
  23903. batchCache: _InstancesBatch;
  23904. instancesBufferSize: number;
  23905. instancesBuffer: Nullable<Buffer>;
  23906. instancesData: Float32Array;
  23907. overridenInstanceCount: number;
  23908. isFrozen: boolean;
  23909. previousBatch: Nullable<_InstancesBatch>;
  23910. hardwareInstancedRendering: boolean;
  23911. sideOrientation: number;
  23912. }
  23913. /**
  23914. * @hidden
  23915. **/
  23916. export class _InstancesBatch {
  23917. mustReturn: boolean;
  23918. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23919. renderSelf: boolean[];
  23920. hardwareInstancedRendering: boolean[];
  23921. }
  23922. /**
  23923. * Class used to represent renderable models
  23924. */
  23925. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23926. /**
  23927. * Mesh side orientation : usually the external or front surface
  23928. */
  23929. static readonly FRONTSIDE: number;
  23930. /**
  23931. * Mesh side orientation : usually the internal or back surface
  23932. */
  23933. static readonly BACKSIDE: number;
  23934. /**
  23935. * Mesh side orientation : both internal and external or front and back surfaces
  23936. */
  23937. static readonly DOUBLESIDE: number;
  23938. /**
  23939. * Mesh side orientation : by default, `FRONTSIDE`
  23940. */
  23941. static readonly DEFAULTSIDE: number;
  23942. /**
  23943. * Mesh cap setting : no cap
  23944. */
  23945. static readonly NO_CAP: number;
  23946. /**
  23947. * Mesh cap setting : one cap at the beginning of the mesh
  23948. */
  23949. static readonly CAP_START: number;
  23950. /**
  23951. * Mesh cap setting : one cap at the end of the mesh
  23952. */
  23953. static readonly CAP_END: number;
  23954. /**
  23955. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23956. */
  23957. static readonly CAP_ALL: number;
  23958. /**
  23959. * Mesh pattern setting : no flip or rotate
  23960. */
  23961. static readonly NO_FLIP: number;
  23962. /**
  23963. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23964. */
  23965. static readonly FLIP_TILE: number;
  23966. /**
  23967. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23968. */
  23969. static readonly ROTATE_TILE: number;
  23970. /**
  23971. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23972. */
  23973. static readonly FLIP_ROW: number;
  23974. /**
  23975. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23976. */
  23977. static readonly ROTATE_ROW: number;
  23978. /**
  23979. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23980. */
  23981. static readonly FLIP_N_ROTATE_TILE: number;
  23982. /**
  23983. * Mesh pattern setting : rotate pattern and rotate
  23984. */
  23985. static readonly FLIP_N_ROTATE_ROW: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23988. */
  23989. static readonly CENTER: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on left
  23992. */
  23993. static readonly LEFT: number;
  23994. /**
  23995. * Mesh tile positioning : part tiles on right
  23996. */
  23997. static readonly RIGHT: number;
  23998. /**
  23999. * Mesh tile positioning : part tiles on top
  24000. */
  24001. static readonly TOP: number;
  24002. /**
  24003. * Mesh tile positioning : part tiles on bottom
  24004. */
  24005. static readonly BOTTOM: number;
  24006. /**
  24007. * Gets the default side orientation.
  24008. * @param orientation the orientation to value to attempt to get
  24009. * @returns the default orientation
  24010. * @hidden
  24011. */
  24012. static _GetDefaultSideOrientation(orientation?: number): number;
  24013. private _internalMeshDataInfo;
  24014. /**
  24015. * An event triggered before rendering the mesh
  24016. */
  24017. readonly onBeforeRenderObservable: Observable<Mesh>;
  24018. /**
  24019. * An event triggered before binding the mesh
  24020. */
  24021. readonly onBeforeBindObservable: Observable<Mesh>;
  24022. /**
  24023. * An event triggered after rendering the mesh
  24024. */
  24025. readonly onAfterRenderObservable: Observable<Mesh>;
  24026. /**
  24027. * An event triggered before drawing the mesh
  24028. */
  24029. readonly onBeforeDrawObservable: Observable<Mesh>;
  24030. private _onBeforeDrawObserver;
  24031. /**
  24032. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24033. */
  24034. onBeforeDraw: () => void;
  24035. /**
  24036. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24037. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24038. */
  24039. delayLoadState: number;
  24040. /**
  24041. * Gets the list of instances created from this mesh
  24042. * it is not supposed to be modified manually.
  24043. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24045. */
  24046. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24047. /**
  24048. * Gets the file containing delay loading data for this mesh
  24049. */
  24050. delayLoadingFile: string;
  24051. /** @hidden */
  24052. _binaryInfo: any;
  24053. /**
  24054. * User defined function used to change how LOD level selection is done
  24055. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24056. */
  24057. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24058. /**
  24059. * Gets or sets the morph target manager
  24060. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24061. */
  24062. morphTargetManager: Nullable<MorphTargetManager>;
  24063. /** @hidden */
  24064. _creationDataStorage: Nullable<_CreationDataStorage>;
  24065. /** @hidden */
  24066. _geometry: Nullable<Geometry>;
  24067. /** @hidden */
  24068. _delayInfo: Array<string>;
  24069. /** @hidden */
  24070. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24071. /** @hidden */
  24072. _instanceDataStorage: _InstanceDataStorage;
  24073. private _effectiveMaterial;
  24074. /** @hidden */
  24075. _shouldGenerateFlatShading: boolean;
  24076. /** @hidden */
  24077. _originalBuilderSideOrientation: number;
  24078. /**
  24079. * Use this property to change the original side orientation defined at construction time
  24080. */
  24081. overrideMaterialSideOrientation: Nullable<number>;
  24082. /**
  24083. * Gets the source mesh (the one used to clone this one from)
  24084. */
  24085. readonly source: Nullable<Mesh>;
  24086. /**
  24087. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24088. */
  24089. isUnIndexed: boolean;
  24090. /**
  24091. * @constructor
  24092. * @param name The value used by scene.getMeshByName() to do a lookup.
  24093. * @param scene The scene to add this mesh to.
  24094. * @param parent The parent of this mesh, if it has one
  24095. * @param source An optional Mesh from which geometry is shared, cloned.
  24096. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24097. * When false, achieved by calling a clone(), also passing False.
  24098. * This will make creation of children, recursive.
  24099. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24100. */
  24101. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24102. /**
  24103. * Gets the class name
  24104. * @returns the string "Mesh".
  24105. */
  24106. getClassName(): string;
  24107. /** @hidden */
  24108. readonly _isMesh: boolean;
  24109. /**
  24110. * Returns a description of this mesh
  24111. * @param fullDetails define if full details about this mesh must be used
  24112. * @returns a descriptive string representing this mesh
  24113. */
  24114. toString(fullDetails?: boolean): string;
  24115. /** @hidden */
  24116. _unBindEffect(): void;
  24117. /**
  24118. * Gets a boolean indicating if this mesh has LOD
  24119. */
  24120. readonly hasLODLevels: boolean;
  24121. /**
  24122. * Gets the list of MeshLODLevel associated with the current mesh
  24123. * @returns an array of MeshLODLevel
  24124. */
  24125. getLODLevels(): MeshLODLevel[];
  24126. private _sortLODLevels;
  24127. /**
  24128. * Add a mesh as LOD level triggered at the given distance.
  24129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24130. * @param distance The distance from the center of the object to show this level
  24131. * @param mesh The mesh to be added as LOD level (can be null)
  24132. * @return This mesh (for chaining)
  24133. */
  24134. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24135. /**
  24136. * Returns the LOD level mesh at the passed distance or null if not found.
  24137. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24138. * @param distance The distance from the center of the object to show this level
  24139. * @returns a Mesh or `null`
  24140. */
  24141. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24142. /**
  24143. * Remove a mesh from the LOD array
  24144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24145. * @param mesh defines the mesh to be removed
  24146. * @return This mesh (for chaining)
  24147. */
  24148. removeLODLevel(mesh: Mesh): Mesh;
  24149. /**
  24150. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24152. * @param camera defines the camera to use to compute distance
  24153. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24154. * @return This mesh (for chaining)
  24155. */
  24156. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24157. /**
  24158. * Gets the mesh internal Geometry object
  24159. */
  24160. readonly geometry: Nullable<Geometry>;
  24161. /**
  24162. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24163. * @returns the total number of vertices
  24164. */
  24165. getTotalVertices(): number;
  24166. /**
  24167. * Returns the content of an associated vertex buffer
  24168. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24169. * - VertexBuffer.PositionKind
  24170. * - VertexBuffer.UVKind
  24171. * - VertexBuffer.UV2Kind
  24172. * - VertexBuffer.UV3Kind
  24173. * - VertexBuffer.UV4Kind
  24174. * - VertexBuffer.UV5Kind
  24175. * - VertexBuffer.UV6Kind
  24176. * - VertexBuffer.ColorKind
  24177. * - VertexBuffer.MatricesIndicesKind
  24178. * - VertexBuffer.MatricesIndicesExtraKind
  24179. * - VertexBuffer.MatricesWeightsKind
  24180. * - VertexBuffer.MatricesWeightsExtraKind
  24181. * @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
  24182. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24183. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24184. */
  24185. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24186. /**
  24187. * Returns the mesh VertexBuffer object from the requested `kind`
  24188. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24189. * - VertexBuffer.PositionKind
  24190. * - VertexBuffer.NormalKind
  24191. * - VertexBuffer.UVKind
  24192. * - VertexBuffer.UV2Kind
  24193. * - VertexBuffer.UV3Kind
  24194. * - VertexBuffer.UV4Kind
  24195. * - VertexBuffer.UV5Kind
  24196. * - VertexBuffer.UV6Kind
  24197. * - VertexBuffer.ColorKind
  24198. * - VertexBuffer.MatricesIndicesKind
  24199. * - VertexBuffer.MatricesIndicesExtraKind
  24200. * - VertexBuffer.MatricesWeightsKind
  24201. * - VertexBuffer.MatricesWeightsExtraKind
  24202. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24203. */
  24204. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24205. /**
  24206. * Tests if a specific vertex buffer is associated with this mesh
  24207. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24208. * - VertexBuffer.PositionKind
  24209. * - VertexBuffer.NormalKind
  24210. * - VertexBuffer.UVKind
  24211. * - VertexBuffer.UV2Kind
  24212. * - VertexBuffer.UV3Kind
  24213. * - VertexBuffer.UV4Kind
  24214. * - VertexBuffer.UV5Kind
  24215. * - VertexBuffer.UV6Kind
  24216. * - VertexBuffer.ColorKind
  24217. * - VertexBuffer.MatricesIndicesKind
  24218. * - VertexBuffer.MatricesIndicesExtraKind
  24219. * - VertexBuffer.MatricesWeightsKind
  24220. * - VertexBuffer.MatricesWeightsExtraKind
  24221. * @returns a boolean
  24222. */
  24223. isVerticesDataPresent(kind: string): boolean;
  24224. /**
  24225. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24226. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24227. * - VertexBuffer.PositionKind
  24228. * - VertexBuffer.UVKind
  24229. * - VertexBuffer.UV2Kind
  24230. * - VertexBuffer.UV3Kind
  24231. * - VertexBuffer.UV4Kind
  24232. * - VertexBuffer.UV5Kind
  24233. * - VertexBuffer.UV6Kind
  24234. * - VertexBuffer.ColorKind
  24235. * - VertexBuffer.MatricesIndicesKind
  24236. * - VertexBuffer.MatricesIndicesExtraKind
  24237. * - VertexBuffer.MatricesWeightsKind
  24238. * - VertexBuffer.MatricesWeightsExtraKind
  24239. * @returns a boolean
  24240. */
  24241. isVertexBufferUpdatable(kind: string): boolean;
  24242. /**
  24243. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24245. * - VertexBuffer.PositionKind
  24246. * - VertexBuffer.NormalKind
  24247. * - VertexBuffer.UVKind
  24248. * - VertexBuffer.UV2Kind
  24249. * - VertexBuffer.UV3Kind
  24250. * - VertexBuffer.UV4Kind
  24251. * - VertexBuffer.UV5Kind
  24252. * - VertexBuffer.UV6Kind
  24253. * - VertexBuffer.ColorKind
  24254. * - VertexBuffer.MatricesIndicesKind
  24255. * - VertexBuffer.MatricesIndicesExtraKind
  24256. * - VertexBuffer.MatricesWeightsKind
  24257. * - VertexBuffer.MatricesWeightsExtraKind
  24258. * @returns an array of strings
  24259. */
  24260. getVerticesDataKinds(): string[];
  24261. /**
  24262. * Returns a positive integer : the total number of indices in this mesh geometry.
  24263. * @returns the numner of indices or zero if the mesh has no geometry.
  24264. */
  24265. getTotalIndices(): number;
  24266. /**
  24267. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24268. * @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.
  24269. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24270. * @returns the indices array or an empty array if the mesh has no geometry
  24271. */
  24272. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24273. readonly isBlocked: boolean;
  24274. /**
  24275. * Determine if the current mesh is ready to be rendered
  24276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24277. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24278. * @returns true if all associated assets are ready (material, textures, shaders)
  24279. */
  24280. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24281. /**
  24282. * 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.
  24283. */
  24284. readonly areNormalsFrozen: boolean;
  24285. /**
  24286. * 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.
  24287. * @returns the current mesh
  24288. */
  24289. freezeNormals(): Mesh;
  24290. /**
  24291. * 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
  24292. * @returns the current mesh
  24293. */
  24294. unfreezeNormals(): Mesh;
  24295. /**
  24296. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24297. */
  24298. overridenInstanceCount: number;
  24299. /** @hidden */
  24300. _preActivate(): Mesh;
  24301. /** @hidden */
  24302. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24303. /** @hidden */
  24304. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24305. /**
  24306. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24307. * This means the mesh underlying bounding box and sphere are recomputed.
  24308. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24309. * @returns the current mesh
  24310. */
  24311. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24312. /** @hidden */
  24313. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24314. /**
  24315. * This function will subdivide the mesh into multiple submeshes
  24316. * @param count defines the expected number of submeshes
  24317. */
  24318. subdivide(count: number): void;
  24319. /**
  24320. * Copy a FloatArray into a specific associated vertex buffer
  24321. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24322. * - VertexBuffer.PositionKind
  24323. * - VertexBuffer.UVKind
  24324. * - VertexBuffer.UV2Kind
  24325. * - VertexBuffer.UV3Kind
  24326. * - VertexBuffer.UV4Kind
  24327. * - VertexBuffer.UV5Kind
  24328. * - VertexBuffer.UV6Kind
  24329. * - VertexBuffer.ColorKind
  24330. * - VertexBuffer.MatricesIndicesKind
  24331. * - VertexBuffer.MatricesIndicesExtraKind
  24332. * - VertexBuffer.MatricesWeightsKind
  24333. * - VertexBuffer.MatricesWeightsExtraKind
  24334. * @param data defines the data source
  24335. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24336. * @param stride defines the data stride size (can be null)
  24337. * @returns the current mesh
  24338. */
  24339. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24340. /**
  24341. * Flags an associated vertex buffer as updatable
  24342. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24343. * - VertexBuffer.PositionKind
  24344. * - VertexBuffer.UVKind
  24345. * - VertexBuffer.UV2Kind
  24346. * - VertexBuffer.UV3Kind
  24347. * - VertexBuffer.UV4Kind
  24348. * - VertexBuffer.UV5Kind
  24349. * - VertexBuffer.UV6Kind
  24350. * - VertexBuffer.ColorKind
  24351. * - VertexBuffer.MatricesIndicesKind
  24352. * - VertexBuffer.MatricesIndicesExtraKind
  24353. * - VertexBuffer.MatricesWeightsKind
  24354. * - VertexBuffer.MatricesWeightsExtraKind
  24355. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24356. */
  24357. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24358. /**
  24359. * Sets the mesh global Vertex Buffer
  24360. * @param buffer defines the buffer to use
  24361. * @returns the current mesh
  24362. */
  24363. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24364. /**
  24365. * Update a specific associated vertex buffer
  24366. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24367. * - VertexBuffer.PositionKind
  24368. * - VertexBuffer.UVKind
  24369. * - VertexBuffer.UV2Kind
  24370. * - VertexBuffer.UV3Kind
  24371. * - VertexBuffer.UV4Kind
  24372. * - VertexBuffer.UV5Kind
  24373. * - VertexBuffer.UV6Kind
  24374. * - VertexBuffer.ColorKind
  24375. * - VertexBuffer.MatricesIndicesKind
  24376. * - VertexBuffer.MatricesIndicesExtraKind
  24377. * - VertexBuffer.MatricesWeightsKind
  24378. * - VertexBuffer.MatricesWeightsExtraKind
  24379. * @param data defines the data source
  24380. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24381. * @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)
  24382. * @returns the current mesh
  24383. */
  24384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24385. /**
  24386. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24387. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24388. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24389. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24390. * @returns the current mesh
  24391. */
  24392. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24393. /**
  24394. * Creates a un-shared specific occurence of the geometry for the mesh.
  24395. * @returns the current mesh
  24396. */
  24397. makeGeometryUnique(): Mesh;
  24398. /**
  24399. * Set the index buffer of this mesh
  24400. * @param indices defines the source data
  24401. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24402. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24403. * @returns the current mesh
  24404. */
  24405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24406. /**
  24407. * Update the current index buffer
  24408. * @param indices defines the source data
  24409. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24410. * @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)
  24411. * @returns the current mesh
  24412. */
  24413. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24414. /**
  24415. * Invert the geometry to move from a right handed system to a left handed one.
  24416. * @returns the current mesh
  24417. */
  24418. toLeftHanded(): Mesh;
  24419. /** @hidden */
  24420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24421. /** @hidden */
  24422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24423. /**
  24424. * Registers for this mesh a javascript function called just before the rendering process
  24425. * @param func defines the function to call before rendering this mesh
  24426. * @returns the current mesh
  24427. */
  24428. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24429. /**
  24430. * Disposes a previously registered javascript function called before the rendering
  24431. * @param func defines the function to remove
  24432. * @returns the current mesh
  24433. */
  24434. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24435. /**
  24436. * Registers for this mesh a javascript function called just after the rendering is complete
  24437. * @param func defines the function to call after rendering this mesh
  24438. * @returns the current mesh
  24439. */
  24440. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24441. /**
  24442. * Disposes a previously registered javascript function called after the rendering.
  24443. * @param func defines the function to remove
  24444. * @returns the current mesh
  24445. */
  24446. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24447. /** @hidden */
  24448. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24449. /** @hidden */
  24450. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24451. /** @hidden */
  24452. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24453. /** @hidden */
  24454. _rebuild(): void;
  24455. /** @hidden */
  24456. _freeze(): void;
  24457. /** @hidden */
  24458. _unFreeze(): void;
  24459. /**
  24460. * 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
  24461. * @param subMesh defines the subMesh to render
  24462. * @param enableAlphaMode defines if alpha mode can be changed
  24463. * @returns the current mesh
  24464. */
  24465. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24466. private _onBeforeDraw;
  24467. /**
  24468. * Renormalize the mesh and patch it up if there are no weights
  24469. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24470. * However in the case of zero weights then we set just a single influence to 1.
  24471. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24472. */
  24473. cleanMatrixWeights(): void;
  24474. private normalizeSkinFourWeights;
  24475. private normalizeSkinWeightsAndExtra;
  24476. /**
  24477. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24478. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24479. * the user know there was an issue with importing the mesh
  24480. * @returns a validation object with skinned, valid and report string
  24481. */
  24482. validateSkinning(): {
  24483. skinned: boolean;
  24484. valid: boolean;
  24485. report: string;
  24486. };
  24487. /** @hidden */
  24488. _checkDelayState(): Mesh;
  24489. private _queueLoad;
  24490. /**
  24491. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24492. * A mesh is in the frustum if its bounding box intersects the frustum
  24493. * @param frustumPlanes defines the frustum to test
  24494. * @returns true if the mesh is in the frustum planes
  24495. */
  24496. isInFrustum(frustumPlanes: Plane[]): boolean;
  24497. /**
  24498. * Sets the mesh material by the material or multiMaterial `id` property
  24499. * @param id is a string identifying the material or the multiMaterial
  24500. * @returns the current mesh
  24501. */
  24502. setMaterialByID(id: string): Mesh;
  24503. /**
  24504. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24505. * @returns an array of IAnimatable
  24506. */
  24507. getAnimatables(): IAnimatable[];
  24508. /**
  24509. * Modifies the mesh geometry according to the passed transformation matrix.
  24510. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24511. * The mesh normals are modified using the same transformation.
  24512. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24513. * @param transform defines the transform matrix to use
  24514. * @see http://doc.babylonjs.com/resources/baking_transformations
  24515. * @returns the current mesh
  24516. */
  24517. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24518. /**
  24519. * Modifies the mesh geometry according to its own current World Matrix.
  24520. * The mesh World Matrix is then reset.
  24521. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24522. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24523. * @see http://doc.babylonjs.com/resources/baking_transformations
  24524. * @returns the current mesh
  24525. */
  24526. bakeCurrentTransformIntoVertices(): Mesh;
  24527. /** @hidden */
  24528. readonly _positions: Nullable<Vector3[]>;
  24529. /** @hidden */
  24530. _resetPointsArrayCache(): Mesh;
  24531. /** @hidden */
  24532. _generatePointsArray(): boolean;
  24533. /**
  24534. * Returns a new Mesh object generated from the current mesh properties.
  24535. * This method must not get confused with createInstance()
  24536. * @param name is a string, the name given to the new mesh
  24537. * @param newParent can be any Node object (default `null`)
  24538. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24539. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24540. * @returns a new mesh
  24541. */
  24542. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24543. /**
  24544. * Releases resources associated with this mesh.
  24545. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24546. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24547. */
  24548. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24549. /**
  24550. * Modifies the mesh geometry according to a displacement map.
  24551. * 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.
  24552. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24553. * @param url is a string, the URL from the image file is to be downloaded.
  24554. * @param minHeight is the lower limit of the displacement.
  24555. * @param maxHeight is the upper limit of the displacement.
  24556. * @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.
  24557. * @param uvOffset is an optional vector2 used to offset UV.
  24558. * @param uvScale is an optional vector2 used to scale UV.
  24559. * @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.
  24560. * @returns the Mesh.
  24561. */
  24562. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24563. /**
  24564. * Modifies the mesh geometry according to a displacementMap buffer.
  24565. * 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.
  24566. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24567. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24568. * @param heightMapWidth is the width of the buffer image.
  24569. * @param heightMapHeight is the height of the buffer image.
  24570. * @param minHeight is the lower limit of the displacement.
  24571. * @param maxHeight is the upper limit of the displacement.
  24572. * @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.
  24573. * @param uvOffset is an optional vector2 used to offset UV.
  24574. * @param uvScale is an optional vector2 used to scale UV.
  24575. * @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.
  24576. * @returns the Mesh.
  24577. */
  24578. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24579. /**
  24580. * Modify the mesh to get a flat shading rendering.
  24581. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24582. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24583. * @returns current mesh
  24584. */
  24585. convertToFlatShadedMesh(): Mesh;
  24586. /**
  24587. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24588. * In other words, more vertices, no more indices and a single bigger VBO.
  24589. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24590. * @returns current mesh
  24591. */
  24592. convertToUnIndexedMesh(): Mesh;
  24593. /**
  24594. * Inverses facet orientations.
  24595. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24596. * @param flipNormals will also inverts the normals
  24597. * @returns current mesh
  24598. */
  24599. flipFaces(flipNormals?: boolean): Mesh;
  24600. /**
  24601. * Increase the number of facets and hence vertices in a mesh
  24602. * Vertex normals are interpolated from existing vertex normals
  24603. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24604. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24605. */
  24606. increaseVertices(numberPerEdge: number): void;
  24607. /**
  24608. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24609. * This will undo any application of covertToFlatShadedMesh
  24610. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24611. */
  24612. forceSharedVertices(): void;
  24613. /** @hidden */
  24614. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24615. /** @hidden */
  24616. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24617. /**
  24618. * Creates a new InstancedMesh object from the mesh model.
  24619. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24620. * @param name defines the name of the new instance
  24621. * @returns a new InstancedMesh
  24622. */
  24623. createInstance(name: string): InstancedMesh;
  24624. /**
  24625. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24626. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24627. * @returns the current mesh
  24628. */
  24629. synchronizeInstances(): Mesh;
  24630. /**
  24631. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24632. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24633. * This should be used together with the simplification to avoid disappearing triangles.
  24634. * @param successCallback an optional success callback to be called after the optimization finished.
  24635. * @returns the current mesh
  24636. */
  24637. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24638. /**
  24639. * Serialize current mesh
  24640. * @param serializationObject defines the object which will receive the serialization data
  24641. */
  24642. serialize(serializationObject: any): void;
  24643. /** @hidden */
  24644. _syncGeometryWithMorphTargetManager(): void;
  24645. /** @hidden */
  24646. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24647. /**
  24648. * Returns a new Mesh object parsed from the source provided.
  24649. * @param parsedMesh is the source
  24650. * @param scene defines the hosting scene
  24651. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24652. * @returns a new Mesh
  24653. */
  24654. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24655. /**
  24656. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24657. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24658. * @param name defines the name of the mesh to create
  24659. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24660. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24661. * @param closePath creates a seam between the first and the last points of each path of the path array
  24662. * @param offset is taken in account only if the `pathArray` is containing a single path
  24663. * @param scene defines the hosting scene
  24664. * @param updatable defines if the mesh must be flagged as updatable
  24665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24666. * @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)
  24667. * @returns a new Mesh
  24668. */
  24669. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24670. /**
  24671. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24672. * @param name defines the name of the mesh to create
  24673. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24674. * @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
  24675. * @param scene defines the hosting scene
  24676. * @param updatable defines if the mesh must be flagged as updatable
  24677. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24678. * @returns a new Mesh
  24679. */
  24680. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24681. /**
  24682. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24683. * @param name defines the name of the mesh to create
  24684. * @param size sets the size (float) of each box side (default 1)
  24685. * @param scene defines the hosting scene
  24686. * @param updatable defines if the mesh must be flagged as updatable
  24687. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24688. * @returns a new Mesh
  24689. */
  24690. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24691. /**
  24692. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24693. * @param name defines the name of the mesh to create
  24694. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24695. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24696. * @param scene defines the hosting scene
  24697. * @param updatable defines if the mesh must be flagged as updatable
  24698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24699. * @returns a new Mesh
  24700. */
  24701. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24702. /**
  24703. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24704. * @param name defines the name of the mesh to create
  24705. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24706. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24707. * @param scene defines the hosting scene
  24708. * @returns a new Mesh
  24709. */
  24710. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24711. /**
  24712. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24713. * @param name defines the name of the mesh to create
  24714. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24715. * @param diameterTop set the top cap diameter (floats, default 1)
  24716. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24717. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24718. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24719. * @param scene defines the hosting scene
  24720. * @param updatable defines if the mesh must be flagged as updatable
  24721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24722. * @returns a new Mesh
  24723. */
  24724. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24725. /**
  24726. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24727. * @param name defines the name of the mesh to create
  24728. * @param diameter sets the diameter size (float) of the torus (default 1)
  24729. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24730. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24731. * @param scene defines the hosting scene
  24732. * @param updatable defines if the mesh must be flagged as updatable
  24733. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24734. * @returns a new Mesh
  24735. */
  24736. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24737. /**
  24738. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24739. * @param name defines the name of the mesh to create
  24740. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24741. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24742. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24743. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24744. * @param p the number of windings on X axis (positive integers, default 2)
  24745. * @param q the number of windings on Y axis (positive integers, default 3)
  24746. * @param scene defines the hosting scene
  24747. * @param updatable defines if the mesh must be flagged as updatable
  24748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24749. * @returns a new Mesh
  24750. */
  24751. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24752. /**
  24753. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24754. * @param name defines the name of the mesh to create
  24755. * @param points is an array successive Vector3
  24756. * @param scene defines the hosting scene
  24757. * @param updatable defines if the mesh must be flagged as updatable
  24758. * @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).
  24759. * @returns a new Mesh
  24760. */
  24761. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24762. /**
  24763. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24764. * @param name defines the name of the mesh to create
  24765. * @param points is an array successive Vector3
  24766. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24767. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24768. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24769. * @param scene defines the hosting scene
  24770. * @param updatable defines if the mesh must be flagged as updatable
  24771. * @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)
  24772. * @returns a new Mesh
  24773. */
  24774. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24775. /**
  24776. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24777. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24778. * 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.
  24779. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24780. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24781. * Remember you can only change the shape positions, not their number when updating a polygon.
  24782. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24783. * @param name defines the name of the mesh to create
  24784. * @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
  24785. * @param scene defines the hosting scene
  24786. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24787. * @param updatable defines if the mesh must be flagged as updatable
  24788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24789. * @param earcutInjection can be used to inject your own earcut reference
  24790. * @returns a new Mesh
  24791. */
  24792. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24793. /**
  24794. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24795. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24796. * @param name defines the name of the mesh to create
  24797. * @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
  24798. * @param depth defines the height of extrusion
  24799. * @param scene defines the hosting scene
  24800. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24801. * @param updatable defines if the mesh must be flagged as updatable
  24802. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24803. * @param earcutInjection can be used to inject your own earcut reference
  24804. * @returns a new Mesh
  24805. */
  24806. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24807. /**
  24808. * Creates an extruded shape mesh.
  24809. * 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
  24810. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24811. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24812. * @param name defines the name of the mesh to create
  24813. * @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
  24814. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24815. * @param scale is the value to scale the shape
  24816. * @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
  24817. * @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
  24818. * @param scene defines the hosting scene
  24819. * @param updatable defines if the mesh must be flagged as updatable
  24820. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24821. * @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)
  24822. * @returns a new Mesh
  24823. */
  24824. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24825. /**
  24826. * Creates an custom extruded shape mesh.
  24827. * The custom extrusion is a parametric shape.
  24828. * It has no predefined shape. Its final shape will depend on the input parameters.
  24829. * Please consider using the same method from the MeshBuilder class instead
  24830. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24831. * @param name defines the name of the mesh to create
  24832. * @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
  24833. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24834. * @param scaleFunction is a custom Javascript function called on each path point
  24835. * @param rotationFunction is a custom Javascript function called on each path point
  24836. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24837. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24838. * @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
  24839. * @param scene defines the hosting scene
  24840. * @param updatable defines if the mesh must be flagged as updatable
  24841. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24842. * @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)
  24843. * @returns a new Mesh
  24844. */
  24845. 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;
  24846. /**
  24847. * Creates lathe mesh.
  24848. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24849. * Please consider using the same method from the MeshBuilder class instead
  24850. * @param name defines the name of the mesh to create
  24851. * @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
  24852. * @param radius is the radius value of the lathe
  24853. * @param tessellation is the side number of the lathe.
  24854. * @param scene defines the hosting scene
  24855. * @param updatable defines if the mesh must be flagged as updatable
  24856. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24857. * @returns a new Mesh
  24858. */
  24859. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24860. /**
  24861. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24862. * @param name defines the name of the mesh to create
  24863. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24864. * @param scene defines the hosting scene
  24865. * @param updatable defines if the mesh must be flagged as updatable
  24866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24867. * @returns a new Mesh
  24868. */
  24869. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24870. /**
  24871. * Creates a ground mesh.
  24872. * Please consider using the same method from the MeshBuilder class instead
  24873. * @param name defines the name of the mesh to create
  24874. * @param width set the width of the ground
  24875. * @param height set the height of the ground
  24876. * @param subdivisions sets the number of subdivisions per side
  24877. * @param scene defines the hosting scene
  24878. * @param updatable defines if the mesh must be flagged as updatable
  24879. * @returns a new Mesh
  24880. */
  24881. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24882. /**
  24883. * Creates a tiled ground mesh.
  24884. * Please consider using the same method from the MeshBuilder class instead
  24885. * @param name defines the name of the mesh to create
  24886. * @param xmin set the ground minimum X coordinate
  24887. * @param zmin set the ground minimum Y coordinate
  24888. * @param xmax set the ground maximum X coordinate
  24889. * @param zmax set the ground maximum Z coordinate
  24890. * @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
  24891. * @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
  24892. * @param scene defines the hosting scene
  24893. * @param updatable defines if the mesh must be flagged as updatable
  24894. * @returns a new Mesh
  24895. */
  24896. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24897. w: number;
  24898. h: number;
  24899. }, precision: {
  24900. w: number;
  24901. h: number;
  24902. }, scene: Scene, updatable?: boolean): Mesh;
  24903. /**
  24904. * Creates a ground mesh from a height map.
  24905. * Please consider using the same method from the MeshBuilder class instead
  24906. * @see http://doc.babylonjs.com/babylon101/height_map
  24907. * @param name defines the name of the mesh to create
  24908. * @param url sets the URL of the height map image resource
  24909. * @param width set the ground width size
  24910. * @param height set the ground height size
  24911. * @param subdivisions sets the number of subdivision per side
  24912. * @param minHeight is the minimum altitude on the ground
  24913. * @param maxHeight is the maximum altitude on the ground
  24914. * @param scene defines the hosting scene
  24915. * @param updatable defines if the mesh must be flagged as updatable
  24916. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24917. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24918. * @returns a new Mesh
  24919. */
  24920. 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;
  24921. /**
  24922. * Creates a tube mesh.
  24923. * The tube is a parametric shape.
  24924. * It has no predefined shape. Its final shape will depend on the input parameters.
  24925. * Please consider using the same method from the MeshBuilder class instead
  24926. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24927. * @param name defines the name of the mesh to create
  24928. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24929. * @param radius sets the tube radius size
  24930. * @param tessellation is the number of sides on the tubular surface
  24931. * @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
  24932. * @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
  24933. * @param scene defines the hosting scene
  24934. * @param updatable defines if the mesh must be flagged as updatable
  24935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24936. * @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)
  24937. * @returns a new Mesh
  24938. */
  24939. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24940. (i: number, distance: number): number;
  24941. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24942. /**
  24943. * Creates a polyhedron mesh.
  24944. * Please consider using the same method from the MeshBuilder class instead.
  24945. * * 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
  24946. * * The parameter `size` (positive float, default 1) sets the polygon size
  24947. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24948. * * 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`
  24949. * * 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
  24950. * * 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)`)
  24951. * * 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
  24952. * * 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
  24953. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24954. * * If you create a double-sided mesh, you can choose what parts of 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
  24955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24956. * @param name defines the name of the mesh to create
  24957. * @param options defines the options used to create the mesh
  24958. * @param scene defines the hosting scene
  24959. * @returns a new Mesh
  24960. */
  24961. static CreatePolyhedron(name: string, options: {
  24962. type?: number;
  24963. size?: number;
  24964. sizeX?: number;
  24965. sizeY?: number;
  24966. sizeZ?: number;
  24967. custom?: any;
  24968. faceUV?: Vector4[];
  24969. faceColors?: Color4[];
  24970. updatable?: boolean;
  24971. sideOrientation?: number;
  24972. }, scene: Scene): Mesh;
  24973. /**
  24974. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24975. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24976. * * 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`)
  24977. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24978. * * 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
  24979. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24980. * * If you create a double-sided mesh, you can choose what parts of 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
  24981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24982. * @param name defines the name of the mesh
  24983. * @param options defines the options used to create the mesh
  24984. * @param scene defines the hosting scene
  24985. * @returns a new Mesh
  24986. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24987. */
  24988. static CreateIcoSphere(name: string, options: {
  24989. radius?: number;
  24990. flat?: boolean;
  24991. subdivisions?: number;
  24992. sideOrientation?: number;
  24993. updatable?: boolean;
  24994. }, scene: Scene): Mesh;
  24995. /**
  24996. * Creates a decal mesh.
  24997. * Please consider using the same method from the MeshBuilder class instead.
  24998. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24999. * @param name defines the name of the mesh
  25000. * @param sourceMesh defines the mesh receiving the decal
  25001. * @param position sets the position of the decal in world coordinates
  25002. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25003. * @param size sets the decal scaling
  25004. * @param angle sets the angle to rotate the decal
  25005. * @returns a new Mesh
  25006. */
  25007. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25008. /**
  25009. * Prepare internal position array for software CPU skinning
  25010. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25011. */
  25012. setPositionsForCPUSkinning(): Float32Array;
  25013. /**
  25014. * Prepare internal normal array for software CPU skinning
  25015. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25016. */
  25017. setNormalsForCPUSkinning(): Float32Array;
  25018. /**
  25019. * Updates the vertex buffer by applying transformation from the bones
  25020. * @param skeleton defines the skeleton to apply to current mesh
  25021. * @returns the current mesh
  25022. */
  25023. applySkeleton(skeleton: Skeleton): Mesh;
  25024. /**
  25025. * 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
  25026. * @param meshes defines the list of meshes to scan
  25027. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25028. */
  25029. static MinMax(meshes: AbstractMesh[]): {
  25030. min: Vector3;
  25031. max: Vector3;
  25032. };
  25033. /**
  25034. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25035. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25036. * @returns a vector3
  25037. */
  25038. static Center(meshesOrMinMaxVector: {
  25039. min: Vector3;
  25040. max: Vector3;
  25041. } | AbstractMesh[]): Vector3;
  25042. /**
  25043. * Merge the array of meshes into a single mesh for performance reasons.
  25044. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25045. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25046. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25047. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25048. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25049. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25050. * @returns a new mesh
  25051. */
  25052. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25053. /** @hidden */
  25054. addInstance(instance: InstancedMesh): void;
  25055. /** @hidden */
  25056. removeInstance(instance: InstancedMesh): void;
  25057. }
  25058. }
  25059. declare module "babylonjs/Cameras/camera" {
  25060. import { SmartArray } from "babylonjs/Misc/smartArray";
  25061. import { Observable } from "babylonjs/Misc/observable";
  25062. import { Nullable } from "babylonjs/types";
  25063. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25064. import { Scene } from "babylonjs/scene";
  25065. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25066. import { Node } from "babylonjs/node";
  25067. import { Mesh } from "babylonjs/Meshes/mesh";
  25068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25069. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25070. import { Viewport } from "babylonjs/Maths/math.viewport";
  25071. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25072. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25074. import { Ray } from "babylonjs/Culling/ray";
  25075. /**
  25076. * This is the base class of all the camera used in the application.
  25077. * @see http://doc.babylonjs.com/features/cameras
  25078. */
  25079. export class Camera extends Node {
  25080. /** @hidden */
  25081. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25082. /**
  25083. * This is the default projection mode used by the cameras.
  25084. * It helps recreating a feeling of perspective and better appreciate depth.
  25085. * This is the best way to simulate real life cameras.
  25086. */
  25087. static readonly PERSPECTIVE_CAMERA: number;
  25088. /**
  25089. * This helps creating camera with an orthographic mode.
  25090. * 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.
  25091. */
  25092. static readonly ORTHOGRAPHIC_CAMERA: number;
  25093. /**
  25094. * This is the default FOV mode for perspective cameras.
  25095. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25096. */
  25097. static readonly FOVMODE_VERTICAL_FIXED: number;
  25098. /**
  25099. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25100. */
  25101. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25102. /**
  25103. * This specifies ther is no need for a camera rig.
  25104. * Basically only one eye is rendered corresponding to the camera.
  25105. */
  25106. static readonly RIG_MODE_NONE: number;
  25107. /**
  25108. * Simulates a camera Rig with one blue eye and one red eye.
  25109. * This can be use with 3d blue and red glasses.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25112. /**
  25113. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25114. */
  25115. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25116. /**
  25117. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25118. */
  25119. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25120. /**
  25121. * Defines that both eyes of the camera will be rendered over under each other.
  25122. */
  25123. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25124. /**
  25125. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25126. */
  25127. static readonly RIG_MODE_VR: number;
  25128. /**
  25129. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25130. */
  25131. static readonly RIG_MODE_WEBVR: number;
  25132. /**
  25133. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25134. */
  25135. static readonly RIG_MODE_CUSTOM: number;
  25136. /**
  25137. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25138. */
  25139. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25140. /**
  25141. * Define the input manager associated with the camera.
  25142. */
  25143. inputs: CameraInputsManager<Camera>;
  25144. /** @hidden */
  25145. _position: Vector3;
  25146. /**
  25147. * Define the current local position of the camera in the scene
  25148. */
  25149. position: Vector3;
  25150. /**
  25151. * The vector the camera should consider as up.
  25152. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25153. */
  25154. upVector: Vector3;
  25155. /**
  25156. * Define the current limit on the left side for an orthographic camera
  25157. * In scene unit
  25158. */
  25159. orthoLeft: Nullable<number>;
  25160. /**
  25161. * Define the current limit on the right side for an orthographic camera
  25162. * In scene unit
  25163. */
  25164. orthoRight: Nullable<number>;
  25165. /**
  25166. * Define the current limit on the bottom side for an orthographic camera
  25167. * In scene unit
  25168. */
  25169. orthoBottom: Nullable<number>;
  25170. /**
  25171. * Define the current limit on the top side for an orthographic camera
  25172. * In scene unit
  25173. */
  25174. orthoTop: Nullable<number>;
  25175. /**
  25176. * Field Of View is set in Radians. (default is 0.8)
  25177. */
  25178. fov: number;
  25179. /**
  25180. * Define the minimum distance the camera can see from.
  25181. * This is important to note that the depth buffer are not infinite and the closer it starts
  25182. * the more your scene might encounter depth fighting issue.
  25183. */
  25184. minZ: number;
  25185. /**
  25186. * Define the maximum distance the camera can see to.
  25187. * This is important to note that the depth buffer are not infinite and the further it end
  25188. * the more your scene might encounter depth fighting issue.
  25189. */
  25190. maxZ: number;
  25191. /**
  25192. * Define the default inertia of the camera.
  25193. * This helps giving a smooth feeling to the camera movement.
  25194. */
  25195. inertia: number;
  25196. /**
  25197. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25198. */
  25199. mode: number;
  25200. /**
  25201. * Define wether the camera is intermediate.
  25202. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25203. */
  25204. isIntermediate: boolean;
  25205. /**
  25206. * Define the viewport of the camera.
  25207. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25208. */
  25209. viewport: Viewport;
  25210. /**
  25211. * Restricts the camera to viewing objects with the same layerMask.
  25212. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25213. */
  25214. layerMask: number;
  25215. /**
  25216. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25217. */
  25218. fovMode: number;
  25219. /**
  25220. * Rig mode of the camera.
  25221. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25222. * This is normally controlled byt the camera themselves as internal use.
  25223. */
  25224. cameraRigMode: number;
  25225. /**
  25226. * Defines the distance between both "eyes" in case of a RIG
  25227. */
  25228. interaxialDistance: number;
  25229. /**
  25230. * Defines if stereoscopic rendering is done side by side or over under.
  25231. */
  25232. isStereoscopicSideBySide: boolean;
  25233. /**
  25234. * 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
  25235. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25236. * else in the scene. (Eg. security camera)
  25237. *
  25238. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25239. */
  25240. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25241. /**
  25242. * When set, the camera will render to this render target instead of the default canvas
  25243. *
  25244. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25245. */
  25246. outputRenderTarget: Nullable<RenderTargetTexture>;
  25247. /**
  25248. * Observable triggered when the camera view matrix has changed.
  25249. */
  25250. onViewMatrixChangedObservable: Observable<Camera>;
  25251. /**
  25252. * Observable triggered when the camera Projection matrix has changed.
  25253. */
  25254. onProjectionMatrixChangedObservable: Observable<Camera>;
  25255. /**
  25256. * Observable triggered when the inputs have been processed.
  25257. */
  25258. onAfterCheckInputsObservable: Observable<Camera>;
  25259. /**
  25260. * Observable triggered when reset has been called and applied to the camera.
  25261. */
  25262. onRestoreStateObservable: Observable<Camera>;
  25263. /** @hidden */
  25264. _cameraRigParams: any;
  25265. /** @hidden */
  25266. _rigCameras: Camera[];
  25267. /** @hidden */
  25268. _rigPostProcess: Nullable<PostProcess>;
  25269. protected _webvrViewMatrix: Matrix;
  25270. /** @hidden */
  25271. _skipRendering: boolean;
  25272. /** @hidden */
  25273. _projectionMatrix: Matrix;
  25274. /** @hidden */
  25275. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25276. /** @hidden */
  25277. _activeMeshes: SmartArray<AbstractMesh>;
  25278. protected _globalPosition: Vector3;
  25279. /** @hidden */
  25280. _computedViewMatrix: Matrix;
  25281. private _doNotComputeProjectionMatrix;
  25282. private _transformMatrix;
  25283. private _frustumPlanes;
  25284. private _refreshFrustumPlanes;
  25285. private _storedFov;
  25286. private _stateStored;
  25287. /**
  25288. * Instantiates a new camera object.
  25289. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25290. * @see http://doc.babylonjs.com/features/cameras
  25291. * @param name Defines the name of the camera in the scene
  25292. * @param position Defines the position of the camera
  25293. * @param scene Defines the scene the camera belongs too
  25294. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25295. */
  25296. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25297. /**
  25298. * Store current camera state (fov, position, etc..)
  25299. * @returns the camera
  25300. */
  25301. storeState(): Camera;
  25302. /**
  25303. * Restores the camera state values if it has been stored. You must call storeState() first
  25304. */
  25305. protected _restoreStateValues(): boolean;
  25306. /**
  25307. * Restored camera state. You must call storeState() first.
  25308. * @returns true if restored and false otherwise
  25309. */
  25310. restoreState(): boolean;
  25311. /**
  25312. * Gets the class name of the camera.
  25313. * @returns the class name
  25314. */
  25315. getClassName(): string;
  25316. /** @hidden */
  25317. readonly _isCamera: boolean;
  25318. /**
  25319. * Gets a string representation of the camera useful for debug purpose.
  25320. * @param fullDetails Defines that a more verboe level of logging is required
  25321. * @returns the string representation
  25322. */
  25323. toString(fullDetails?: boolean): string;
  25324. /**
  25325. * Gets the current world space position of the camera.
  25326. */
  25327. readonly globalPosition: Vector3;
  25328. /**
  25329. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25330. * @returns the active meshe list
  25331. */
  25332. getActiveMeshes(): SmartArray<AbstractMesh>;
  25333. /**
  25334. * Check wether a mesh is part of the current active mesh list of the camera
  25335. * @param mesh Defines the mesh to check
  25336. * @returns true if active, false otherwise
  25337. */
  25338. isActiveMesh(mesh: Mesh): boolean;
  25339. /**
  25340. * Is this camera ready to be used/rendered
  25341. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25342. * @return true if the camera is ready
  25343. */
  25344. isReady(completeCheck?: boolean): boolean;
  25345. /** @hidden */
  25346. _initCache(): void;
  25347. /** @hidden */
  25348. _updateCache(ignoreParentClass?: boolean): void;
  25349. /** @hidden */
  25350. _isSynchronized(): boolean;
  25351. /** @hidden */
  25352. _isSynchronizedViewMatrix(): boolean;
  25353. /** @hidden */
  25354. _isSynchronizedProjectionMatrix(): boolean;
  25355. /**
  25356. * Attach the input controls to a specific dom element to get the input from.
  25357. * @param element Defines the element the controls should be listened from
  25358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25359. */
  25360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25361. /**
  25362. * Detach the current controls from the specified dom element.
  25363. * @param element Defines the element to stop listening the inputs from
  25364. */
  25365. detachControl(element: HTMLElement): void;
  25366. /**
  25367. * Update the camera state according to the different inputs gathered during the frame.
  25368. */
  25369. update(): void;
  25370. /** @hidden */
  25371. _checkInputs(): void;
  25372. /** @hidden */
  25373. readonly rigCameras: Camera[];
  25374. /**
  25375. * Gets the post process used by the rig cameras
  25376. */
  25377. readonly rigPostProcess: Nullable<PostProcess>;
  25378. /**
  25379. * Internal, gets the first post proces.
  25380. * @returns the first post process to be run on this camera.
  25381. */
  25382. _getFirstPostProcess(): Nullable<PostProcess>;
  25383. private _cascadePostProcessesToRigCams;
  25384. /**
  25385. * Attach a post process to the camera.
  25386. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25387. * @param postProcess The post process to attach to the camera
  25388. * @param insertAt The position of the post process in case several of them are in use in the scene
  25389. * @returns the position the post process has been inserted at
  25390. */
  25391. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25392. /**
  25393. * Detach a post process to the camera.
  25394. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25395. * @param postProcess The post process to detach from the camera
  25396. */
  25397. detachPostProcess(postProcess: PostProcess): void;
  25398. /**
  25399. * Gets the current world matrix of the camera
  25400. */
  25401. getWorldMatrix(): Matrix;
  25402. /** @hidden */
  25403. _getViewMatrix(): Matrix;
  25404. /**
  25405. * Gets the current view matrix of the camera.
  25406. * @param force forces the camera to recompute the matrix without looking at the cached state
  25407. * @returns the view matrix
  25408. */
  25409. getViewMatrix(force?: boolean): Matrix;
  25410. /**
  25411. * Freeze the projection matrix.
  25412. * It will prevent the cache check of the camera projection compute and can speed up perf
  25413. * if no parameter of the camera are meant to change
  25414. * @param projection Defines manually a projection if necessary
  25415. */
  25416. freezeProjectionMatrix(projection?: Matrix): void;
  25417. /**
  25418. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25419. */
  25420. unfreezeProjectionMatrix(): void;
  25421. /**
  25422. * Gets the current projection matrix of the camera.
  25423. * @param force forces the camera to recompute the matrix without looking at the cached state
  25424. * @returns the projection matrix
  25425. */
  25426. getProjectionMatrix(force?: boolean): Matrix;
  25427. /**
  25428. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25429. * @returns a Matrix
  25430. */
  25431. getTransformationMatrix(): Matrix;
  25432. private _updateFrustumPlanes;
  25433. /**
  25434. * Checks if a cullable object (mesh...) is in the camera frustum
  25435. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25436. * @param target The object to check
  25437. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25438. * @returns true if the object is in frustum otherwise false
  25439. */
  25440. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25441. /**
  25442. * Checks if a cullable object (mesh...) is in the camera frustum
  25443. * Unlike isInFrustum this cheks the full bounding box
  25444. * @param target The object to check
  25445. * @returns true if the object is in frustum otherwise false
  25446. */
  25447. isCompletelyInFrustum(target: ICullable): boolean;
  25448. /**
  25449. * Gets a ray in the forward direction from the camera.
  25450. * @param length Defines the length of the ray to create
  25451. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25452. * @param origin Defines the start point of the ray which defaults to the camera position
  25453. * @returns the forward ray
  25454. */
  25455. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25456. /**
  25457. * Releases resources associated with this node.
  25458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25460. */
  25461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25462. /** @hidden */
  25463. _isLeftCamera: boolean;
  25464. /**
  25465. * Gets the left camera of a rig setup in case of Rigged Camera
  25466. */
  25467. readonly isLeftCamera: boolean;
  25468. /** @hidden */
  25469. _isRightCamera: boolean;
  25470. /**
  25471. * Gets the right camera of a rig setup in case of Rigged Camera
  25472. */
  25473. readonly isRightCamera: boolean;
  25474. /**
  25475. * Gets the left camera of a rig setup in case of Rigged Camera
  25476. */
  25477. readonly leftCamera: Nullable<FreeCamera>;
  25478. /**
  25479. * Gets the right camera of a rig setup in case of Rigged Camera
  25480. */
  25481. readonly rightCamera: Nullable<FreeCamera>;
  25482. /**
  25483. * Gets the left camera target of a rig setup in case of Rigged Camera
  25484. * @returns the target position
  25485. */
  25486. getLeftTarget(): Nullable<Vector3>;
  25487. /**
  25488. * Gets the right camera target of a rig setup in case of Rigged Camera
  25489. * @returns the target position
  25490. */
  25491. getRightTarget(): Nullable<Vector3>;
  25492. /**
  25493. * @hidden
  25494. */
  25495. setCameraRigMode(mode: number, rigParams: any): void;
  25496. /** @hidden */
  25497. static _setStereoscopicRigMode(camera: Camera): void;
  25498. /** @hidden */
  25499. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25500. /** @hidden */
  25501. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25502. /** @hidden */
  25503. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25504. /** @hidden */
  25505. _getVRProjectionMatrix(): Matrix;
  25506. protected _updateCameraRotationMatrix(): void;
  25507. protected _updateWebVRCameraRotationMatrix(): void;
  25508. /**
  25509. * This function MUST be overwritten by the different WebVR cameras available.
  25510. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25511. * @hidden
  25512. */
  25513. _getWebVRProjectionMatrix(): Matrix;
  25514. /**
  25515. * This function MUST be overwritten by the different WebVR cameras available.
  25516. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25517. * @hidden
  25518. */
  25519. _getWebVRViewMatrix(): Matrix;
  25520. /** @hidden */
  25521. setCameraRigParameter(name: string, value: any): void;
  25522. /**
  25523. * needs to be overridden by children so sub has required properties to be copied
  25524. * @hidden
  25525. */
  25526. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25527. /**
  25528. * May need to be overridden by children
  25529. * @hidden
  25530. */
  25531. _updateRigCameras(): void;
  25532. /** @hidden */
  25533. _setupInputs(): void;
  25534. /**
  25535. * Serialiaze the camera setup to a json represention
  25536. * @returns the JSON representation
  25537. */
  25538. serialize(): any;
  25539. /**
  25540. * Clones the current camera.
  25541. * @param name The cloned camera name
  25542. * @returns the cloned camera
  25543. */
  25544. clone(name: string): Camera;
  25545. /**
  25546. * Gets the direction of the camera relative to a given local axis.
  25547. * @param localAxis Defines the reference axis to provide a relative direction.
  25548. * @return the direction
  25549. */
  25550. getDirection(localAxis: Vector3): Vector3;
  25551. /**
  25552. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25553. * @param localAxis Defines the reference axis to provide a relative direction.
  25554. * @param result Defines the vector to store the result in
  25555. */
  25556. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25557. /**
  25558. * Gets a camera constructor for a given camera type
  25559. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25560. * @param name The name of the camera the result will be able to instantiate
  25561. * @param scene The scene the result will construct the camera in
  25562. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25563. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25564. * @returns a factory method to construc the camera
  25565. */
  25566. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25567. /**
  25568. * Compute the world matrix of the camera.
  25569. * @returns the camera workd matrix
  25570. */
  25571. computeWorldMatrix(): Matrix;
  25572. /**
  25573. * Parse a JSON and creates the camera from the parsed information
  25574. * @param parsedCamera The JSON to parse
  25575. * @param scene The scene to instantiate the camera in
  25576. * @returns the newly constructed camera
  25577. */
  25578. static Parse(parsedCamera: any, scene: Scene): Camera;
  25579. }
  25580. }
  25581. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25582. import { Nullable } from "babylonjs/types";
  25583. import { Scene } from "babylonjs/scene";
  25584. import { Vector4 } from "babylonjs/Maths/math.vector";
  25585. import { Mesh } from "babylonjs/Meshes/mesh";
  25586. /**
  25587. * Class containing static functions to help procedurally build meshes
  25588. */
  25589. export class DiscBuilder {
  25590. /**
  25591. * Creates a plane polygonal mesh. By default, this is a disc
  25592. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25593. * * 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
  25594. * * 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
  25595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25598. * @param name defines the name of the mesh
  25599. * @param options defines the options used to create the mesh
  25600. * @param scene defines the hosting scene
  25601. * @returns the plane polygonal mesh
  25602. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25603. */
  25604. static CreateDisc(name: string, options: {
  25605. radius?: number;
  25606. tessellation?: number;
  25607. arc?: number;
  25608. updatable?: boolean;
  25609. sideOrientation?: number;
  25610. frontUVs?: Vector4;
  25611. backUVs?: Vector4;
  25612. }, scene?: Nullable<Scene>): Mesh;
  25613. }
  25614. }
  25615. declare module "babylonjs/Particles/solidParticleSystem" {
  25616. import { Vector3 } from "babylonjs/Maths/math.vector";
  25617. import { Mesh } from "babylonjs/Meshes/mesh";
  25618. import { Scene, IDisposable } from "babylonjs/scene";
  25619. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25620. /**
  25621. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25622. *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.
  25623. * The SPS is also a particle system. It provides some methods to manage the particles.
  25624. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25625. *
  25626. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25627. */
  25628. export class SolidParticleSystem implements IDisposable {
  25629. /**
  25630. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25631. * Example : var p = SPS.particles[i];
  25632. */
  25633. particles: SolidParticle[];
  25634. /**
  25635. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25636. */
  25637. nbParticles: number;
  25638. /**
  25639. * If the particles must ever face the camera (default false). Useful for planar particles.
  25640. */
  25641. billboard: boolean;
  25642. /**
  25643. * Recompute normals when adding a shape
  25644. */
  25645. recomputeNormals: boolean;
  25646. /**
  25647. * This a counter ofr your own usage. It's not set by any SPS functions.
  25648. */
  25649. counter: number;
  25650. /**
  25651. * The SPS name. This name is also given to the underlying mesh.
  25652. */
  25653. name: string;
  25654. /**
  25655. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25656. */
  25657. mesh: Mesh;
  25658. /**
  25659. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25660. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25661. */
  25662. vars: any;
  25663. /**
  25664. * This array is populated when the SPS is set as 'pickable'.
  25665. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25666. * Each element of this array is an object `{idx: int, faceId: int}`.
  25667. * `idx` is the picked particle index in the `SPS.particles` array
  25668. * `faceId` is the picked face index counted within this particle.
  25669. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25670. */
  25671. pickedParticles: {
  25672. idx: number;
  25673. faceId: number;
  25674. }[];
  25675. /**
  25676. * This array is populated when `enableDepthSort` is set to true.
  25677. * Each element of this array is an instance of the class DepthSortedParticle.
  25678. */
  25679. depthSortedParticles: DepthSortedParticle[];
  25680. /**
  25681. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25682. * @hidden
  25683. */
  25684. _bSphereOnly: boolean;
  25685. /**
  25686. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25687. * @hidden
  25688. */
  25689. _bSphereRadiusFactor: number;
  25690. private _scene;
  25691. private _positions;
  25692. private _indices;
  25693. private _normals;
  25694. private _colors;
  25695. private _uvs;
  25696. private _indices32;
  25697. private _positions32;
  25698. private _normals32;
  25699. private _fixedNormal32;
  25700. private _colors32;
  25701. private _uvs32;
  25702. private _index;
  25703. private _updatable;
  25704. private _pickable;
  25705. private _isVisibilityBoxLocked;
  25706. private _alwaysVisible;
  25707. private _depthSort;
  25708. private _shapeCounter;
  25709. private _copy;
  25710. private _color;
  25711. private _computeParticleColor;
  25712. private _computeParticleTexture;
  25713. private _computeParticleRotation;
  25714. private _computeParticleVertex;
  25715. private _computeBoundingBox;
  25716. private _depthSortParticles;
  25717. private _camera;
  25718. private _mustUnrotateFixedNormals;
  25719. private _particlesIntersect;
  25720. private _needs32Bits;
  25721. /**
  25722. * Creates a SPS (Solid Particle System) object.
  25723. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25724. * @param scene (Scene) is the scene in which the SPS is added.
  25725. * @param options defines the options of the sps e.g.
  25726. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25727. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25728. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25729. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25730. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25731. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25732. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25733. */
  25734. constructor(name: string, scene: Scene, options?: {
  25735. updatable?: boolean;
  25736. isPickable?: boolean;
  25737. enableDepthSort?: boolean;
  25738. particleIntersection?: boolean;
  25739. boundingSphereOnly?: boolean;
  25740. bSphereRadiusFactor?: number;
  25741. });
  25742. /**
  25743. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25744. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25745. * @returns the created mesh
  25746. */
  25747. buildMesh(): Mesh;
  25748. /**
  25749. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25750. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25751. * Thus the particles generated from `digest()` have their property `position` set yet.
  25752. * @param mesh ( Mesh ) is the mesh to be digested
  25753. * @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
  25754. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25755. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25756. * @returns the current SPS
  25757. */
  25758. digest(mesh: Mesh, options?: {
  25759. facetNb?: number;
  25760. number?: number;
  25761. delta?: number;
  25762. }): SolidParticleSystem;
  25763. private _unrotateFixedNormals;
  25764. private _resetCopy;
  25765. private _meshBuilder;
  25766. private _posToShape;
  25767. private _uvsToShapeUV;
  25768. private _addParticle;
  25769. /**
  25770. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25771. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25772. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25773. * @param nb (positive integer) the number of particles to be created from this model
  25774. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25775. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25776. * @returns the number of shapes in the system
  25777. */
  25778. addShape(mesh: Mesh, nb: number, options?: {
  25779. positionFunction?: any;
  25780. vertexFunction?: any;
  25781. }): number;
  25782. private _rebuildParticle;
  25783. /**
  25784. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25785. * @returns the SPS.
  25786. */
  25787. rebuildMesh(): SolidParticleSystem;
  25788. /**
  25789. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25790. * This method calls `updateParticle()` for each particle of the SPS.
  25791. * For an animated SPS, it is usually called within the render loop.
  25792. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25793. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25794. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25795. * @returns the SPS.
  25796. */
  25797. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25798. /**
  25799. * Disposes the SPS.
  25800. */
  25801. dispose(): void;
  25802. /**
  25803. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25805. * @returns the SPS.
  25806. */
  25807. refreshVisibleSize(): SolidParticleSystem;
  25808. /**
  25809. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25810. * @param size the size (float) of the visibility box
  25811. * note : this doesn't lock the SPS mesh bounding box.
  25812. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25813. */
  25814. setVisibilityBox(size: number): void;
  25815. /**
  25816. * Gets whether the SPS as always visible or not
  25817. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25818. */
  25819. /**
  25820. * Sets the SPS as always visible or not
  25821. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25822. */
  25823. isAlwaysVisible: boolean;
  25824. /**
  25825. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25826. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25827. */
  25828. /**
  25829. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25830. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25831. */
  25832. isVisibilityBoxLocked: boolean;
  25833. /**
  25834. * Tells to `setParticles()` to compute the particle rotations or not.
  25835. * Default value : true. The SPS is faster when it's set to false.
  25836. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25837. */
  25838. /**
  25839. * Gets if `setParticles()` computes the particle rotations or not.
  25840. * Default value : true. The SPS is faster when it's set to false.
  25841. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25842. */
  25843. computeParticleRotation: boolean;
  25844. /**
  25845. * Tells to `setParticles()` to compute the particle colors or not.
  25846. * Default value : true. The SPS is faster when it's set to false.
  25847. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25848. */
  25849. /**
  25850. * Gets if `setParticles()` computes the particle colors or not.
  25851. * Default value : true. The SPS is faster when it's set to false.
  25852. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25853. */
  25854. computeParticleColor: boolean;
  25855. /**
  25856. * Gets if `setParticles()` computes the particle textures or not.
  25857. * Default value : true. The SPS is faster when it's set to false.
  25858. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25859. */
  25860. computeParticleTexture: boolean;
  25861. /**
  25862. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25863. * Default value : false. The SPS is faster when it's set to false.
  25864. * Note : the particle custom vertex positions aren't stored values.
  25865. */
  25866. /**
  25867. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25868. * Default value : false. The SPS is faster when it's set to false.
  25869. * Note : the particle custom vertex positions aren't stored values.
  25870. */
  25871. computeParticleVertex: boolean;
  25872. /**
  25873. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25874. */
  25875. /**
  25876. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25877. */
  25878. computeBoundingBox: boolean;
  25879. /**
  25880. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25881. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25882. * Default : `true`
  25883. */
  25884. /**
  25885. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25886. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25887. * Default : `true`
  25888. */
  25889. depthSortParticles: boolean;
  25890. /**
  25891. * This function does nothing. It may be overwritten to set all the particle first values.
  25892. * The SPS doesn't call this function, you may have to call it by your own.
  25893. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25894. */
  25895. initParticles(): void;
  25896. /**
  25897. * This function does nothing. It may be overwritten to recycle a particle.
  25898. * The SPS doesn't call this function, you may have to call it by your own.
  25899. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25900. * @param particle The particle to recycle
  25901. * @returns the recycled particle
  25902. */
  25903. recycleParticle(particle: SolidParticle): SolidParticle;
  25904. /**
  25905. * Updates a particle : this function should be overwritten by the user.
  25906. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25907. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25908. * @example : just set a particle position or velocity and recycle conditions
  25909. * @param particle The particle to update
  25910. * @returns the updated particle
  25911. */
  25912. updateParticle(particle: SolidParticle): SolidParticle;
  25913. /**
  25914. * Updates a vertex of a particle : it can be overwritten by the user.
  25915. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25916. * @param particle the current particle
  25917. * @param vertex the current index of the current particle
  25918. * @param pt the index of the current vertex in the particle shape
  25919. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25920. * @example : just set a vertex particle position
  25921. * @returns the updated vertex
  25922. */
  25923. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25924. /**
  25925. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25926. * This does nothing and may be overwritten by the user.
  25927. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25928. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25929. * @param update the boolean update value actually passed to setParticles()
  25930. */
  25931. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25932. /**
  25933. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25934. * This will be passed three parameters.
  25935. * This does nothing and may be overwritten by the user.
  25936. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25937. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25938. * @param update the boolean update value actually passed to setParticles()
  25939. */
  25940. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25941. }
  25942. }
  25943. declare module "babylonjs/Particles/solidParticle" {
  25944. import { Nullable } from "babylonjs/types";
  25945. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25946. import { Color4 } from "babylonjs/Maths/math.color";
  25947. import { Mesh } from "babylonjs/Meshes/mesh";
  25948. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25949. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25950. import { Plane } from "babylonjs/Maths/math.plane";
  25951. /**
  25952. * Represents one particle of a solid particle system.
  25953. */
  25954. export class SolidParticle {
  25955. /**
  25956. * particle global index
  25957. */
  25958. idx: number;
  25959. /**
  25960. * The color of the particle
  25961. */
  25962. color: Nullable<Color4>;
  25963. /**
  25964. * The world space position of the particle.
  25965. */
  25966. position: Vector3;
  25967. /**
  25968. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25969. */
  25970. rotation: Vector3;
  25971. /**
  25972. * The world space rotation quaternion of the particle.
  25973. */
  25974. rotationQuaternion: Nullable<Quaternion>;
  25975. /**
  25976. * The scaling of the particle.
  25977. */
  25978. scaling: Vector3;
  25979. /**
  25980. * The uvs of the particle.
  25981. */
  25982. uvs: Vector4;
  25983. /**
  25984. * The current speed of the particle.
  25985. */
  25986. velocity: Vector3;
  25987. /**
  25988. * The pivot point in the particle local space.
  25989. */
  25990. pivot: Vector3;
  25991. /**
  25992. * Must the particle be translated from its pivot point in its local space ?
  25993. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25994. * Default : false
  25995. */
  25996. translateFromPivot: boolean;
  25997. /**
  25998. * Is the particle active or not ?
  25999. */
  26000. alive: boolean;
  26001. /**
  26002. * Is the particle visible or not ?
  26003. */
  26004. isVisible: boolean;
  26005. /**
  26006. * Index of this particle in the global "positions" array (Internal use)
  26007. * @hidden
  26008. */
  26009. _pos: number;
  26010. /**
  26011. * @hidden Index of this particle in the global "indices" array (Internal use)
  26012. */
  26013. _ind: number;
  26014. /**
  26015. * @hidden ModelShape of this particle (Internal use)
  26016. */
  26017. _model: ModelShape;
  26018. /**
  26019. * ModelShape id of this particle
  26020. */
  26021. shapeId: number;
  26022. /**
  26023. * Index of the particle in its shape id (Internal use)
  26024. */
  26025. idxInShape: number;
  26026. /**
  26027. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26028. */
  26029. _modelBoundingInfo: BoundingInfo;
  26030. /**
  26031. * @hidden Particle BoundingInfo object (Internal use)
  26032. */
  26033. _boundingInfo: BoundingInfo;
  26034. /**
  26035. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26036. */
  26037. _sps: SolidParticleSystem;
  26038. /**
  26039. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26040. */
  26041. _stillInvisible: boolean;
  26042. /**
  26043. * @hidden Last computed particle rotation matrix
  26044. */
  26045. _rotationMatrix: number[];
  26046. /**
  26047. * Parent particle Id, if any.
  26048. * Default null.
  26049. */
  26050. parentId: Nullable<number>;
  26051. /**
  26052. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26053. * The possible values are :
  26054. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26055. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26056. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26057. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26058. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26059. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26060. * */
  26061. cullingStrategy: number;
  26062. /**
  26063. * @hidden Internal global position in the SPS.
  26064. */
  26065. _globalPosition: Vector3;
  26066. /**
  26067. * Creates a Solid Particle object.
  26068. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26069. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26070. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26071. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26072. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26073. * @param shapeId (integer) is the model shape identifier in the SPS.
  26074. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26075. * @param sps defines the sps it is associated to
  26076. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26077. */
  26078. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26079. /**
  26080. * Legacy support, changed scale to scaling
  26081. */
  26082. /**
  26083. * Legacy support, changed scale to scaling
  26084. */
  26085. scale: Vector3;
  26086. /**
  26087. * Legacy support, changed quaternion to rotationQuaternion
  26088. */
  26089. /**
  26090. * Legacy support, changed quaternion to rotationQuaternion
  26091. */
  26092. quaternion: Nullable<Quaternion>;
  26093. /**
  26094. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26095. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26096. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26097. * @returns true if it intersects
  26098. */
  26099. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26100. /**
  26101. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26102. * A particle is in the frustum if its bounding box intersects the frustum
  26103. * @param frustumPlanes defines the frustum to test
  26104. * @returns true if the particle is in the frustum planes
  26105. */
  26106. isInFrustum(frustumPlanes: Plane[]): boolean;
  26107. /**
  26108. * get the rotation matrix of the particle
  26109. * @hidden
  26110. */
  26111. getRotationMatrix(m: Matrix): void;
  26112. }
  26113. /**
  26114. * Represents the shape of the model used by one particle of a solid particle system.
  26115. * SPS internal tool, don't use it manually.
  26116. */
  26117. export class ModelShape {
  26118. /**
  26119. * The shape id
  26120. * @hidden
  26121. */
  26122. shapeID: number;
  26123. /**
  26124. * flat array of model positions (internal use)
  26125. * @hidden
  26126. */
  26127. _shape: Vector3[];
  26128. /**
  26129. * flat array of model UVs (internal use)
  26130. * @hidden
  26131. */
  26132. _shapeUV: number[];
  26133. /**
  26134. * length of the shape in the model indices array (internal use)
  26135. * @hidden
  26136. */
  26137. _indicesLength: number;
  26138. /**
  26139. * Custom position function (internal use)
  26140. * @hidden
  26141. */
  26142. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26143. /**
  26144. * Custom vertex function (internal use)
  26145. * @hidden
  26146. */
  26147. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26148. /**
  26149. * 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.
  26150. * SPS internal tool, don't use it manually.
  26151. * @hidden
  26152. */
  26153. 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>);
  26154. }
  26155. /**
  26156. * Represents a Depth Sorted Particle in the solid particle system.
  26157. */
  26158. export class DepthSortedParticle {
  26159. /**
  26160. * Index of the particle in the "indices" array
  26161. */
  26162. ind: number;
  26163. /**
  26164. * Length of the particle shape in the "indices" array
  26165. */
  26166. indicesLength: number;
  26167. /**
  26168. * Squared distance from the particle to the camera
  26169. */
  26170. sqDistance: number;
  26171. }
  26172. }
  26173. declare module "babylonjs/Collisions/meshCollisionData" {
  26174. import { Collider } from "babylonjs/Collisions/collider";
  26175. import { Vector3 } from "babylonjs/Maths/math.vector";
  26176. import { Nullable } from "babylonjs/types";
  26177. import { Observer } from "babylonjs/Misc/observable";
  26178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26179. /**
  26180. * @hidden
  26181. */
  26182. export class _MeshCollisionData {
  26183. _checkCollisions: boolean;
  26184. _collisionMask: number;
  26185. _collisionGroup: number;
  26186. _collider: Nullable<Collider>;
  26187. _oldPositionForCollisions: Vector3;
  26188. _diffPositionForCollisions: Vector3;
  26189. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26190. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26191. }
  26192. }
  26193. declare module "babylonjs/Meshes/abstractMesh" {
  26194. import { Observable } from "babylonjs/Misc/observable";
  26195. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26196. import { Camera } from "babylonjs/Cameras/camera";
  26197. import { Scene, IDisposable } from "babylonjs/scene";
  26198. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26199. import { Node } from "babylonjs/node";
  26200. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26201. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26203. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26204. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26205. import { Material } from "babylonjs/Materials/material";
  26206. import { Light } from "babylonjs/Lights/light";
  26207. import { Skeleton } from "babylonjs/Bones/skeleton";
  26208. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26209. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26210. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26211. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26212. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26213. import { Plane } from "babylonjs/Maths/math.plane";
  26214. import { Ray } from "babylonjs/Culling/ray";
  26215. import { Collider } from "babylonjs/Collisions/collider";
  26216. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26217. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26218. /** @hidden */
  26219. class _FacetDataStorage {
  26220. facetPositions: Vector3[];
  26221. facetNormals: Vector3[];
  26222. facetPartitioning: number[][];
  26223. facetNb: number;
  26224. partitioningSubdivisions: number;
  26225. partitioningBBoxRatio: number;
  26226. facetDataEnabled: boolean;
  26227. facetParameters: any;
  26228. bbSize: Vector3;
  26229. subDiv: {
  26230. max: number;
  26231. X: number;
  26232. Y: number;
  26233. Z: number;
  26234. };
  26235. facetDepthSort: boolean;
  26236. facetDepthSortEnabled: boolean;
  26237. depthSortedIndices: IndicesArray;
  26238. depthSortedFacets: {
  26239. ind: number;
  26240. sqDistance: number;
  26241. }[];
  26242. facetDepthSortFunction: (f1: {
  26243. ind: number;
  26244. sqDistance: number;
  26245. }, f2: {
  26246. ind: number;
  26247. sqDistance: number;
  26248. }) => number;
  26249. facetDepthSortFrom: Vector3;
  26250. facetDepthSortOrigin: Vector3;
  26251. invertedMatrix: Matrix;
  26252. }
  26253. /**
  26254. * @hidden
  26255. **/
  26256. class _InternalAbstractMeshDataInfo {
  26257. _hasVertexAlpha: boolean;
  26258. _useVertexColors: boolean;
  26259. _numBoneInfluencers: number;
  26260. _applyFog: boolean;
  26261. _receiveShadows: boolean;
  26262. _facetData: _FacetDataStorage;
  26263. _visibility: number;
  26264. _skeleton: Nullable<Skeleton>;
  26265. _layerMask: number;
  26266. _computeBonesUsingShaders: boolean;
  26267. _isActive: boolean;
  26268. _onlyForInstances: boolean;
  26269. _isActiveIntermediate: boolean;
  26270. _onlyForInstancesIntermediate: boolean;
  26271. }
  26272. /**
  26273. * Class used to store all common mesh properties
  26274. */
  26275. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26276. /** No occlusion */
  26277. static OCCLUSION_TYPE_NONE: number;
  26278. /** Occlusion set to optimisitic */
  26279. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26280. /** Occlusion set to strict */
  26281. static OCCLUSION_TYPE_STRICT: number;
  26282. /** Use an accurante occlusion algorithm */
  26283. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26284. /** Use a conservative occlusion algorithm */
  26285. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26286. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26287. * Test order :
  26288. * Is the bounding sphere outside the frustum ?
  26289. * If not, are the bounding box vertices outside the frustum ?
  26290. * It not, then the cullable object is in the frustum.
  26291. */
  26292. static readonly CULLINGSTRATEGY_STANDARD: number;
  26293. /** Culling strategy : Bounding Sphere Only.
  26294. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26295. * It's also less accurate than the standard because some not visible objects can still be selected.
  26296. * Test : is the bounding sphere outside the frustum ?
  26297. * If not, then the cullable object is in the frustum.
  26298. */
  26299. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26300. /** Culling strategy : Optimistic Inclusion.
  26301. * This in an inclusion test first, then the standard exclusion test.
  26302. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26303. * 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.
  26304. * Anyway, it's as accurate as the standard strategy.
  26305. * Test :
  26306. * Is the cullable object bounding sphere center in the frustum ?
  26307. * If not, apply the default culling strategy.
  26308. */
  26309. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26310. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26311. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26312. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26313. * 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.
  26314. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26315. * Test :
  26316. * Is the cullable object bounding sphere center in the frustum ?
  26317. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26318. */
  26319. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26320. /**
  26321. * No billboard
  26322. */
  26323. static readonly BILLBOARDMODE_NONE: number;
  26324. /** Billboard on X axis */
  26325. static readonly BILLBOARDMODE_X: number;
  26326. /** Billboard on Y axis */
  26327. static readonly BILLBOARDMODE_Y: number;
  26328. /** Billboard on Z axis */
  26329. static readonly BILLBOARDMODE_Z: number;
  26330. /** Billboard on all axes */
  26331. static readonly BILLBOARDMODE_ALL: number;
  26332. /** Billboard on using position instead of orientation */
  26333. static readonly BILLBOARDMODE_USE_POSITION: number;
  26334. /** @hidden */
  26335. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26336. /**
  26337. * The culling strategy to use to check whether the mesh must be rendered or not.
  26338. * This value can be changed at any time and will be used on the next render mesh selection.
  26339. * The possible values are :
  26340. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26341. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26342. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26343. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26344. * Please read each static variable documentation to get details about the culling process.
  26345. * */
  26346. cullingStrategy: number;
  26347. /**
  26348. * Gets the number of facets in the mesh
  26349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26350. */
  26351. readonly facetNb: number;
  26352. /**
  26353. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26355. */
  26356. partitioningSubdivisions: number;
  26357. /**
  26358. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26359. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26361. */
  26362. partitioningBBoxRatio: number;
  26363. /**
  26364. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26365. * Works only for updatable meshes.
  26366. * Doesn't work with multi-materials
  26367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26368. */
  26369. mustDepthSortFacets: boolean;
  26370. /**
  26371. * The location (Vector3) where the facet depth sort must be computed from.
  26372. * By default, the active camera position.
  26373. * Used only when facet depth sort is enabled
  26374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26375. */
  26376. facetDepthSortFrom: Vector3;
  26377. /**
  26378. * gets a boolean indicating if facetData is enabled
  26379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26380. */
  26381. readonly isFacetDataEnabled: boolean;
  26382. /** @hidden */
  26383. _updateNonUniformScalingState(value: boolean): boolean;
  26384. /**
  26385. * An event triggered when this mesh collides with another one
  26386. */
  26387. onCollideObservable: Observable<AbstractMesh>;
  26388. /** Set a function to call when this mesh collides with another one */
  26389. onCollide: () => void;
  26390. /**
  26391. * An event triggered when the collision's position changes
  26392. */
  26393. onCollisionPositionChangeObservable: Observable<Vector3>;
  26394. /** Set a function to call when the collision's position changes */
  26395. onCollisionPositionChange: () => void;
  26396. /**
  26397. * An event triggered when material is changed
  26398. */
  26399. onMaterialChangedObservable: Observable<AbstractMesh>;
  26400. /**
  26401. * Gets or sets the orientation for POV movement & rotation
  26402. */
  26403. definedFacingForward: boolean;
  26404. /** @hidden */
  26405. _occlusionQuery: Nullable<WebGLQuery>;
  26406. /** @hidden */
  26407. _renderingGroup: Nullable<RenderingGroup>;
  26408. /**
  26409. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26410. */
  26411. /**
  26412. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26413. */
  26414. visibility: number;
  26415. /** Gets or sets the alpha index used to sort transparent meshes
  26416. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26417. */
  26418. alphaIndex: number;
  26419. /**
  26420. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26421. */
  26422. isVisible: boolean;
  26423. /**
  26424. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26425. */
  26426. isPickable: boolean;
  26427. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26428. showSubMeshesBoundingBox: boolean;
  26429. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26430. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26431. */
  26432. isBlocker: boolean;
  26433. /**
  26434. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26435. */
  26436. enablePointerMoveEvents: boolean;
  26437. /**
  26438. * Specifies the rendering group id for this mesh (0 by default)
  26439. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26440. */
  26441. renderingGroupId: number;
  26442. private _material;
  26443. /** Gets or sets current material */
  26444. material: Nullable<Material>;
  26445. /**
  26446. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26447. * @see http://doc.babylonjs.com/babylon101/shadows
  26448. */
  26449. receiveShadows: boolean;
  26450. /** Defines color to use when rendering outline */
  26451. outlineColor: Color3;
  26452. /** Define width to use when rendering outline */
  26453. outlineWidth: number;
  26454. /** Defines color to use when rendering overlay */
  26455. overlayColor: Color3;
  26456. /** Defines alpha to use when rendering overlay */
  26457. overlayAlpha: number;
  26458. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26459. hasVertexAlpha: boolean;
  26460. /** 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) */
  26461. useVertexColors: boolean;
  26462. /**
  26463. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26464. */
  26465. computeBonesUsingShaders: boolean;
  26466. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26467. numBoneInfluencers: number;
  26468. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26469. applyFog: boolean;
  26470. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26471. useOctreeForRenderingSelection: boolean;
  26472. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26473. useOctreeForPicking: boolean;
  26474. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26475. useOctreeForCollisions: boolean;
  26476. /**
  26477. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26478. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26479. */
  26480. layerMask: number;
  26481. /**
  26482. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26483. */
  26484. alwaysSelectAsActiveMesh: boolean;
  26485. /**
  26486. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26487. */
  26488. doNotSyncBoundingInfo: boolean;
  26489. /**
  26490. * Gets or sets the current action manager
  26491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26492. */
  26493. actionManager: Nullable<AbstractActionManager>;
  26494. private _meshCollisionData;
  26495. /**
  26496. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26498. */
  26499. ellipsoid: Vector3;
  26500. /**
  26501. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26503. */
  26504. ellipsoidOffset: Vector3;
  26505. /**
  26506. * Gets or sets a collision mask used to mask collisions (default is -1).
  26507. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26508. */
  26509. collisionMask: number;
  26510. /**
  26511. * Gets or sets the current collision group mask (-1 by default).
  26512. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26513. */
  26514. collisionGroup: number;
  26515. /**
  26516. * Defines edge width used when edgesRenderer is enabled
  26517. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26518. */
  26519. edgesWidth: number;
  26520. /**
  26521. * Defines edge color used when edgesRenderer is enabled
  26522. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26523. */
  26524. edgesColor: Color4;
  26525. /** @hidden */
  26526. _edgesRenderer: Nullable<IEdgesRenderer>;
  26527. /** @hidden */
  26528. _masterMesh: Nullable<AbstractMesh>;
  26529. /** @hidden */
  26530. _boundingInfo: Nullable<BoundingInfo>;
  26531. /** @hidden */
  26532. _renderId: number;
  26533. /**
  26534. * Gets or sets the list of subMeshes
  26535. * @see http://doc.babylonjs.com/how_to/multi_materials
  26536. */
  26537. subMeshes: SubMesh[];
  26538. /** @hidden */
  26539. _intersectionsInProgress: AbstractMesh[];
  26540. /** @hidden */
  26541. _unIndexed: boolean;
  26542. /** @hidden */
  26543. _lightSources: Light[];
  26544. /** Gets the list of lights affecting that mesh */
  26545. readonly lightSources: Light[];
  26546. /** @hidden */
  26547. readonly _positions: Nullable<Vector3[]>;
  26548. /** @hidden */
  26549. _waitingData: {
  26550. lods: Nullable<any>;
  26551. actions: Nullable<any>;
  26552. freezeWorldMatrix: Nullable<boolean>;
  26553. };
  26554. /** @hidden */
  26555. _bonesTransformMatrices: Nullable<Float32Array>;
  26556. /** @hidden */
  26557. _transformMatrixTexture: Nullable<RawTexture>;
  26558. /**
  26559. * Gets or sets a skeleton to apply skining transformations
  26560. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26561. */
  26562. skeleton: Nullable<Skeleton>;
  26563. /**
  26564. * An event triggered when the mesh is rebuilt.
  26565. */
  26566. onRebuildObservable: Observable<AbstractMesh>;
  26567. /**
  26568. * Creates a new AbstractMesh
  26569. * @param name defines the name of the mesh
  26570. * @param scene defines the hosting scene
  26571. */
  26572. constructor(name: string, scene?: Nullable<Scene>);
  26573. /**
  26574. * Returns the string "AbstractMesh"
  26575. * @returns "AbstractMesh"
  26576. */
  26577. getClassName(): string;
  26578. /**
  26579. * Gets a string representation of the current mesh
  26580. * @param fullDetails defines a boolean indicating if full details must be included
  26581. * @returns a string representation of the current mesh
  26582. */
  26583. toString(fullDetails?: boolean): string;
  26584. /**
  26585. * @hidden
  26586. */
  26587. protected _getEffectiveParent(): Nullable<Node>;
  26588. /** @hidden */
  26589. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26590. /** @hidden */
  26591. _rebuild(): void;
  26592. /** @hidden */
  26593. _resyncLightSources(): void;
  26594. /** @hidden */
  26595. _resyncLighSource(light: Light): void;
  26596. /** @hidden */
  26597. _unBindEffect(): void;
  26598. /** @hidden */
  26599. _removeLightSource(light: Light): void;
  26600. private _markSubMeshesAsDirty;
  26601. /** @hidden */
  26602. _markSubMeshesAsLightDirty(): void;
  26603. /** @hidden */
  26604. _markSubMeshesAsAttributesDirty(): void;
  26605. /** @hidden */
  26606. _markSubMeshesAsMiscDirty(): void;
  26607. /**
  26608. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26609. */
  26610. scaling: Vector3;
  26611. /**
  26612. * Returns true if the mesh is blocked. Implemented by child classes
  26613. */
  26614. readonly isBlocked: boolean;
  26615. /**
  26616. * Returns the mesh itself by default. Implemented by child classes
  26617. * @param camera defines the camera to use to pick the right LOD level
  26618. * @returns the currentAbstractMesh
  26619. */
  26620. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26621. /**
  26622. * Returns 0 by default. Implemented by child classes
  26623. * @returns an integer
  26624. */
  26625. getTotalVertices(): number;
  26626. /**
  26627. * Returns a positive integer : the total number of indices in this mesh geometry.
  26628. * @returns the numner of indices or zero if the mesh has no geometry.
  26629. */
  26630. getTotalIndices(): number;
  26631. /**
  26632. * Returns null by default. Implemented by child classes
  26633. * @returns null
  26634. */
  26635. getIndices(): Nullable<IndicesArray>;
  26636. /**
  26637. * Returns the array of the requested vertex data kind. Implemented by child classes
  26638. * @param kind defines the vertex data kind to use
  26639. * @returns null
  26640. */
  26641. getVerticesData(kind: string): Nullable<FloatArray>;
  26642. /**
  26643. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26644. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26645. * Note that a new underlying VertexBuffer object is created each call.
  26646. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26647. * @param kind defines vertex data kind:
  26648. * * VertexBuffer.PositionKind
  26649. * * VertexBuffer.UVKind
  26650. * * VertexBuffer.UV2Kind
  26651. * * VertexBuffer.UV3Kind
  26652. * * VertexBuffer.UV4Kind
  26653. * * VertexBuffer.UV5Kind
  26654. * * VertexBuffer.UV6Kind
  26655. * * VertexBuffer.ColorKind
  26656. * * VertexBuffer.MatricesIndicesKind
  26657. * * VertexBuffer.MatricesIndicesExtraKind
  26658. * * VertexBuffer.MatricesWeightsKind
  26659. * * VertexBuffer.MatricesWeightsExtraKind
  26660. * @param data defines the data source
  26661. * @param updatable defines if the data must be flagged as updatable (or static)
  26662. * @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
  26663. * @returns the current mesh
  26664. */
  26665. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26666. /**
  26667. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26668. * If the mesh has no geometry, it is simply returned as it is.
  26669. * @param kind defines vertex data kind:
  26670. * * VertexBuffer.PositionKind
  26671. * * VertexBuffer.UVKind
  26672. * * VertexBuffer.UV2Kind
  26673. * * VertexBuffer.UV3Kind
  26674. * * VertexBuffer.UV4Kind
  26675. * * VertexBuffer.UV5Kind
  26676. * * VertexBuffer.UV6Kind
  26677. * * VertexBuffer.ColorKind
  26678. * * VertexBuffer.MatricesIndicesKind
  26679. * * VertexBuffer.MatricesIndicesExtraKind
  26680. * * VertexBuffer.MatricesWeightsKind
  26681. * * VertexBuffer.MatricesWeightsExtraKind
  26682. * @param data defines the data source
  26683. * @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
  26684. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26685. * @returns the current mesh
  26686. */
  26687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26688. /**
  26689. * Sets the mesh indices,
  26690. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26691. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26692. * @param totalVertices Defines the total number of vertices
  26693. * @returns the current mesh
  26694. */
  26695. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26696. /**
  26697. * Gets a boolean indicating if specific vertex data is present
  26698. * @param kind defines the vertex data kind to use
  26699. * @returns true is data kind is present
  26700. */
  26701. isVerticesDataPresent(kind: string): boolean;
  26702. /**
  26703. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26704. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26705. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26706. * @returns a BoundingInfo
  26707. */
  26708. getBoundingInfo(): BoundingInfo;
  26709. /**
  26710. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26711. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26712. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26713. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26714. * @returns the current mesh
  26715. */
  26716. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26717. /**
  26718. * Overwrite the current bounding info
  26719. * @param boundingInfo defines the new bounding info
  26720. * @returns the current mesh
  26721. */
  26722. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26723. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26724. readonly useBones: boolean;
  26725. /** @hidden */
  26726. _preActivate(): void;
  26727. /** @hidden */
  26728. _preActivateForIntermediateRendering(renderId: number): void;
  26729. /** @hidden */
  26730. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26731. /** @hidden */
  26732. _postActivate(): void;
  26733. /** @hidden */
  26734. _freeze(): void;
  26735. /** @hidden */
  26736. _unFreeze(): void;
  26737. /**
  26738. * Gets the current world matrix
  26739. * @returns a Matrix
  26740. */
  26741. getWorldMatrix(): Matrix;
  26742. /** @hidden */
  26743. _getWorldMatrixDeterminant(): number;
  26744. /**
  26745. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26746. */
  26747. readonly isAnInstance: boolean;
  26748. /**
  26749. * Perform relative position change from the point of view of behind the front of the mesh.
  26750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26751. * Supports definition of mesh facing forward or backward
  26752. * @param amountRight defines the distance on the right axis
  26753. * @param amountUp defines the distance on the up axis
  26754. * @param amountForward defines the distance on the forward axis
  26755. * @returns the current mesh
  26756. */
  26757. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26758. /**
  26759. * Calculate relative position change from the point of view of behind the front of the mesh.
  26760. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26761. * Supports definition of mesh facing forward or backward
  26762. * @param amountRight defines the distance on the right axis
  26763. * @param amountUp defines the distance on the up axis
  26764. * @param amountForward defines the distance on the forward axis
  26765. * @returns the new displacement vector
  26766. */
  26767. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26768. /**
  26769. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26770. * Supports definition of mesh facing forward or backward
  26771. * @param flipBack defines the flip
  26772. * @param twirlClockwise defines the twirl
  26773. * @param tiltRight defines the tilt
  26774. * @returns the current mesh
  26775. */
  26776. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26777. /**
  26778. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26779. * Supports definition of mesh facing forward or backward.
  26780. * @param flipBack defines the flip
  26781. * @param twirlClockwise defines the twirl
  26782. * @param tiltRight defines the tilt
  26783. * @returns the new rotation vector
  26784. */
  26785. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26786. /**
  26787. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26788. * This means the mesh underlying bounding box and sphere are recomputed.
  26789. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26790. * @returns the current mesh
  26791. */
  26792. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26793. /** @hidden */
  26794. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26795. /** @hidden */
  26796. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26797. /** @hidden */
  26798. _updateBoundingInfo(): AbstractMesh;
  26799. /** @hidden */
  26800. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26801. /** @hidden */
  26802. protected _afterComputeWorldMatrix(): void;
  26803. /** @hidden */
  26804. readonly _effectiveMesh: AbstractMesh;
  26805. /**
  26806. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26807. * A mesh is in the frustum if its bounding box intersects the frustum
  26808. * @param frustumPlanes defines the frustum to test
  26809. * @returns true if the mesh is in the frustum planes
  26810. */
  26811. isInFrustum(frustumPlanes: Plane[]): boolean;
  26812. /**
  26813. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26814. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26815. * @param frustumPlanes defines the frustum to test
  26816. * @returns true if the mesh is completely in the frustum planes
  26817. */
  26818. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26819. /**
  26820. * True if the mesh intersects another mesh or a SolidParticle object
  26821. * @param mesh defines a target mesh or SolidParticle to test
  26822. * @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)
  26823. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26824. * @returns true if there is an intersection
  26825. */
  26826. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26827. /**
  26828. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26829. * @param point defines the point to test
  26830. * @returns true if there is an intersection
  26831. */
  26832. intersectsPoint(point: Vector3): boolean;
  26833. /**
  26834. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26836. */
  26837. checkCollisions: boolean;
  26838. /**
  26839. * Gets Collider object used to compute collisions (not physics)
  26840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26841. */
  26842. readonly collider: Nullable<Collider>;
  26843. /**
  26844. * Move the mesh using collision engine
  26845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26846. * @param displacement defines the requested displacement vector
  26847. * @returns the current mesh
  26848. */
  26849. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26850. private _onCollisionPositionChange;
  26851. /** @hidden */
  26852. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26853. /** @hidden */
  26854. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26855. /** @hidden */
  26856. _checkCollision(collider: Collider): AbstractMesh;
  26857. /** @hidden */
  26858. _generatePointsArray(): boolean;
  26859. /**
  26860. * Checks if the passed Ray intersects with the mesh
  26861. * @param ray defines the ray to use
  26862. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26864. * @returns the picking info
  26865. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26866. */
  26867. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26868. /**
  26869. * Clones the current mesh
  26870. * @param name defines the mesh name
  26871. * @param newParent defines the new mesh parent
  26872. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26873. * @returns the new mesh
  26874. */
  26875. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26876. /**
  26877. * Disposes all the submeshes of the current meshnp
  26878. * @returns the current mesh
  26879. */
  26880. releaseSubMeshes(): AbstractMesh;
  26881. /**
  26882. * Releases resources associated with this abstract mesh.
  26883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26885. */
  26886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26887. /**
  26888. * Adds the passed mesh as a child to the current mesh
  26889. * @param mesh defines the child mesh
  26890. * @returns the current mesh
  26891. */
  26892. addChild(mesh: AbstractMesh): AbstractMesh;
  26893. /**
  26894. * Removes the passed mesh from the current mesh children list
  26895. * @param mesh defines the child mesh
  26896. * @returns the current mesh
  26897. */
  26898. removeChild(mesh: AbstractMesh): AbstractMesh;
  26899. /** @hidden */
  26900. private _initFacetData;
  26901. /**
  26902. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26903. * This method can be called within the render loop.
  26904. * 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
  26905. * @returns the current mesh
  26906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26907. */
  26908. updateFacetData(): AbstractMesh;
  26909. /**
  26910. * Returns the facetLocalNormals array.
  26911. * The normals are expressed in the mesh local spac
  26912. * @returns an array of Vector3
  26913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26914. */
  26915. getFacetLocalNormals(): Vector3[];
  26916. /**
  26917. * Returns the facetLocalPositions array.
  26918. * The facet positions are expressed in the mesh local space
  26919. * @returns an array of Vector3
  26920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26921. */
  26922. getFacetLocalPositions(): Vector3[];
  26923. /**
  26924. * Returns the facetLocalPartioning array
  26925. * @returns an array of array of numbers
  26926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26927. */
  26928. getFacetLocalPartitioning(): number[][];
  26929. /**
  26930. * Returns the i-th facet position in the world system.
  26931. * This method allocates a new Vector3 per call
  26932. * @param i defines the facet index
  26933. * @returns a new Vector3
  26934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26935. */
  26936. getFacetPosition(i: number): Vector3;
  26937. /**
  26938. * Sets the reference Vector3 with the i-th facet position in the world system
  26939. * @param i defines the facet index
  26940. * @param ref defines the target vector
  26941. * @returns the current mesh
  26942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26943. */
  26944. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26945. /**
  26946. * Returns the i-th facet normal in the world system.
  26947. * This method allocates a new Vector3 per call
  26948. * @param i defines the facet index
  26949. * @returns a new Vector3
  26950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26951. */
  26952. getFacetNormal(i: number): Vector3;
  26953. /**
  26954. * Sets the reference Vector3 with the i-th facet normal in the world system
  26955. * @param i defines the facet index
  26956. * @param ref defines the target vector
  26957. * @returns the current mesh
  26958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26959. */
  26960. getFacetNormalToRef(i: number, ref: Vector3): this;
  26961. /**
  26962. * 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)
  26963. * @param x defines x coordinate
  26964. * @param y defines y coordinate
  26965. * @param z defines z coordinate
  26966. * @returns the array of facet indexes
  26967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26968. */
  26969. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26970. /**
  26971. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26972. * @param projected sets as the (x,y,z) world projection on the facet
  26973. * @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
  26974. * @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
  26975. * @param x defines x coordinate
  26976. * @param y defines y coordinate
  26977. * @param z defines z coordinate
  26978. * @returns the face index if found (or null instead)
  26979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26980. */
  26981. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26982. /**
  26983. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26984. * @param projected sets as the (x,y,z) local projection on the facet
  26985. * @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
  26986. * @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
  26987. * @param x defines x coordinate
  26988. * @param y defines y coordinate
  26989. * @param z defines z coordinate
  26990. * @returns the face index if found (or null instead)
  26991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26992. */
  26993. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26994. /**
  26995. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26996. * @returns the parameters
  26997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26998. */
  26999. getFacetDataParameters(): any;
  27000. /**
  27001. * Disables the feature FacetData and frees the related memory
  27002. * @returns the current mesh
  27003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27004. */
  27005. disableFacetData(): AbstractMesh;
  27006. /**
  27007. * Updates the AbstractMesh indices array
  27008. * @param indices defines the data source
  27009. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27010. * @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)
  27011. * @returns the current mesh
  27012. */
  27013. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27014. /**
  27015. * Creates new normals data for the mesh
  27016. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27017. * @returns the current mesh
  27018. */
  27019. createNormals(updatable: boolean): AbstractMesh;
  27020. /**
  27021. * Align the mesh with a normal
  27022. * @param normal defines the normal to use
  27023. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27024. * @returns the current mesh
  27025. */
  27026. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27027. /** @hidden */
  27028. _checkOcclusionQuery(): boolean;
  27029. /**
  27030. * Disables the mesh edge rendering mode
  27031. * @returns the currentAbstractMesh
  27032. */
  27033. disableEdgesRendering(): AbstractMesh;
  27034. /**
  27035. * Enables the edge rendering mode on the mesh.
  27036. * This mode makes the mesh edges visible
  27037. * @param epsilon defines the maximal distance between two angles to detect a face
  27038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27039. * @returns the currentAbstractMesh
  27040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27041. */
  27042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27043. }
  27044. }
  27045. declare module "babylonjs/Actions/actionEvent" {
  27046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27047. import { Nullable } from "babylonjs/types";
  27048. import { Sprite } from "babylonjs/Sprites/sprite";
  27049. import { Scene } from "babylonjs/scene";
  27050. import { Vector2 } from "babylonjs/Maths/math.vector";
  27051. /**
  27052. * Interface used to define ActionEvent
  27053. */
  27054. export interface IActionEvent {
  27055. /** The mesh or sprite that triggered the action */
  27056. source: any;
  27057. /** The X mouse cursor position at the time of the event */
  27058. pointerX: number;
  27059. /** The Y mouse cursor position at the time of the event */
  27060. pointerY: number;
  27061. /** The mesh that is currently pointed at (can be null) */
  27062. meshUnderPointer: Nullable<AbstractMesh>;
  27063. /** the original (browser) event that triggered the ActionEvent */
  27064. sourceEvent?: any;
  27065. /** additional data for the event */
  27066. additionalData?: any;
  27067. }
  27068. /**
  27069. * ActionEvent is the event being sent when an action is triggered.
  27070. */
  27071. export class ActionEvent implements IActionEvent {
  27072. /** The mesh or sprite that triggered the action */
  27073. source: any;
  27074. /** The X mouse cursor position at the time of the event */
  27075. pointerX: number;
  27076. /** The Y mouse cursor position at the time of the event */
  27077. pointerY: number;
  27078. /** The mesh that is currently pointed at (can be null) */
  27079. meshUnderPointer: Nullable<AbstractMesh>;
  27080. /** the original (browser) event that triggered the ActionEvent */
  27081. sourceEvent?: any;
  27082. /** additional data for the event */
  27083. additionalData?: any;
  27084. /**
  27085. * Creates a new ActionEvent
  27086. * @param source The mesh or sprite that triggered the action
  27087. * @param pointerX The X mouse cursor position at the time of the event
  27088. * @param pointerY The Y mouse cursor position at the time of the event
  27089. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27090. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27091. * @param additionalData additional data for the event
  27092. */
  27093. constructor(
  27094. /** The mesh or sprite that triggered the action */
  27095. source: any,
  27096. /** The X mouse cursor position at the time of the event */
  27097. pointerX: number,
  27098. /** The Y mouse cursor position at the time of the event */
  27099. pointerY: number,
  27100. /** The mesh that is currently pointed at (can be null) */
  27101. meshUnderPointer: Nullable<AbstractMesh>,
  27102. /** the original (browser) event that triggered the ActionEvent */
  27103. sourceEvent?: any,
  27104. /** additional data for the event */
  27105. additionalData?: any);
  27106. /**
  27107. * Helper function to auto-create an ActionEvent from a source mesh.
  27108. * @param source The source mesh that triggered the event
  27109. * @param evt The original (browser) event
  27110. * @param additionalData additional data for the event
  27111. * @returns the new ActionEvent
  27112. */
  27113. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27114. /**
  27115. * Helper function to auto-create an ActionEvent from a source sprite
  27116. * @param source The source sprite that triggered the event
  27117. * @param scene Scene associated with the sprite
  27118. * @param evt The original (browser) event
  27119. * @param additionalData additional data for the event
  27120. * @returns the new ActionEvent
  27121. */
  27122. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27123. /**
  27124. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27125. * @param scene the scene where the event occurred
  27126. * @param evt The original (browser) event
  27127. * @returns the new ActionEvent
  27128. */
  27129. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27130. /**
  27131. * Helper function to auto-create an ActionEvent from a primitive
  27132. * @param prim defines the target primitive
  27133. * @param pointerPos defines the pointer position
  27134. * @param evt The original (browser) event
  27135. * @param additionalData additional data for the event
  27136. * @returns the new ActionEvent
  27137. */
  27138. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27139. }
  27140. }
  27141. declare module "babylonjs/Actions/abstractActionManager" {
  27142. import { IDisposable } from "babylonjs/scene";
  27143. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27144. import { IAction } from "babylonjs/Actions/action";
  27145. import { Nullable } from "babylonjs/types";
  27146. /**
  27147. * Abstract class used to decouple action Manager from scene and meshes.
  27148. * Do not instantiate.
  27149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27150. */
  27151. export abstract class AbstractActionManager implements IDisposable {
  27152. /** Gets the list of active triggers */
  27153. static Triggers: {
  27154. [key: string]: number;
  27155. };
  27156. /** Gets the cursor to use when hovering items */
  27157. hoverCursor: string;
  27158. /** Gets the list of actions */
  27159. actions: IAction[];
  27160. /**
  27161. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27162. */
  27163. isRecursive: boolean;
  27164. /**
  27165. * Releases all associated resources
  27166. */
  27167. abstract dispose(): void;
  27168. /**
  27169. * Does this action manager has pointer triggers
  27170. */
  27171. abstract readonly hasPointerTriggers: boolean;
  27172. /**
  27173. * Does this action manager has pick triggers
  27174. */
  27175. abstract readonly hasPickTriggers: boolean;
  27176. /**
  27177. * Process a specific trigger
  27178. * @param trigger defines the trigger to process
  27179. * @param evt defines the event details to be processed
  27180. */
  27181. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27182. /**
  27183. * Does this action manager handles actions of any of the given triggers
  27184. * @param triggers defines the triggers to be tested
  27185. * @return a boolean indicating whether one (or more) of the triggers is handled
  27186. */
  27187. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27188. /**
  27189. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27190. * speed.
  27191. * @param triggerA defines the trigger to be tested
  27192. * @param triggerB defines the trigger to be tested
  27193. * @return a boolean indicating whether one (or more) of the triggers is handled
  27194. */
  27195. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27196. /**
  27197. * Does this action manager handles actions of a given trigger
  27198. * @param trigger defines the trigger to be tested
  27199. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27200. * @return whether the trigger is handled
  27201. */
  27202. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27203. /**
  27204. * Serialize this manager to a JSON object
  27205. * @param name defines the property name to store this manager
  27206. * @returns a JSON representation of this manager
  27207. */
  27208. abstract serialize(name: string): any;
  27209. /**
  27210. * Registers an action to this action manager
  27211. * @param action defines the action to be registered
  27212. * @return the action amended (prepared) after registration
  27213. */
  27214. abstract registerAction(action: IAction): Nullable<IAction>;
  27215. /**
  27216. * Unregisters an action to this action manager
  27217. * @param action defines the action to be unregistered
  27218. * @return a boolean indicating whether the action has been unregistered
  27219. */
  27220. abstract unregisterAction(action: IAction): Boolean;
  27221. /**
  27222. * Does exist one action manager with at least one trigger
  27223. **/
  27224. static readonly HasTriggers: boolean;
  27225. /**
  27226. * Does exist one action manager with at least one pick trigger
  27227. **/
  27228. static readonly HasPickTriggers: boolean;
  27229. /**
  27230. * Does exist one action manager that handles actions of a given trigger
  27231. * @param trigger defines the trigger to be tested
  27232. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27233. **/
  27234. static HasSpecificTrigger(trigger: number): boolean;
  27235. }
  27236. }
  27237. declare module "babylonjs/node" {
  27238. import { Scene } from "babylonjs/scene";
  27239. import { Nullable } from "babylonjs/types";
  27240. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27241. import { Engine } from "babylonjs/Engines/engine";
  27242. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27243. import { Observable } from "babylonjs/Misc/observable";
  27244. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27245. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27246. import { Animatable } from "babylonjs/Animations/animatable";
  27247. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27248. import { Animation } from "babylonjs/Animations/animation";
  27249. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27251. /**
  27252. * Defines how a node can be built from a string name.
  27253. */
  27254. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27255. /**
  27256. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27257. */
  27258. export class Node implements IBehaviorAware<Node> {
  27259. /** @hidden */
  27260. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27261. private static _NodeConstructors;
  27262. /**
  27263. * Add a new node constructor
  27264. * @param type defines the type name of the node to construct
  27265. * @param constructorFunc defines the constructor function
  27266. */
  27267. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27268. /**
  27269. * Returns a node constructor based on type name
  27270. * @param type defines the type name
  27271. * @param name defines the new node name
  27272. * @param scene defines the hosting scene
  27273. * @param options defines optional options to transmit to constructors
  27274. * @returns the new constructor or null
  27275. */
  27276. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27277. /**
  27278. * Gets or sets the name of the node
  27279. */
  27280. name: string;
  27281. /**
  27282. * Gets or sets the id of the node
  27283. */
  27284. id: string;
  27285. /**
  27286. * Gets or sets the unique id of the node
  27287. */
  27288. uniqueId: number;
  27289. /**
  27290. * Gets or sets a string used to store user defined state for the node
  27291. */
  27292. state: string;
  27293. /**
  27294. * Gets or sets an object used to store user defined information for the node
  27295. */
  27296. metadata: any;
  27297. /**
  27298. * For internal use only. Please do not use.
  27299. */
  27300. reservedDataStore: any;
  27301. /**
  27302. * List of inspectable custom properties (used by the Inspector)
  27303. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27304. */
  27305. inspectableCustomProperties: IInspectable[];
  27306. /**
  27307. * Gets or sets a boolean used to define if the node must be serialized
  27308. */
  27309. doNotSerialize: boolean;
  27310. /** @hidden */
  27311. _isDisposed: boolean;
  27312. /**
  27313. * Gets a list of Animations associated with the node
  27314. */
  27315. animations: import("babylonjs/Animations/animation").Animation[];
  27316. protected _ranges: {
  27317. [name: string]: Nullable<AnimationRange>;
  27318. };
  27319. /**
  27320. * Callback raised when the node is ready to be used
  27321. */
  27322. onReady: Nullable<(node: Node) => void>;
  27323. private _isEnabled;
  27324. private _isParentEnabled;
  27325. private _isReady;
  27326. /** @hidden */
  27327. _currentRenderId: number;
  27328. private _parentUpdateId;
  27329. /** @hidden */
  27330. _childUpdateId: number;
  27331. /** @hidden */
  27332. _waitingParentId: Nullable<string>;
  27333. /** @hidden */
  27334. _scene: Scene;
  27335. /** @hidden */
  27336. _cache: any;
  27337. private _parentNode;
  27338. private _children;
  27339. /** @hidden */
  27340. _worldMatrix: Matrix;
  27341. /** @hidden */
  27342. _worldMatrixDeterminant: number;
  27343. /** @hidden */
  27344. _worldMatrixDeterminantIsDirty: boolean;
  27345. /** @hidden */
  27346. private _sceneRootNodesIndex;
  27347. /**
  27348. * Gets a boolean indicating if the node has been disposed
  27349. * @returns true if the node was disposed
  27350. */
  27351. isDisposed(): boolean;
  27352. /**
  27353. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27354. * @see https://doc.babylonjs.com/how_to/parenting
  27355. */
  27356. parent: Nullable<Node>;
  27357. private addToSceneRootNodes;
  27358. private removeFromSceneRootNodes;
  27359. private _animationPropertiesOverride;
  27360. /**
  27361. * Gets or sets the animation properties override
  27362. */
  27363. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27364. /**
  27365. * Gets a string idenfifying the name of the class
  27366. * @returns "Node" string
  27367. */
  27368. getClassName(): string;
  27369. /** @hidden */
  27370. readonly _isNode: boolean;
  27371. /**
  27372. * An event triggered when the mesh is disposed
  27373. */
  27374. onDisposeObservable: Observable<Node>;
  27375. private _onDisposeObserver;
  27376. /**
  27377. * Sets a callback that will be raised when the node will be disposed
  27378. */
  27379. onDispose: () => void;
  27380. /**
  27381. * Creates a new Node
  27382. * @param name the name and id to be given to this node
  27383. * @param scene the scene this node will be added to
  27384. * @param addToRootNodes the node will be added to scene.rootNodes
  27385. */
  27386. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27387. /**
  27388. * Gets the scene of the node
  27389. * @returns a scene
  27390. */
  27391. getScene(): Scene;
  27392. /**
  27393. * Gets the engine of the node
  27394. * @returns a Engine
  27395. */
  27396. getEngine(): Engine;
  27397. private _behaviors;
  27398. /**
  27399. * Attach a behavior to the node
  27400. * @see http://doc.babylonjs.com/features/behaviour
  27401. * @param behavior defines the behavior to attach
  27402. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27403. * @returns the current Node
  27404. */
  27405. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27406. /**
  27407. * Remove an attached behavior
  27408. * @see http://doc.babylonjs.com/features/behaviour
  27409. * @param behavior defines the behavior to attach
  27410. * @returns the current Node
  27411. */
  27412. removeBehavior(behavior: Behavior<Node>): Node;
  27413. /**
  27414. * Gets the list of attached behaviors
  27415. * @see http://doc.babylonjs.com/features/behaviour
  27416. */
  27417. readonly behaviors: Behavior<Node>[];
  27418. /**
  27419. * Gets an attached behavior by name
  27420. * @param name defines the name of the behavior to look for
  27421. * @see http://doc.babylonjs.com/features/behaviour
  27422. * @returns null if behavior was not found else the requested behavior
  27423. */
  27424. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27425. /**
  27426. * Returns the latest update of the World matrix
  27427. * @returns a Matrix
  27428. */
  27429. getWorldMatrix(): Matrix;
  27430. /** @hidden */
  27431. _getWorldMatrixDeterminant(): number;
  27432. /**
  27433. * Returns directly the latest state of the mesh World matrix.
  27434. * A Matrix is returned.
  27435. */
  27436. readonly worldMatrixFromCache: Matrix;
  27437. /** @hidden */
  27438. _initCache(): void;
  27439. /** @hidden */
  27440. updateCache(force?: boolean): void;
  27441. /** @hidden */
  27442. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27443. /** @hidden */
  27444. _updateCache(ignoreParentClass?: boolean): void;
  27445. /** @hidden */
  27446. _isSynchronized(): boolean;
  27447. /** @hidden */
  27448. _markSyncedWithParent(): void;
  27449. /** @hidden */
  27450. isSynchronizedWithParent(): boolean;
  27451. /** @hidden */
  27452. isSynchronized(): boolean;
  27453. /**
  27454. * Is this node ready to be used/rendered
  27455. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27456. * @return true if the node is ready
  27457. */
  27458. isReady(completeCheck?: boolean): boolean;
  27459. /**
  27460. * Is this node enabled?
  27461. * 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
  27462. * @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
  27463. * @return whether this node (and its parent) is enabled
  27464. */
  27465. isEnabled(checkAncestors?: boolean): boolean;
  27466. /** @hidden */
  27467. protected _syncParentEnabledState(): void;
  27468. /**
  27469. * Set the enabled state of this node
  27470. * @param value defines the new enabled state
  27471. */
  27472. setEnabled(value: boolean): void;
  27473. /**
  27474. * Is this node a descendant of the given node?
  27475. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27476. * @param ancestor defines the parent node to inspect
  27477. * @returns a boolean indicating if this node is a descendant of the given node
  27478. */
  27479. isDescendantOf(ancestor: Node): boolean;
  27480. /** @hidden */
  27481. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27482. /**
  27483. * Will return all nodes that have this node as ascendant
  27484. * @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
  27485. * @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
  27486. * @return all children nodes of all types
  27487. */
  27488. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27489. /**
  27490. * Get all child-meshes of this node
  27491. * @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)
  27492. * @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
  27493. * @returns an array of AbstractMesh
  27494. */
  27495. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27496. /**
  27497. * Get all direct children of this node
  27498. * @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
  27499. * @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)
  27500. * @returns an array of Node
  27501. */
  27502. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27503. /** @hidden */
  27504. _setReady(state: boolean): void;
  27505. /**
  27506. * Get an animation by name
  27507. * @param name defines the name of the animation to look for
  27508. * @returns null if not found else the requested animation
  27509. */
  27510. getAnimationByName(name: string): Nullable<Animation>;
  27511. /**
  27512. * Creates an animation range for this node
  27513. * @param name defines the name of the range
  27514. * @param from defines the starting key
  27515. * @param to defines the end key
  27516. */
  27517. createAnimationRange(name: string, from: number, to: number): void;
  27518. /**
  27519. * Delete a specific animation range
  27520. * @param name defines the name of the range to delete
  27521. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27522. */
  27523. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27524. /**
  27525. * Get an animation range by name
  27526. * @param name defines the name of the animation range to look for
  27527. * @returns null if not found else the requested animation range
  27528. */
  27529. getAnimationRange(name: string): Nullable<AnimationRange>;
  27530. /**
  27531. * Gets the list of all animation ranges defined on this node
  27532. * @returns an array
  27533. */
  27534. getAnimationRanges(): Nullable<AnimationRange>[];
  27535. /**
  27536. * Will start the animation sequence
  27537. * @param name defines the range frames for animation sequence
  27538. * @param loop defines if the animation should loop (false by default)
  27539. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27540. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27541. * @returns the object created for this animation. If range does not exist, it will return null
  27542. */
  27543. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27544. /**
  27545. * Serialize animation ranges into a JSON compatible object
  27546. * @returns serialization object
  27547. */
  27548. serializeAnimationRanges(): any;
  27549. /**
  27550. * Computes the world matrix of the node
  27551. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27552. * @returns the world matrix
  27553. */
  27554. computeWorldMatrix(force?: boolean): Matrix;
  27555. /**
  27556. * Releases resources associated with this node.
  27557. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27558. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27559. */
  27560. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27561. /**
  27562. * Parse animation range data from a serialization object and store them into a given node
  27563. * @param node defines where to store the animation ranges
  27564. * @param parsedNode defines the serialization object to read data from
  27565. * @param scene defines the hosting scene
  27566. */
  27567. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27568. /**
  27569. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27570. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27571. * @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
  27572. * @returns the new bounding vectors
  27573. */
  27574. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27575. min: Vector3;
  27576. max: Vector3;
  27577. };
  27578. }
  27579. }
  27580. declare module "babylonjs/Animations/animation" {
  27581. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27582. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27583. import { Color3 } from "babylonjs/Maths/math.color";
  27584. import { Nullable } from "babylonjs/types";
  27585. import { Scene } from "babylonjs/scene";
  27586. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27587. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27588. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27589. import { Node } from "babylonjs/node";
  27590. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27591. import { Size } from "babylonjs/Maths/math.size";
  27592. import { Animatable } from "babylonjs/Animations/animatable";
  27593. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27594. /**
  27595. * @hidden
  27596. */
  27597. export class _IAnimationState {
  27598. key: number;
  27599. repeatCount: number;
  27600. workValue?: any;
  27601. loopMode?: number;
  27602. offsetValue?: any;
  27603. highLimitValue?: any;
  27604. }
  27605. /**
  27606. * Class used to store any kind of animation
  27607. */
  27608. export class Animation {
  27609. /**Name of the animation */
  27610. name: string;
  27611. /**Property to animate */
  27612. targetProperty: string;
  27613. /**The frames per second of the animation */
  27614. framePerSecond: number;
  27615. /**The data type of the animation */
  27616. dataType: number;
  27617. /**The loop mode of the animation */
  27618. loopMode?: number | undefined;
  27619. /**Specifies if blending should be enabled */
  27620. enableBlending?: boolean | undefined;
  27621. /**
  27622. * Use matrix interpolation instead of using direct key value when animating matrices
  27623. */
  27624. static AllowMatricesInterpolation: boolean;
  27625. /**
  27626. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27627. */
  27628. static AllowMatrixDecomposeForInterpolation: boolean;
  27629. /**
  27630. * Stores the key frames of the animation
  27631. */
  27632. private _keys;
  27633. /**
  27634. * Stores the easing function of the animation
  27635. */
  27636. private _easingFunction;
  27637. /**
  27638. * @hidden Internal use only
  27639. */
  27640. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27641. /**
  27642. * The set of event that will be linked to this animation
  27643. */
  27644. private _events;
  27645. /**
  27646. * Stores an array of target property paths
  27647. */
  27648. targetPropertyPath: string[];
  27649. /**
  27650. * Stores the blending speed of the animation
  27651. */
  27652. blendingSpeed: number;
  27653. /**
  27654. * Stores the animation ranges for the animation
  27655. */
  27656. private _ranges;
  27657. /**
  27658. * @hidden Internal use
  27659. */
  27660. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27661. /**
  27662. * Sets up an animation
  27663. * @param property The property to animate
  27664. * @param animationType The animation type to apply
  27665. * @param framePerSecond The frames per second of the animation
  27666. * @param easingFunction The easing function used in the animation
  27667. * @returns The created animation
  27668. */
  27669. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27670. /**
  27671. * Create and start an animation on a node
  27672. * @param name defines the name of the global animation that will be run on all nodes
  27673. * @param node defines the root node where the animation will take place
  27674. * @param targetProperty defines property to animate
  27675. * @param framePerSecond defines the number of frame per second yo use
  27676. * @param totalFrame defines the number of frames in total
  27677. * @param from defines the initial value
  27678. * @param to defines the final value
  27679. * @param loopMode defines which loop mode you want to use (off by default)
  27680. * @param easingFunction defines the easing function to use (linear by default)
  27681. * @param onAnimationEnd defines the callback to call when animation end
  27682. * @returns the animatable created for this animation
  27683. */
  27684. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27685. /**
  27686. * Create and start an animation on a node and its descendants
  27687. * @param name defines the name of the global animation that will be run on all nodes
  27688. * @param node defines the root node where the animation will take place
  27689. * @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
  27690. * @param targetProperty defines property to animate
  27691. * @param framePerSecond defines the number of frame per second to use
  27692. * @param totalFrame defines the number of frames in total
  27693. * @param from defines the initial value
  27694. * @param to defines the final value
  27695. * @param loopMode defines which loop mode you want to use (off by default)
  27696. * @param easingFunction defines the easing function to use (linear by default)
  27697. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27698. * @returns the list of animatables created for all nodes
  27699. * @example https://www.babylonjs-playground.com/#MH0VLI
  27700. */
  27701. 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[]>;
  27702. /**
  27703. * Creates a new animation, merges it with the existing animations and starts it
  27704. * @param name Name of the animation
  27705. * @param node Node which contains the scene that begins the animations
  27706. * @param targetProperty Specifies which property to animate
  27707. * @param framePerSecond The frames per second of the animation
  27708. * @param totalFrame The total number of frames
  27709. * @param from The frame at the beginning of the animation
  27710. * @param to The frame at the end of the animation
  27711. * @param loopMode Specifies the loop mode of the animation
  27712. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27713. * @param onAnimationEnd Callback to run once the animation is complete
  27714. * @returns Nullable animation
  27715. */
  27716. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27717. /**
  27718. * Transition property of an host to the target Value
  27719. * @param property The property to transition
  27720. * @param targetValue The target Value of the property
  27721. * @param host The object where the property to animate belongs
  27722. * @param scene Scene used to run the animation
  27723. * @param frameRate Framerate (in frame/s) to use
  27724. * @param transition The transition type we want to use
  27725. * @param duration The duration of the animation, in milliseconds
  27726. * @param onAnimationEnd Callback trigger at the end of the animation
  27727. * @returns Nullable animation
  27728. */
  27729. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27730. /**
  27731. * Return the array of runtime animations currently using this animation
  27732. */
  27733. readonly runtimeAnimations: RuntimeAnimation[];
  27734. /**
  27735. * Specifies if any of the runtime animations are currently running
  27736. */
  27737. readonly hasRunningRuntimeAnimations: boolean;
  27738. /**
  27739. * Initializes the animation
  27740. * @param name Name of the animation
  27741. * @param targetProperty Property to animate
  27742. * @param framePerSecond The frames per second of the animation
  27743. * @param dataType The data type of the animation
  27744. * @param loopMode The loop mode of the animation
  27745. * @param enableBlending Specifies if blending should be enabled
  27746. */
  27747. constructor(
  27748. /**Name of the animation */
  27749. name: string,
  27750. /**Property to animate */
  27751. targetProperty: string,
  27752. /**The frames per second of the animation */
  27753. framePerSecond: number,
  27754. /**The data type of the animation */
  27755. dataType: number,
  27756. /**The loop mode of the animation */
  27757. loopMode?: number | undefined,
  27758. /**Specifies if blending should be enabled */
  27759. enableBlending?: boolean | undefined);
  27760. /**
  27761. * Converts the animation to a string
  27762. * @param fullDetails support for multiple levels of logging within scene loading
  27763. * @returns String form of the animation
  27764. */
  27765. toString(fullDetails?: boolean): string;
  27766. /**
  27767. * Add an event to this animation
  27768. * @param event Event to add
  27769. */
  27770. addEvent(event: AnimationEvent): void;
  27771. /**
  27772. * Remove all events found at the given frame
  27773. * @param frame The frame to remove events from
  27774. */
  27775. removeEvents(frame: number): void;
  27776. /**
  27777. * Retrieves all the events from the animation
  27778. * @returns Events from the animation
  27779. */
  27780. getEvents(): AnimationEvent[];
  27781. /**
  27782. * Creates an animation range
  27783. * @param name Name of the animation range
  27784. * @param from Starting frame of the animation range
  27785. * @param to Ending frame of the animation
  27786. */
  27787. createRange(name: string, from: number, to: number): void;
  27788. /**
  27789. * Deletes an animation range by name
  27790. * @param name Name of the animation range to delete
  27791. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27792. */
  27793. deleteRange(name: string, deleteFrames?: boolean): void;
  27794. /**
  27795. * Gets the animation range by name, or null if not defined
  27796. * @param name Name of the animation range
  27797. * @returns Nullable animation range
  27798. */
  27799. getRange(name: string): Nullable<AnimationRange>;
  27800. /**
  27801. * Gets the key frames from the animation
  27802. * @returns The key frames of the animation
  27803. */
  27804. getKeys(): Array<IAnimationKey>;
  27805. /**
  27806. * Gets the highest frame rate of the animation
  27807. * @returns Highest frame rate of the animation
  27808. */
  27809. getHighestFrame(): number;
  27810. /**
  27811. * Gets the easing function of the animation
  27812. * @returns Easing function of the animation
  27813. */
  27814. getEasingFunction(): IEasingFunction;
  27815. /**
  27816. * Sets the easing function of the animation
  27817. * @param easingFunction A custom mathematical formula for animation
  27818. */
  27819. setEasingFunction(easingFunction: EasingFunction): void;
  27820. /**
  27821. * Interpolates a scalar linearly
  27822. * @param startValue Start value of the animation curve
  27823. * @param endValue End value of the animation curve
  27824. * @param gradient Scalar amount to interpolate
  27825. * @returns Interpolated scalar value
  27826. */
  27827. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27828. /**
  27829. * Interpolates a scalar cubically
  27830. * @param startValue Start value of the animation curve
  27831. * @param outTangent End tangent of the animation
  27832. * @param endValue End value of the animation curve
  27833. * @param inTangent Start tangent of the animation curve
  27834. * @param gradient Scalar amount to interpolate
  27835. * @returns Interpolated scalar value
  27836. */
  27837. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27838. /**
  27839. * Interpolates a quaternion using a spherical linear interpolation
  27840. * @param startValue Start value of the animation curve
  27841. * @param endValue End value of the animation curve
  27842. * @param gradient Scalar amount to interpolate
  27843. * @returns Interpolated quaternion value
  27844. */
  27845. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27846. /**
  27847. * Interpolates a quaternion cubically
  27848. * @param startValue Start value of the animation curve
  27849. * @param outTangent End tangent of the animation curve
  27850. * @param endValue End value of the animation curve
  27851. * @param inTangent Start tangent of the animation curve
  27852. * @param gradient Scalar amount to interpolate
  27853. * @returns Interpolated quaternion value
  27854. */
  27855. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27856. /**
  27857. * Interpolates a Vector3 linearl
  27858. * @param startValue Start value of the animation curve
  27859. * @param endValue End value of the animation curve
  27860. * @param gradient Scalar amount to interpolate
  27861. * @returns Interpolated scalar value
  27862. */
  27863. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27864. /**
  27865. * Interpolates a Vector3 cubically
  27866. * @param startValue Start value of the animation curve
  27867. * @param outTangent End tangent of the animation
  27868. * @param endValue End value of the animation curve
  27869. * @param inTangent Start tangent of the animation curve
  27870. * @param gradient Scalar amount to interpolate
  27871. * @returns InterpolatedVector3 value
  27872. */
  27873. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27874. /**
  27875. * Interpolates a Vector2 linearly
  27876. * @param startValue Start value of the animation curve
  27877. * @param endValue End value of the animation curve
  27878. * @param gradient Scalar amount to interpolate
  27879. * @returns Interpolated Vector2 value
  27880. */
  27881. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27882. /**
  27883. * Interpolates a Vector2 cubically
  27884. * @param startValue Start value of the animation curve
  27885. * @param outTangent End tangent of the animation
  27886. * @param endValue End value of the animation curve
  27887. * @param inTangent Start tangent of the animation curve
  27888. * @param gradient Scalar amount to interpolate
  27889. * @returns Interpolated Vector2 value
  27890. */
  27891. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27892. /**
  27893. * Interpolates a size linearly
  27894. * @param startValue Start value of the animation curve
  27895. * @param endValue End value of the animation curve
  27896. * @param gradient Scalar amount to interpolate
  27897. * @returns Interpolated Size value
  27898. */
  27899. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27900. /**
  27901. * Interpolates a Color3 linearly
  27902. * @param startValue Start value of the animation curve
  27903. * @param endValue End value of the animation curve
  27904. * @param gradient Scalar amount to interpolate
  27905. * @returns Interpolated Color3 value
  27906. */
  27907. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27908. /**
  27909. * @hidden Internal use only
  27910. */
  27911. _getKeyValue(value: any): any;
  27912. /**
  27913. * @hidden Internal use only
  27914. */
  27915. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27916. /**
  27917. * Defines the function to use to interpolate matrices
  27918. * @param startValue defines the start matrix
  27919. * @param endValue defines the end matrix
  27920. * @param gradient defines the gradient between both matrices
  27921. * @param result defines an optional target matrix where to store the interpolation
  27922. * @returns the interpolated matrix
  27923. */
  27924. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27925. /**
  27926. * Makes a copy of the animation
  27927. * @returns Cloned animation
  27928. */
  27929. clone(): Animation;
  27930. /**
  27931. * Sets the key frames of the animation
  27932. * @param values The animation key frames to set
  27933. */
  27934. setKeys(values: Array<IAnimationKey>): void;
  27935. /**
  27936. * Serializes the animation to an object
  27937. * @returns Serialized object
  27938. */
  27939. serialize(): any;
  27940. /**
  27941. * Float animation type
  27942. */
  27943. private static _ANIMATIONTYPE_FLOAT;
  27944. /**
  27945. * Vector3 animation type
  27946. */
  27947. private static _ANIMATIONTYPE_VECTOR3;
  27948. /**
  27949. * Quaternion animation type
  27950. */
  27951. private static _ANIMATIONTYPE_QUATERNION;
  27952. /**
  27953. * Matrix animation type
  27954. */
  27955. private static _ANIMATIONTYPE_MATRIX;
  27956. /**
  27957. * Color3 animation type
  27958. */
  27959. private static _ANIMATIONTYPE_COLOR3;
  27960. /**
  27961. * Vector2 animation type
  27962. */
  27963. private static _ANIMATIONTYPE_VECTOR2;
  27964. /**
  27965. * Size animation type
  27966. */
  27967. private static _ANIMATIONTYPE_SIZE;
  27968. /**
  27969. * Relative Loop Mode
  27970. */
  27971. private static _ANIMATIONLOOPMODE_RELATIVE;
  27972. /**
  27973. * Cycle Loop Mode
  27974. */
  27975. private static _ANIMATIONLOOPMODE_CYCLE;
  27976. /**
  27977. * Constant Loop Mode
  27978. */
  27979. private static _ANIMATIONLOOPMODE_CONSTANT;
  27980. /**
  27981. * Get the float animation type
  27982. */
  27983. static readonly ANIMATIONTYPE_FLOAT: number;
  27984. /**
  27985. * Get the Vector3 animation type
  27986. */
  27987. static readonly ANIMATIONTYPE_VECTOR3: number;
  27988. /**
  27989. * Get the Vector2 animation type
  27990. */
  27991. static readonly ANIMATIONTYPE_VECTOR2: number;
  27992. /**
  27993. * Get the Size animation type
  27994. */
  27995. static readonly ANIMATIONTYPE_SIZE: number;
  27996. /**
  27997. * Get the Quaternion animation type
  27998. */
  27999. static readonly ANIMATIONTYPE_QUATERNION: number;
  28000. /**
  28001. * Get the Matrix animation type
  28002. */
  28003. static readonly ANIMATIONTYPE_MATRIX: number;
  28004. /**
  28005. * Get the Color3 animation type
  28006. */
  28007. static readonly ANIMATIONTYPE_COLOR3: number;
  28008. /**
  28009. * Get the Relative Loop Mode
  28010. */
  28011. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28012. /**
  28013. * Get the Cycle Loop Mode
  28014. */
  28015. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28016. /**
  28017. * Get the Constant Loop Mode
  28018. */
  28019. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28020. /** @hidden */
  28021. static _UniversalLerp(left: any, right: any, amount: number): any;
  28022. /**
  28023. * Parses an animation object and creates an animation
  28024. * @param parsedAnimation Parsed animation object
  28025. * @returns Animation object
  28026. */
  28027. static Parse(parsedAnimation: any): Animation;
  28028. /**
  28029. * Appends the serialized animations from the source animations
  28030. * @param source Source containing the animations
  28031. * @param destination Target to store the animations
  28032. */
  28033. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28034. }
  28035. }
  28036. declare module "babylonjs/Animations/animatable.interface" {
  28037. import { Nullable } from "babylonjs/types";
  28038. import { Animation } from "babylonjs/Animations/animation";
  28039. /**
  28040. * Interface containing an array of animations
  28041. */
  28042. export interface IAnimatable {
  28043. /**
  28044. * Array of animations
  28045. */
  28046. animations: Nullable<Array<Animation>>;
  28047. }
  28048. }
  28049. declare module "babylonjs/Materials/fresnelParameters" {
  28050. import { Color3 } from "babylonjs/Maths/math.color";
  28051. /**
  28052. * This represents all the required information to add a fresnel effect on a material:
  28053. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28054. */
  28055. export class FresnelParameters {
  28056. private _isEnabled;
  28057. /**
  28058. * Define if the fresnel effect is enable or not.
  28059. */
  28060. isEnabled: boolean;
  28061. /**
  28062. * Define the color used on edges (grazing angle)
  28063. */
  28064. leftColor: Color3;
  28065. /**
  28066. * Define the color used on center
  28067. */
  28068. rightColor: Color3;
  28069. /**
  28070. * Define bias applied to computed fresnel term
  28071. */
  28072. bias: number;
  28073. /**
  28074. * Defined the power exponent applied to fresnel term
  28075. */
  28076. power: number;
  28077. /**
  28078. * Clones the current fresnel and its valuues
  28079. * @returns a clone fresnel configuration
  28080. */
  28081. clone(): FresnelParameters;
  28082. /**
  28083. * Serializes the current fresnel parameters to a JSON representation.
  28084. * @return the JSON serialization
  28085. */
  28086. serialize(): any;
  28087. /**
  28088. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28089. * @param parsedFresnelParameters Define the JSON representation
  28090. * @returns the parsed parameters
  28091. */
  28092. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28093. }
  28094. }
  28095. declare module "babylonjs/Misc/decorators" {
  28096. import { Nullable } from "babylonjs/types";
  28097. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28098. import { Scene } from "babylonjs/scene";
  28099. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28100. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28101. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28102. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28103. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28104. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28105. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28106. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28107. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28108. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28109. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28110. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28111. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28112. /**
  28113. * Decorator used to define property that can be serialized as reference to a camera
  28114. * @param sourceName defines the name of the property to decorate
  28115. */
  28116. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28117. /**
  28118. * Class used to help serialization objects
  28119. */
  28120. export class SerializationHelper {
  28121. /** @hidden */
  28122. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28123. /** @hidden */
  28124. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28125. /** @hidden */
  28126. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28127. /** @hidden */
  28128. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28129. /**
  28130. * Appends the serialized animations from the source animations
  28131. * @param source Source containing the animations
  28132. * @param destination Target to store the animations
  28133. */
  28134. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28135. /**
  28136. * Static function used to serialized a specific entity
  28137. * @param entity defines the entity to serialize
  28138. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28139. * @returns a JSON compatible object representing the serialization of the entity
  28140. */
  28141. static Serialize<T>(entity: T, serializationObject?: any): any;
  28142. /**
  28143. * Creates a new entity from a serialization data object
  28144. * @param creationFunction defines a function used to instanciated the new entity
  28145. * @param source defines the source serialization data
  28146. * @param scene defines the hosting scene
  28147. * @param rootUrl defines the root url for resources
  28148. * @returns a new entity
  28149. */
  28150. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28151. /**
  28152. * Clones an object
  28153. * @param creationFunction defines the function used to instanciate the new object
  28154. * @param source defines the source object
  28155. * @returns the cloned object
  28156. */
  28157. static Clone<T>(creationFunction: () => T, source: T): T;
  28158. /**
  28159. * Instanciates a new object based on a source one (some data will be shared between both object)
  28160. * @param creationFunction defines the function used to instanciate the new object
  28161. * @param source defines the source object
  28162. * @returns the new object
  28163. */
  28164. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28165. }
  28166. }
  28167. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28168. import { Nullable } from "babylonjs/types";
  28169. /**
  28170. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28171. */
  28172. export interface CubeMapInfo {
  28173. /**
  28174. * The pixel array for the front face.
  28175. * This is stored in format, left to right, up to down format.
  28176. */
  28177. front: Nullable<ArrayBufferView>;
  28178. /**
  28179. * The pixel array for the back face.
  28180. * This is stored in format, left to right, up to down format.
  28181. */
  28182. back: Nullable<ArrayBufferView>;
  28183. /**
  28184. * The pixel array for the left face.
  28185. * This is stored in format, left to right, up to down format.
  28186. */
  28187. left: Nullable<ArrayBufferView>;
  28188. /**
  28189. * The pixel array for the right face.
  28190. * This is stored in format, left to right, up to down format.
  28191. */
  28192. right: Nullable<ArrayBufferView>;
  28193. /**
  28194. * The pixel array for the up face.
  28195. * This is stored in format, left to right, up to down format.
  28196. */
  28197. up: Nullable<ArrayBufferView>;
  28198. /**
  28199. * The pixel array for the down face.
  28200. * This is stored in format, left to right, up to down format.
  28201. */
  28202. down: Nullable<ArrayBufferView>;
  28203. /**
  28204. * The size of the cubemap stored.
  28205. *
  28206. * Each faces will be size * size pixels.
  28207. */
  28208. size: number;
  28209. /**
  28210. * The format of the texture.
  28211. *
  28212. * RGBA, RGB.
  28213. */
  28214. format: number;
  28215. /**
  28216. * The type of the texture data.
  28217. *
  28218. * UNSIGNED_INT, FLOAT.
  28219. */
  28220. type: number;
  28221. /**
  28222. * Specifies whether the texture is in gamma space.
  28223. */
  28224. gammaSpace: boolean;
  28225. }
  28226. /**
  28227. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28228. */
  28229. export class PanoramaToCubeMapTools {
  28230. private static FACE_FRONT;
  28231. private static FACE_BACK;
  28232. private static FACE_RIGHT;
  28233. private static FACE_LEFT;
  28234. private static FACE_DOWN;
  28235. private static FACE_UP;
  28236. /**
  28237. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28238. *
  28239. * @param float32Array The source data.
  28240. * @param inputWidth The width of the input panorama.
  28241. * @param inputHeight The height of the input panorama.
  28242. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28243. * @return The cubemap data
  28244. */
  28245. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28246. private static CreateCubemapTexture;
  28247. private static CalcProjectionSpherical;
  28248. }
  28249. }
  28250. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28251. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28252. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28253. import { Nullable } from "babylonjs/types";
  28254. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28255. /**
  28256. * Helper class dealing with the extraction of spherical polynomial dataArray
  28257. * from a cube map.
  28258. */
  28259. export class CubeMapToSphericalPolynomialTools {
  28260. private static FileFaces;
  28261. /**
  28262. * Converts a texture to the according Spherical Polynomial data.
  28263. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28264. *
  28265. * @param texture The texture to extract the information from.
  28266. * @return The Spherical Polynomial data.
  28267. */
  28268. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28269. /**
  28270. * Converts a cubemap to the according Spherical Polynomial data.
  28271. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28272. *
  28273. * @param cubeInfo The Cube map to extract the information from.
  28274. * @return The Spherical Polynomial data.
  28275. */
  28276. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28277. }
  28278. }
  28279. declare module "babylonjs/Misc/guid" {
  28280. /**
  28281. * Class used to manipulate GUIDs
  28282. */
  28283. export class GUID {
  28284. /**
  28285. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28286. * Be aware Math.random() could cause collisions, but:
  28287. * "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"
  28288. * @returns a pseudo random id
  28289. */
  28290. static RandomId(): string;
  28291. }
  28292. }
  28293. declare module "babylonjs/Materials/Textures/baseTexture" {
  28294. import { Observable } from "babylonjs/Misc/observable";
  28295. import { Nullable } from "babylonjs/types";
  28296. import { Scene } from "babylonjs/scene";
  28297. import { Matrix } from "babylonjs/Maths/math.vector";
  28298. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28300. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28301. import { ISize } from "babylonjs/Maths/math.size";
  28302. /**
  28303. * Base class of all the textures in babylon.
  28304. * It groups all the common properties the materials, post process, lights... might need
  28305. * in order to make a correct use of the texture.
  28306. */
  28307. export class BaseTexture implements IAnimatable {
  28308. /**
  28309. * Default anisotropic filtering level for the application.
  28310. * It is set to 4 as a good tradeoff between perf and quality.
  28311. */
  28312. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28313. /**
  28314. * Gets or sets the unique id of the texture
  28315. */
  28316. uniqueId: number;
  28317. /**
  28318. * Define the name of the texture.
  28319. */
  28320. name: string;
  28321. /**
  28322. * Gets or sets an object used to store user defined information.
  28323. */
  28324. metadata: any;
  28325. /**
  28326. * For internal use only. Please do not use.
  28327. */
  28328. reservedDataStore: any;
  28329. private _hasAlpha;
  28330. /**
  28331. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28332. */
  28333. hasAlpha: boolean;
  28334. /**
  28335. * Defines if the alpha value should be determined via the rgb values.
  28336. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28337. */
  28338. getAlphaFromRGB: boolean;
  28339. /**
  28340. * Intensity or strength of the texture.
  28341. * It is commonly used by materials to fine tune the intensity of the texture
  28342. */
  28343. level: number;
  28344. /**
  28345. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28346. * This is part of the texture as textures usually maps to one uv set.
  28347. */
  28348. coordinatesIndex: number;
  28349. private _coordinatesMode;
  28350. /**
  28351. * How a texture is mapped.
  28352. *
  28353. * | Value | Type | Description |
  28354. * | ----- | ----------------------------------- | ----------- |
  28355. * | 0 | EXPLICIT_MODE | |
  28356. * | 1 | SPHERICAL_MODE | |
  28357. * | 2 | PLANAR_MODE | |
  28358. * | 3 | CUBIC_MODE | |
  28359. * | 4 | PROJECTION_MODE | |
  28360. * | 5 | SKYBOX_MODE | |
  28361. * | 6 | INVCUBIC_MODE | |
  28362. * | 7 | EQUIRECTANGULAR_MODE | |
  28363. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28364. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28365. */
  28366. coordinatesMode: number;
  28367. /**
  28368. * | Value | Type | Description |
  28369. * | ----- | ------------------ | ----------- |
  28370. * | 0 | CLAMP_ADDRESSMODE | |
  28371. * | 1 | WRAP_ADDRESSMODE | |
  28372. * | 2 | MIRROR_ADDRESSMODE | |
  28373. */
  28374. wrapU: number;
  28375. /**
  28376. * | Value | Type | Description |
  28377. * | ----- | ------------------ | ----------- |
  28378. * | 0 | CLAMP_ADDRESSMODE | |
  28379. * | 1 | WRAP_ADDRESSMODE | |
  28380. * | 2 | MIRROR_ADDRESSMODE | |
  28381. */
  28382. wrapV: number;
  28383. /**
  28384. * | Value | Type | Description |
  28385. * | ----- | ------------------ | ----------- |
  28386. * | 0 | CLAMP_ADDRESSMODE | |
  28387. * | 1 | WRAP_ADDRESSMODE | |
  28388. * | 2 | MIRROR_ADDRESSMODE | |
  28389. */
  28390. wrapR: number;
  28391. /**
  28392. * With compliant hardware and browser (supporting anisotropic filtering)
  28393. * this defines the level of anisotropic filtering in the texture.
  28394. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28395. */
  28396. anisotropicFilteringLevel: number;
  28397. /**
  28398. * Define if the texture is a cube texture or if false a 2d texture.
  28399. */
  28400. isCube: boolean;
  28401. /**
  28402. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28403. */
  28404. is3D: boolean;
  28405. /**
  28406. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28407. * HDR texture are usually stored in linear space.
  28408. * This only impacts the PBR and Background materials
  28409. */
  28410. gammaSpace: boolean;
  28411. /**
  28412. * Gets whether or not the texture contains RGBD data.
  28413. */
  28414. readonly isRGBD: boolean;
  28415. /**
  28416. * Is Z inverted in the texture (useful in a cube texture).
  28417. */
  28418. invertZ: boolean;
  28419. /**
  28420. * Are mip maps generated for this texture or not.
  28421. */
  28422. readonly noMipmap: boolean;
  28423. /**
  28424. * @hidden
  28425. */
  28426. lodLevelInAlpha: boolean;
  28427. /**
  28428. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28429. */
  28430. lodGenerationOffset: number;
  28431. /**
  28432. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28433. */
  28434. lodGenerationScale: number;
  28435. /**
  28436. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28437. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28438. * average roughness values.
  28439. */
  28440. linearSpecularLOD: boolean;
  28441. /**
  28442. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28443. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28444. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28445. */
  28446. irradianceTexture: Nullable<BaseTexture>;
  28447. /**
  28448. * Define if the texture is a render target.
  28449. */
  28450. isRenderTarget: boolean;
  28451. /**
  28452. * Define the unique id of the texture in the scene.
  28453. */
  28454. readonly uid: string;
  28455. /**
  28456. * Return a string representation of the texture.
  28457. * @returns the texture as a string
  28458. */
  28459. toString(): string;
  28460. /**
  28461. * Get the class name of the texture.
  28462. * @returns "BaseTexture"
  28463. */
  28464. getClassName(): string;
  28465. /**
  28466. * Define the list of animation attached to the texture.
  28467. */
  28468. animations: import("babylonjs/Animations/animation").Animation[];
  28469. /**
  28470. * An event triggered when the texture is disposed.
  28471. */
  28472. onDisposeObservable: Observable<BaseTexture>;
  28473. private _onDisposeObserver;
  28474. /**
  28475. * Callback triggered when the texture has been disposed.
  28476. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28477. */
  28478. onDispose: () => void;
  28479. /**
  28480. * Define the current state of the loading sequence when in delayed load mode.
  28481. */
  28482. delayLoadState: number;
  28483. private _scene;
  28484. /** @hidden */
  28485. _texture: Nullable<InternalTexture>;
  28486. private _uid;
  28487. /**
  28488. * Define if the texture is preventinga material to render or not.
  28489. * If not and the texture is not ready, the engine will use a default black texture instead.
  28490. */
  28491. readonly isBlocking: boolean;
  28492. /**
  28493. * Instantiates a new BaseTexture.
  28494. * Base class of all the textures in babylon.
  28495. * It groups all the common properties the materials, post process, lights... might need
  28496. * in order to make a correct use of the texture.
  28497. * @param scene Define the scene the texture blongs to
  28498. */
  28499. constructor(scene: Nullable<Scene>);
  28500. /**
  28501. * Get the scene the texture belongs to.
  28502. * @returns the scene or null if undefined
  28503. */
  28504. getScene(): Nullable<Scene>;
  28505. /**
  28506. * Get the texture transform matrix used to offset tile the texture for istance.
  28507. * @returns the transformation matrix
  28508. */
  28509. getTextureMatrix(): Matrix;
  28510. /**
  28511. * Get the texture reflection matrix used to rotate/transform the reflection.
  28512. * @returns the reflection matrix
  28513. */
  28514. getReflectionTextureMatrix(): Matrix;
  28515. /**
  28516. * Get the underlying lower level texture from Babylon.
  28517. * @returns the insternal texture
  28518. */
  28519. getInternalTexture(): Nullable<InternalTexture>;
  28520. /**
  28521. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28522. * @returns true if ready or not blocking
  28523. */
  28524. isReadyOrNotBlocking(): boolean;
  28525. /**
  28526. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28527. * @returns true if fully ready
  28528. */
  28529. isReady(): boolean;
  28530. private _cachedSize;
  28531. /**
  28532. * Get the size of the texture.
  28533. * @returns the texture size.
  28534. */
  28535. getSize(): ISize;
  28536. /**
  28537. * Get the base size of the texture.
  28538. * It can be different from the size if the texture has been resized for POT for instance
  28539. * @returns the base size
  28540. */
  28541. getBaseSize(): ISize;
  28542. /**
  28543. * Update the sampling mode of the texture.
  28544. * Default is Trilinear mode.
  28545. *
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28549. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28550. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28551. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28552. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28553. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28554. * | 7 | NEAREST_LINEAR | |
  28555. * | 8 | NEAREST_NEAREST | |
  28556. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28557. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28558. * | 11 | LINEAR_LINEAR | |
  28559. * | 12 | LINEAR_NEAREST | |
  28560. *
  28561. * > _mag_: magnification filter (close to the viewer)
  28562. * > _min_: minification filter (far from the viewer)
  28563. * > _mip_: filter used between mip map levels
  28564. *@param samplingMode Define the new sampling mode of the texture
  28565. */
  28566. updateSamplingMode(samplingMode: number): void;
  28567. /**
  28568. * Scales the texture if is `canRescale()`
  28569. * @param ratio the resize factor we want to use to rescale
  28570. */
  28571. scale(ratio: number): void;
  28572. /**
  28573. * Get if the texture can rescale.
  28574. */
  28575. readonly canRescale: boolean;
  28576. /** @hidden */
  28577. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28578. /** @hidden */
  28579. _rebuild(): void;
  28580. /**
  28581. * Triggers the load sequence in delayed load mode.
  28582. */
  28583. delayLoad(): void;
  28584. /**
  28585. * Clones the texture.
  28586. * @returns the cloned texture
  28587. */
  28588. clone(): Nullable<BaseTexture>;
  28589. /**
  28590. * Get the texture underlying type (INT, FLOAT...)
  28591. */
  28592. readonly textureType: number;
  28593. /**
  28594. * Get the texture underlying format (RGB, RGBA...)
  28595. */
  28596. readonly textureFormat: number;
  28597. /**
  28598. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28599. * This will returns an RGBA array buffer containing either in values (0-255) or
  28600. * float values (0-1) depending of the underlying buffer type.
  28601. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28602. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28603. * @param buffer defines a user defined buffer to fill with data (can be null)
  28604. * @returns The Array buffer containing the pixels data.
  28605. */
  28606. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28607. /**
  28608. * Release and destroy the underlying lower level texture aka internalTexture.
  28609. */
  28610. releaseInternalTexture(): void;
  28611. /**
  28612. * Get the polynomial representation of the texture data.
  28613. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28614. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28615. */
  28616. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28617. /** @hidden */
  28618. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28619. /** @hidden */
  28620. readonly _lodTextureMid: Nullable<BaseTexture>;
  28621. /** @hidden */
  28622. readonly _lodTextureLow: Nullable<BaseTexture>;
  28623. /**
  28624. * Dispose the texture and release its associated resources.
  28625. */
  28626. dispose(): void;
  28627. /**
  28628. * Serialize the texture into a JSON representation that can be parsed later on.
  28629. * @returns the JSON representation of the texture
  28630. */
  28631. serialize(): any;
  28632. /**
  28633. * Helper function to be called back once a list of texture contains only ready textures.
  28634. * @param textures Define the list of textures to wait for
  28635. * @param callback Define the callback triggered once the entire list will be ready
  28636. */
  28637. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28638. }
  28639. }
  28640. declare module "babylonjs/Materials/Textures/internalTexture" {
  28641. import { Observable } from "babylonjs/Misc/observable";
  28642. import { Nullable, int } from "babylonjs/types";
  28643. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28644. import { Engine } from "babylonjs/Engines/engine";
  28645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28646. /**
  28647. * Class used to store data associated with WebGL texture data for the engine
  28648. * This class should not be used directly
  28649. */
  28650. export class InternalTexture {
  28651. /** @hidden */
  28652. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28653. /**
  28654. * The source of the texture data is unknown
  28655. */
  28656. static DATASOURCE_UNKNOWN: number;
  28657. /**
  28658. * Texture data comes from an URL
  28659. */
  28660. static DATASOURCE_URL: number;
  28661. /**
  28662. * Texture data is only used for temporary storage
  28663. */
  28664. static DATASOURCE_TEMP: number;
  28665. /**
  28666. * Texture data comes from raw data (ArrayBuffer)
  28667. */
  28668. static DATASOURCE_RAW: number;
  28669. /**
  28670. * Texture content is dynamic (video or dynamic texture)
  28671. */
  28672. static DATASOURCE_DYNAMIC: number;
  28673. /**
  28674. * Texture content is generated by rendering to it
  28675. */
  28676. static DATASOURCE_RENDERTARGET: number;
  28677. /**
  28678. * Texture content is part of a multi render target process
  28679. */
  28680. static DATASOURCE_MULTIRENDERTARGET: number;
  28681. /**
  28682. * Texture data comes from a cube data file
  28683. */
  28684. static DATASOURCE_CUBE: number;
  28685. /**
  28686. * Texture data comes from a raw cube data
  28687. */
  28688. static DATASOURCE_CUBERAW: number;
  28689. /**
  28690. * Texture data come from a prefiltered cube data file
  28691. */
  28692. static DATASOURCE_CUBEPREFILTERED: number;
  28693. /**
  28694. * Texture content is raw 3D data
  28695. */
  28696. static DATASOURCE_RAW3D: number;
  28697. /**
  28698. * Texture content is a depth texture
  28699. */
  28700. static DATASOURCE_DEPTHTEXTURE: number;
  28701. /**
  28702. * Texture data comes from a raw cube data encoded with RGBD
  28703. */
  28704. static DATASOURCE_CUBERAW_RGBD: number;
  28705. /**
  28706. * Defines if the texture is ready
  28707. */
  28708. isReady: boolean;
  28709. /**
  28710. * Defines if the texture is a cube texture
  28711. */
  28712. isCube: boolean;
  28713. /**
  28714. * Defines if the texture contains 3D data
  28715. */
  28716. is3D: boolean;
  28717. /**
  28718. * Defines if the texture contains multiview data
  28719. */
  28720. isMultiview: boolean;
  28721. /**
  28722. * Gets the URL used to load this texture
  28723. */
  28724. url: string;
  28725. /**
  28726. * Gets the sampling mode of the texture
  28727. */
  28728. samplingMode: number;
  28729. /**
  28730. * Gets a boolean indicating if the texture needs mipmaps generation
  28731. */
  28732. generateMipMaps: boolean;
  28733. /**
  28734. * Gets the number of samples used by the texture (WebGL2+ only)
  28735. */
  28736. samples: number;
  28737. /**
  28738. * Gets the type of the texture (int, float...)
  28739. */
  28740. type: number;
  28741. /**
  28742. * Gets the format of the texture (RGB, RGBA...)
  28743. */
  28744. format: number;
  28745. /**
  28746. * Observable called when the texture is loaded
  28747. */
  28748. onLoadedObservable: Observable<InternalTexture>;
  28749. /**
  28750. * Gets the width of the texture
  28751. */
  28752. width: number;
  28753. /**
  28754. * Gets the height of the texture
  28755. */
  28756. height: number;
  28757. /**
  28758. * Gets the depth of the texture
  28759. */
  28760. depth: number;
  28761. /**
  28762. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28763. */
  28764. baseWidth: number;
  28765. /**
  28766. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28767. */
  28768. baseHeight: number;
  28769. /**
  28770. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28771. */
  28772. baseDepth: number;
  28773. /**
  28774. * Gets a boolean indicating if the texture is inverted on Y axis
  28775. */
  28776. invertY: boolean;
  28777. /** @hidden */
  28778. _invertVScale: boolean;
  28779. /** @hidden */
  28780. _associatedChannel: number;
  28781. /** @hidden */
  28782. _dataSource: number;
  28783. /** @hidden */
  28784. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28785. /** @hidden */
  28786. _bufferView: Nullable<ArrayBufferView>;
  28787. /** @hidden */
  28788. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28789. /** @hidden */
  28790. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28791. /** @hidden */
  28792. _size: number;
  28793. /** @hidden */
  28794. _extension: string;
  28795. /** @hidden */
  28796. _files: Nullable<string[]>;
  28797. /** @hidden */
  28798. _workingCanvas: Nullable<HTMLCanvasElement>;
  28799. /** @hidden */
  28800. _workingContext: Nullable<CanvasRenderingContext2D>;
  28801. /** @hidden */
  28802. _framebuffer: Nullable<WebGLFramebuffer>;
  28803. /** @hidden */
  28804. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28805. /** @hidden */
  28806. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28807. /** @hidden */
  28808. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28809. /** @hidden */
  28810. _attachments: Nullable<number[]>;
  28811. /** @hidden */
  28812. _cachedCoordinatesMode: Nullable<number>;
  28813. /** @hidden */
  28814. _cachedWrapU: Nullable<number>;
  28815. /** @hidden */
  28816. _cachedWrapV: Nullable<number>;
  28817. /** @hidden */
  28818. _cachedWrapR: Nullable<number>;
  28819. /** @hidden */
  28820. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28821. /** @hidden */
  28822. _isDisabled: boolean;
  28823. /** @hidden */
  28824. _compression: Nullable<string>;
  28825. /** @hidden */
  28826. _generateStencilBuffer: boolean;
  28827. /** @hidden */
  28828. _generateDepthBuffer: boolean;
  28829. /** @hidden */
  28830. _comparisonFunction: number;
  28831. /** @hidden */
  28832. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28833. /** @hidden */
  28834. _lodGenerationScale: number;
  28835. /** @hidden */
  28836. _lodGenerationOffset: number;
  28837. /** @hidden */
  28838. _colorTextureArray: Nullable<WebGLTexture>;
  28839. /** @hidden */
  28840. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28841. /** @hidden */
  28842. _lodTextureHigh: Nullable<BaseTexture>;
  28843. /** @hidden */
  28844. _lodTextureMid: Nullable<BaseTexture>;
  28845. /** @hidden */
  28846. _lodTextureLow: Nullable<BaseTexture>;
  28847. /** @hidden */
  28848. _isRGBD: boolean;
  28849. /** @hidden */
  28850. _linearSpecularLOD: boolean;
  28851. /** @hidden */
  28852. _irradianceTexture: Nullable<BaseTexture>;
  28853. /** @hidden */
  28854. _webGLTexture: Nullable<WebGLTexture>;
  28855. /** @hidden */
  28856. _references: number;
  28857. private _engine;
  28858. /**
  28859. * Gets the Engine the texture belongs to.
  28860. * @returns The babylon engine
  28861. */
  28862. getEngine(): Engine;
  28863. /**
  28864. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28865. */
  28866. readonly dataSource: number;
  28867. /**
  28868. * Creates a new InternalTexture
  28869. * @param engine defines the engine to use
  28870. * @param dataSource defines the type of data that will be used
  28871. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28872. */
  28873. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28874. /**
  28875. * Increments the number of references (ie. the number of Texture that point to it)
  28876. */
  28877. incrementReferences(): void;
  28878. /**
  28879. * Change the size of the texture (not the size of the content)
  28880. * @param width defines the new width
  28881. * @param height defines the new height
  28882. * @param depth defines the new depth (1 by default)
  28883. */
  28884. updateSize(width: int, height: int, depth?: int): void;
  28885. /** @hidden */
  28886. _rebuild(): void;
  28887. /** @hidden */
  28888. _swapAndDie(target: InternalTexture): void;
  28889. /**
  28890. * Dispose the current allocated resources
  28891. */
  28892. dispose(): void;
  28893. }
  28894. }
  28895. declare module "babylonjs/Materials/effect" {
  28896. import { Observable } from "babylonjs/Misc/observable";
  28897. import { Nullable } from "babylonjs/types";
  28898. import { IDisposable } from "babylonjs/scene";
  28899. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28900. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28901. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28902. import { Engine } from "babylonjs/Engines/engine";
  28903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28905. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28906. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28908. /**
  28909. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28910. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28911. */
  28912. export class EffectFallbacks {
  28913. private _defines;
  28914. private _currentRank;
  28915. private _maxRank;
  28916. private _mesh;
  28917. /**
  28918. * Removes the fallback from the bound mesh.
  28919. */
  28920. unBindMesh(): void;
  28921. /**
  28922. * Adds a fallback on the specified property.
  28923. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28924. * @param define The name of the define in the shader
  28925. */
  28926. addFallback(rank: number, define: string): void;
  28927. /**
  28928. * Sets the mesh to use CPU skinning when needing to fallback.
  28929. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28930. * @param mesh The mesh to use the fallbacks.
  28931. */
  28932. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28933. /**
  28934. * Checks to see if more fallbacks are still availible.
  28935. */
  28936. readonly isMoreFallbacks: boolean;
  28937. /**
  28938. * Removes the defines that should be removed when falling back.
  28939. * @param currentDefines defines the current define statements for the shader.
  28940. * @param effect defines the current effect we try to compile
  28941. * @returns The resulting defines with defines of the current rank removed.
  28942. */
  28943. reduce(currentDefines: string, effect: Effect): string;
  28944. }
  28945. /**
  28946. * Options to be used when creating an effect.
  28947. */
  28948. export class EffectCreationOptions {
  28949. /**
  28950. * Atrributes that will be used in the shader.
  28951. */
  28952. attributes: string[];
  28953. /**
  28954. * Uniform varible names that will be set in the shader.
  28955. */
  28956. uniformsNames: string[];
  28957. /**
  28958. * Uniform buffer varible names that will be set in the shader.
  28959. */
  28960. uniformBuffersNames: string[];
  28961. /**
  28962. * Sampler texture variable names that will be set in the shader.
  28963. */
  28964. samplers: string[];
  28965. /**
  28966. * Define statements that will be set in the shader.
  28967. */
  28968. defines: any;
  28969. /**
  28970. * Possible fallbacks for this effect to improve performance when needed.
  28971. */
  28972. fallbacks: Nullable<EffectFallbacks>;
  28973. /**
  28974. * Callback that will be called when the shader is compiled.
  28975. */
  28976. onCompiled: Nullable<(effect: Effect) => void>;
  28977. /**
  28978. * Callback that will be called if an error occurs during shader compilation.
  28979. */
  28980. onError: Nullable<(effect: Effect, errors: string) => void>;
  28981. /**
  28982. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28983. */
  28984. indexParameters: any;
  28985. /**
  28986. * Max number of lights that can be used in the shader.
  28987. */
  28988. maxSimultaneousLights: number;
  28989. /**
  28990. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28991. */
  28992. transformFeedbackVaryings: Nullable<string[]>;
  28993. }
  28994. /**
  28995. * Effect containing vertex and fragment shader that can be executed on an object.
  28996. */
  28997. export class Effect implements IDisposable {
  28998. /**
  28999. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29000. */
  29001. static ShadersRepository: string;
  29002. /**
  29003. * Name of the effect.
  29004. */
  29005. name: any;
  29006. /**
  29007. * String container all the define statements that should be set on the shader.
  29008. */
  29009. defines: string;
  29010. /**
  29011. * Callback that will be called when the shader is compiled.
  29012. */
  29013. onCompiled: Nullable<(effect: Effect) => void>;
  29014. /**
  29015. * Callback that will be called if an error occurs during shader compilation.
  29016. */
  29017. onError: Nullable<(effect: Effect, errors: string) => void>;
  29018. /**
  29019. * Callback that will be called when effect is bound.
  29020. */
  29021. onBind: Nullable<(effect: Effect) => void>;
  29022. /**
  29023. * Unique ID of the effect.
  29024. */
  29025. uniqueId: number;
  29026. /**
  29027. * Observable that will be called when the shader is compiled.
  29028. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29029. */
  29030. onCompileObservable: Observable<Effect>;
  29031. /**
  29032. * Observable that will be called if an error occurs during shader compilation.
  29033. */
  29034. onErrorObservable: Observable<Effect>;
  29035. /** @hidden */
  29036. _onBindObservable: Nullable<Observable<Effect>>;
  29037. /**
  29038. * Observable that will be called when effect is bound.
  29039. */
  29040. readonly onBindObservable: Observable<Effect>;
  29041. /** @hidden */
  29042. _bonesComputationForcedToCPU: boolean;
  29043. private static _uniqueIdSeed;
  29044. private _engine;
  29045. private _uniformBuffersNames;
  29046. private _uniformsNames;
  29047. private _samplerList;
  29048. private _samplers;
  29049. private _isReady;
  29050. private _compilationError;
  29051. private _attributesNames;
  29052. private _attributes;
  29053. private _uniforms;
  29054. /**
  29055. * Key for the effect.
  29056. * @hidden
  29057. */
  29058. _key: string;
  29059. private _indexParameters;
  29060. private _fallbacks;
  29061. private _vertexSourceCode;
  29062. private _fragmentSourceCode;
  29063. private _vertexSourceCodeOverride;
  29064. private _fragmentSourceCodeOverride;
  29065. private _transformFeedbackVaryings;
  29066. /**
  29067. * Compiled shader to webGL program.
  29068. * @hidden
  29069. */
  29070. _pipelineContext: Nullable<IPipelineContext>;
  29071. private _valueCache;
  29072. private static _baseCache;
  29073. /**
  29074. * Instantiates an effect.
  29075. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29076. * @param baseName Name of the effect.
  29077. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29078. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29079. * @param samplers List of sampler variables that will be passed to the shader.
  29080. * @param engine Engine to be used to render the effect
  29081. * @param defines Define statements to be added to the shader.
  29082. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29083. * @param onCompiled Callback that will be called when the shader is compiled.
  29084. * @param onError Callback that will be called if an error occurs during shader compilation.
  29085. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29086. */
  29087. 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);
  29088. private _useFinalCode;
  29089. /**
  29090. * Unique key for this effect
  29091. */
  29092. readonly key: string;
  29093. /**
  29094. * If the effect has been compiled and prepared.
  29095. * @returns if the effect is compiled and prepared.
  29096. */
  29097. isReady(): boolean;
  29098. /**
  29099. * The engine the effect was initialized with.
  29100. * @returns the engine.
  29101. */
  29102. getEngine(): Engine;
  29103. /**
  29104. * The pipeline context for this effect
  29105. * @returns the associated pipeline context
  29106. */
  29107. getPipelineContext(): Nullable<IPipelineContext>;
  29108. /**
  29109. * The set of names of attribute variables for the shader.
  29110. * @returns An array of attribute names.
  29111. */
  29112. getAttributesNames(): string[];
  29113. /**
  29114. * Returns the attribute at the given index.
  29115. * @param index The index of the attribute.
  29116. * @returns The location of the attribute.
  29117. */
  29118. getAttributeLocation(index: number): number;
  29119. /**
  29120. * Returns the attribute based on the name of the variable.
  29121. * @param name of the attribute to look up.
  29122. * @returns the attribute location.
  29123. */
  29124. getAttributeLocationByName(name: string): number;
  29125. /**
  29126. * The number of attributes.
  29127. * @returns the numnber of attributes.
  29128. */
  29129. getAttributesCount(): number;
  29130. /**
  29131. * Gets the index of a uniform variable.
  29132. * @param uniformName of the uniform to look up.
  29133. * @returns the index.
  29134. */
  29135. getUniformIndex(uniformName: string): number;
  29136. /**
  29137. * Returns the attribute based on the name of the variable.
  29138. * @param uniformName of the uniform to look up.
  29139. * @returns the location of the uniform.
  29140. */
  29141. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29142. /**
  29143. * Returns an array of sampler variable names
  29144. * @returns The array of sampler variable neames.
  29145. */
  29146. getSamplers(): string[];
  29147. /**
  29148. * The error from the last compilation.
  29149. * @returns the error string.
  29150. */
  29151. getCompilationError(): string;
  29152. /**
  29153. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29154. * @param func The callback to be used.
  29155. */
  29156. executeWhenCompiled(func: (effect: Effect) => void): void;
  29157. private _checkIsReady;
  29158. /** @hidden */
  29159. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29160. /** @hidden */
  29161. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29162. /** @hidden */
  29163. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29164. /**
  29165. * Recompiles the webGL program
  29166. * @param vertexSourceCode The source code for the vertex shader.
  29167. * @param fragmentSourceCode The source code for the fragment shader.
  29168. * @param onCompiled Callback called when completed.
  29169. * @param onError Callback called on error.
  29170. * @hidden
  29171. */
  29172. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29173. /**
  29174. * Prepares the effect
  29175. * @hidden
  29176. */
  29177. _prepareEffect(): void;
  29178. /**
  29179. * Checks if the effect is supported. (Must be called after compilation)
  29180. */
  29181. readonly isSupported: boolean;
  29182. /**
  29183. * Binds a texture to the engine to be used as output of the shader.
  29184. * @param channel Name of the output variable.
  29185. * @param texture Texture to bind.
  29186. * @hidden
  29187. */
  29188. _bindTexture(channel: string, texture: InternalTexture): void;
  29189. /**
  29190. * Sets a texture on the engine to be used in the shader.
  29191. * @param channel Name of the sampler variable.
  29192. * @param texture Texture to set.
  29193. */
  29194. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29195. /**
  29196. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29197. * @param channel Name of the sampler variable.
  29198. * @param texture Texture to set.
  29199. */
  29200. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29201. /**
  29202. * Sets an array of textures on the engine to be used in the shader.
  29203. * @param channel Name of the variable.
  29204. * @param textures Textures to set.
  29205. */
  29206. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29207. /**
  29208. * 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)
  29209. * @param channel Name of the sampler variable.
  29210. * @param postProcess Post process to get the input texture from.
  29211. */
  29212. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29213. /**
  29214. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29215. * 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)
  29216. * @param channel Name of the sampler variable.
  29217. * @param postProcess Post process to get the output texture from.
  29218. */
  29219. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29220. /** @hidden */
  29221. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29222. /** @hidden */
  29223. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29224. /** @hidden */
  29225. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29226. /** @hidden */
  29227. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29228. /**
  29229. * Binds a buffer to a uniform.
  29230. * @param buffer Buffer to bind.
  29231. * @param name Name of the uniform variable to bind to.
  29232. */
  29233. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29234. /**
  29235. * Binds block to a uniform.
  29236. * @param blockName Name of the block to bind.
  29237. * @param index Index to bind.
  29238. */
  29239. bindUniformBlock(blockName: string, index: number): void;
  29240. /**
  29241. * Sets an interger value on a uniform variable.
  29242. * @param uniformName Name of the variable.
  29243. * @param value Value to be set.
  29244. * @returns this effect.
  29245. */
  29246. setInt(uniformName: string, value: number): Effect;
  29247. /**
  29248. * Sets an int array on a uniform variable.
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setIntArray(uniformName: string, array: Int32Array): Effect;
  29254. /**
  29255. * 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)
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29261. /**
  29262. * 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)
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29275. /**
  29276. * Sets an float array on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29289. /**
  29290. * 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)
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29303. /**
  29304. * Sets an array on a uniform variable.
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setArray(uniformName: string, array: number[]): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setArray2(uniformName: string, array: number[]): Effect;
  29317. /**
  29318. * 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)
  29319. * @param uniformName Name of the variable.
  29320. * @param array array to be set.
  29321. * @returns this effect.
  29322. */
  29323. setArray3(uniformName: string, array: number[]): Effect;
  29324. /**
  29325. * 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)
  29326. * @param uniformName Name of the variable.
  29327. * @param array array to be set.
  29328. * @returns this effect.
  29329. */
  29330. setArray4(uniformName: string, array: number[]): Effect;
  29331. /**
  29332. * Sets matrices on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param matrices matrices to be set.
  29335. * @returns this effect.
  29336. */
  29337. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29338. /**
  29339. * Sets matrix on a uniform variable.
  29340. * @param uniformName Name of the variable.
  29341. * @param matrix matrix to be set.
  29342. * @returns this effect.
  29343. */
  29344. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29345. /**
  29346. * 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)
  29347. * @param uniformName Name of the variable.
  29348. * @param matrix matrix to be set.
  29349. * @returns this effect.
  29350. */
  29351. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29352. /**
  29353. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29354. * @param uniformName Name of the variable.
  29355. * @param matrix matrix to be set.
  29356. * @returns this effect.
  29357. */
  29358. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29359. /**
  29360. * Sets a float on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param value value to be set.
  29363. * @returns this effect.
  29364. */
  29365. setFloat(uniformName: string, value: number): Effect;
  29366. /**
  29367. * Sets a boolean on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param bool value to be set.
  29370. * @returns this effect.
  29371. */
  29372. setBool(uniformName: string, bool: boolean): Effect;
  29373. /**
  29374. * Sets a Vector2 on a uniform variable.
  29375. * @param uniformName Name of the variable.
  29376. * @param vector2 vector2 to be set.
  29377. * @returns this effect.
  29378. */
  29379. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29380. /**
  29381. * Sets a float2 on a uniform variable.
  29382. * @param uniformName Name of the variable.
  29383. * @param x First float in float2.
  29384. * @param y Second float in float2.
  29385. * @returns this effect.
  29386. */
  29387. setFloat2(uniformName: string, x: number, y: number): Effect;
  29388. /**
  29389. * Sets a Vector3 on a uniform variable.
  29390. * @param uniformName Name of the variable.
  29391. * @param vector3 Value to be set.
  29392. * @returns this effect.
  29393. */
  29394. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29395. /**
  29396. * Sets a float3 on a uniform variable.
  29397. * @param uniformName Name of the variable.
  29398. * @param x First float in float3.
  29399. * @param y Second float in float3.
  29400. * @param z Third float in float3.
  29401. * @returns this effect.
  29402. */
  29403. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29404. /**
  29405. * Sets a Vector4 on a uniform variable.
  29406. * @param uniformName Name of the variable.
  29407. * @param vector4 Value to be set.
  29408. * @returns this effect.
  29409. */
  29410. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29411. /**
  29412. * Sets a float4 on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param x First float in float4.
  29415. * @param y Second float in float4.
  29416. * @param z Third float in float4.
  29417. * @param w Fourth float in float4.
  29418. * @returns this effect.
  29419. */
  29420. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29421. /**
  29422. * Sets a Color3 on a uniform variable.
  29423. * @param uniformName Name of the variable.
  29424. * @param color3 Value to be set.
  29425. * @returns this effect.
  29426. */
  29427. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29428. /**
  29429. * Sets a Color4 on a uniform variable.
  29430. * @param uniformName Name of the variable.
  29431. * @param color3 Value to be set.
  29432. * @param alpha Alpha value to be set.
  29433. * @returns this effect.
  29434. */
  29435. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29436. /**
  29437. * Sets a Color4 on a uniform variable
  29438. * @param uniformName defines the name of the variable
  29439. * @param color4 defines the value to be set
  29440. * @returns this effect.
  29441. */
  29442. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29443. /** Release all associated resources */
  29444. dispose(): void;
  29445. /**
  29446. * This function will add a new shader to the shader store
  29447. * @param name the name of the shader
  29448. * @param pixelShader optional pixel shader content
  29449. * @param vertexShader optional vertex shader content
  29450. */
  29451. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29452. /**
  29453. * Store of each shader (The can be looked up using effect.key)
  29454. */
  29455. static ShadersStore: {
  29456. [key: string]: string;
  29457. };
  29458. /**
  29459. * Store of each included file for a shader (The can be looked up using effect.key)
  29460. */
  29461. static IncludesShadersStore: {
  29462. [key: string]: string;
  29463. };
  29464. /**
  29465. * Resets the cache of effects.
  29466. */
  29467. static ResetCache(): void;
  29468. }
  29469. }
  29470. declare module "babylonjs/Materials/uniformBuffer" {
  29471. import { Nullable, FloatArray } from "babylonjs/types";
  29472. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29473. import { Engine } from "babylonjs/Engines/engine";
  29474. import { Effect } from "babylonjs/Materials/effect";
  29475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29476. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29477. import { Color3 } from "babylonjs/Maths/math.color";
  29478. /**
  29479. * Uniform buffer objects.
  29480. *
  29481. * Handles blocks of uniform on the GPU.
  29482. *
  29483. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29484. *
  29485. * For more information, please refer to :
  29486. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29487. */
  29488. export class UniformBuffer {
  29489. private _engine;
  29490. private _buffer;
  29491. private _data;
  29492. private _bufferData;
  29493. private _dynamic?;
  29494. private _uniformLocations;
  29495. private _uniformSizes;
  29496. private _uniformLocationPointer;
  29497. private _needSync;
  29498. private _noUBO;
  29499. private _currentEffect;
  29500. private static _MAX_UNIFORM_SIZE;
  29501. private static _tempBuffer;
  29502. /**
  29503. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29504. * This is dynamic to allow compat with webgl 1 and 2.
  29505. * You will need to pass the name of the uniform as well as the value.
  29506. */
  29507. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29508. /**
  29509. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29510. * This is dynamic to allow compat with webgl 1 and 2.
  29511. * You will need to pass the name of the uniform as well as the value.
  29512. */
  29513. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29514. /**
  29515. * Lambda to Update a single float in a uniform buffer.
  29516. * This is dynamic to allow compat with webgl 1 and 2.
  29517. * You will need to pass the name of the uniform as well as the value.
  29518. */
  29519. updateFloat: (name: string, x: number) => void;
  29520. /**
  29521. * Lambda to Update a vec2 of float in a uniform buffer.
  29522. * This is dynamic to allow compat with webgl 1 and 2.
  29523. * You will need to pass the name of the uniform as well as the value.
  29524. */
  29525. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29526. /**
  29527. * Lambda to Update a vec3 of float in a uniform buffer.
  29528. * This is dynamic to allow compat with webgl 1 and 2.
  29529. * You will need to pass the name of the uniform as well as the value.
  29530. */
  29531. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29532. /**
  29533. * Lambda to Update a vec4 of float in a uniform buffer.
  29534. * This is dynamic to allow compat with webgl 1 and 2.
  29535. * You will need to pass the name of the uniform as well as the value.
  29536. */
  29537. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29538. /**
  29539. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29540. * This is dynamic to allow compat with webgl 1 and 2.
  29541. * You will need to pass the name of the uniform as well as the value.
  29542. */
  29543. updateMatrix: (name: string, mat: Matrix) => void;
  29544. /**
  29545. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29546. * This is dynamic to allow compat with webgl 1 and 2.
  29547. * You will need to pass the name of the uniform as well as the value.
  29548. */
  29549. updateVector3: (name: string, vector: Vector3) => void;
  29550. /**
  29551. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29552. * This is dynamic to allow compat with webgl 1 and 2.
  29553. * You will need to pass the name of the uniform as well as the value.
  29554. */
  29555. updateVector4: (name: string, vector: Vector4) => void;
  29556. /**
  29557. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29558. * This is dynamic to allow compat with webgl 1 and 2.
  29559. * You will need to pass the name of the uniform as well as the value.
  29560. */
  29561. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29562. /**
  29563. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29564. * This is dynamic to allow compat with webgl 1 and 2.
  29565. * You will need to pass the name of the uniform as well as the value.
  29566. */
  29567. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29568. /**
  29569. * Instantiates a new Uniform buffer objects.
  29570. *
  29571. * Handles blocks of uniform on the GPU.
  29572. *
  29573. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29574. *
  29575. * For more information, please refer to :
  29576. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29577. * @param engine Define the engine the buffer is associated with
  29578. * @param data Define the data contained in the buffer
  29579. * @param dynamic Define if the buffer is updatable
  29580. */
  29581. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29582. /**
  29583. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29584. * or just falling back on setUniformXXX calls.
  29585. */
  29586. readonly useUbo: boolean;
  29587. /**
  29588. * Indicates if the WebGL underlying uniform buffer is in sync
  29589. * with the javascript cache data.
  29590. */
  29591. readonly isSync: boolean;
  29592. /**
  29593. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29594. * Also, a dynamic UniformBuffer will disable cache verification and always
  29595. * update the underlying WebGL uniform buffer to the GPU.
  29596. * @returns if Dynamic, otherwise false
  29597. */
  29598. isDynamic(): boolean;
  29599. /**
  29600. * The data cache on JS side.
  29601. * @returns the underlying data as a float array
  29602. */
  29603. getData(): Float32Array;
  29604. /**
  29605. * The underlying WebGL Uniform buffer.
  29606. * @returns the webgl buffer
  29607. */
  29608. getBuffer(): Nullable<DataBuffer>;
  29609. /**
  29610. * std140 layout specifies how to align data within an UBO structure.
  29611. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29612. * for specs.
  29613. */
  29614. private _fillAlignment;
  29615. /**
  29616. * Adds an uniform in the buffer.
  29617. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29618. * for the layout to be correct !
  29619. * @param name Name of the uniform, as used in the uniform block in the shader.
  29620. * @param size Data size, or data directly.
  29621. */
  29622. addUniform(name: string, size: number | number[]): void;
  29623. /**
  29624. * Adds a Matrix 4x4 to the uniform buffer.
  29625. * @param name Name of the uniform, as used in the uniform block in the shader.
  29626. * @param mat A 4x4 matrix.
  29627. */
  29628. addMatrix(name: string, mat: Matrix): void;
  29629. /**
  29630. * Adds a vec2 to the uniform buffer.
  29631. * @param name Name of the uniform, as used in the uniform block in the shader.
  29632. * @param x Define the x component value of the vec2
  29633. * @param y Define the y component value of the vec2
  29634. */
  29635. addFloat2(name: string, x: number, y: number): void;
  29636. /**
  29637. * Adds a vec3 to the uniform buffer.
  29638. * @param name Name of the uniform, as used in the uniform block in the shader.
  29639. * @param x Define the x component value of the vec3
  29640. * @param y Define the y component value of the vec3
  29641. * @param z Define the z component value of the vec3
  29642. */
  29643. addFloat3(name: string, x: number, y: number, z: number): void;
  29644. /**
  29645. * Adds a vec3 to the uniform buffer.
  29646. * @param name Name of the uniform, as used in the uniform block in the shader.
  29647. * @param color Define the vec3 from a Color
  29648. */
  29649. addColor3(name: string, color: Color3): void;
  29650. /**
  29651. * Adds a vec4 to the uniform buffer.
  29652. * @param name Name of the uniform, as used in the uniform block in the shader.
  29653. * @param color Define the rgb components from a Color
  29654. * @param alpha Define the a component of the vec4
  29655. */
  29656. addColor4(name: string, color: Color3, alpha: number): void;
  29657. /**
  29658. * Adds a vec3 to the uniform buffer.
  29659. * @param name Name of the uniform, as used in the uniform block in the shader.
  29660. * @param vector Define the vec3 components from a Vector
  29661. */
  29662. addVector3(name: string, vector: Vector3): void;
  29663. /**
  29664. * Adds a Matrix 3x3 to the uniform buffer.
  29665. * @param name Name of the uniform, as used in the uniform block in the shader.
  29666. */
  29667. addMatrix3x3(name: string): void;
  29668. /**
  29669. * Adds a Matrix 2x2 to the uniform buffer.
  29670. * @param name Name of the uniform, as used in the uniform block in the shader.
  29671. */
  29672. addMatrix2x2(name: string): void;
  29673. /**
  29674. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29675. */
  29676. create(): void;
  29677. /** @hidden */
  29678. _rebuild(): void;
  29679. /**
  29680. * Updates the WebGL Uniform Buffer on the GPU.
  29681. * If the `dynamic` flag is set to true, no cache comparison is done.
  29682. * Otherwise, the buffer will be updated only if the cache differs.
  29683. */
  29684. update(): void;
  29685. /**
  29686. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29687. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29688. * @param data Define the flattened data
  29689. * @param size Define the size of the data.
  29690. */
  29691. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29692. private _updateMatrix3x3ForUniform;
  29693. private _updateMatrix3x3ForEffect;
  29694. private _updateMatrix2x2ForEffect;
  29695. private _updateMatrix2x2ForUniform;
  29696. private _updateFloatForEffect;
  29697. private _updateFloatForUniform;
  29698. private _updateFloat2ForEffect;
  29699. private _updateFloat2ForUniform;
  29700. private _updateFloat3ForEffect;
  29701. private _updateFloat3ForUniform;
  29702. private _updateFloat4ForEffect;
  29703. private _updateFloat4ForUniform;
  29704. private _updateMatrixForEffect;
  29705. private _updateMatrixForUniform;
  29706. private _updateVector3ForEffect;
  29707. private _updateVector3ForUniform;
  29708. private _updateVector4ForEffect;
  29709. private _updateVector4ForUniform;
  29710. private _updateColor3ForEffect;
  29711. private _updateColor3ForUniform;
  29712. private _updateColor4ForEffect;
  29713. private _updateColor4ForUniform;
  29714. /**
  29715. * Sets a sampler uniform on the effect.
  29716. * @param name Define the name of the sampler.
  29717. * @param texture Define the texture to set in the sampler
  29718. */
  29719. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29720. /**
  29721. * Directly updates the value of the uniform in the cache AND on the GPU.
  29722. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29723. * @param data Define the flattened data
  29724. */
  29725. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29726. /**
  29727. * Binds this uniform buffer to an effect.
  29728. * @param effect Define the effect to bind the buffer to
  29729. * @param name Name of the uniform block in the shader.
  29730. */
  29731. bindToEffect(effect: Effect, name: string): void;
  29732. /**
  29733. * Disposes the uniform buffer.
  29734. */
  29735. dispose(): void;
  29736. }
  29737. }
  29738. declare module "babylonjs/Audio/analyser" {
  29739. import { Scene } from "babylonjs/scene";
  29740. /**
  29741. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29743. */
  29744. export class Analyser {
  29745. /**
  29746. * Gets or sets the smoothing
  29747. * @ignorenaming
  29748. */
  29749. SMOOTHING: number;
  29750. /**
  29751. * Gets or sets the FFT table size
  29752. * @ignorenaming
  29753. */
  29754. FFT_SIZE: number;
  29755. /**
  29756. * Gets or sets the bar graph amplitude
  29757. * @ignorenaming
  29758. */
  29759. BARGRAPHAMPLITUDE: number;
  29760. /**
  29761. * Gets or sets the position of the debug canvas
  29762. * @ignorenaming
  29763. */
  29764. DEBUGCANVASPOS: {
  29765. x: number;
  29766. y: number;
  29767. };
  29768. /**
  29769. * Gets or sets the debug canvas size
  29770. * @ignorenaming
  29771. */
  29772. DEBUGCANVASSIZE: {
  29773. width: number;
  29774. height: number;
  29775. };
  29776. private _byteFreqs;
  29777. private _byteTime;
  29778. private _floatFreqs;
  29779. private _webAudioAnalyser;
  29780. private _debugCanvas;
  29781. private _debugCanvasContext;
  29782. private _scene;
  29783. private _registerFunc;
  29784. private _audioEngine;
  29785. /**
  29786. * Creates a new analyser
  29787. * @param scene defines hosting scene
  29788. */
  29789. constructor(scene: Scene);
  29790. /**
  29791. * Get the number of data values you will have to play with for the visualization
  29792. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29793. * @returns a number
  29794. */
  29795. getFrequencyBinCount(): number;
  29796. /**
  29797. * Gets the current frequency data as a byte array
  29798. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29799. * @returns a Uint8Array
  29800. */
  29801. getByteFrequencyData(): Uint8Array;
  29802. /**
  29803. * Gets the current waveform as a byte array
  29804. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29805. * @returns a Uint8Array
  29806. */
  29807. getByteTimeDomainData(): Uint8Array;
  29808. /**
  29809. * Gets the current frequency data as a float array
  29810. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29811. * @returns a Float32Array
  29812. */
  29813. getFloatFrequencyData(): Float32Array;
  29814. /**
  29815. * Renders the debug canvas
  29816. */
  29817. drawDebugCanvas(): void;
  29818. /**
  29819. * Stops rendering the debug canvas and removes it
  29820. */
  29821. stopDebugCanvas(): void;
  29822. /**
  29823. * Connects two audio nodes
  29824. * @param inputAudioNode defines first node to connect
  29825. * @param outputAudioNode defines second node to connect
  29826. */
  29827. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29828. /**
  29829. * Releases all associated resources
  29830. */
  29831. dispose(): void;
  29832. }
  29833. }
  29834. declare module "babylonjs/Audio/audioEngine" {
  29835. import { IDisposable } from "babylonjs/scene";
  29836. import { Analyser } from "babylonjs/Audio/analyser";
  29837. import { Nullable } from "babylonjs/types";
  29838. import { Observable } from "babylonjs/Misc/observable";
  29839. /**
  29840. * This represents an audio engine and it is responsible
  29841. * to play, synchronize and analyse sounds throughout the application.
  29842. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29843. */
  29844. export interface IAudioEngine extends IDisposable {
  29845. /**
  29846. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29847. */
  29848. readonly canUseWebAudio: boolean;
  29849. /**
  29850. * Gets the current AudioContext if available.
  29851. */
  29852. readonly audioContext: Nullable<AudioContext>;
  29853. /**
  29854. * The master gain node defines the global audio volume of your audio engine.
  29855. */
  29856. readonly masterGain: GainNode;
  29857. /**
  29858. * Gets whether or not mp3 are supported by your browser.
  29859. */
  29860. readonly isMP3supported: boolean;
  29861. /**
  29862. * Gets whether or not ogg are supported by your browser.
  29863. */
  29864. readonly isOGGsupported: boolean;
  29865. /**
  29866. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29867. * @ignoreNaming
  29868. */
  29869. WarnedWebAudioUnsupported: boolean;
  29870. /**
  29871. * Defines if the audio engine relies on a custom unlocked button.
  29872. * In this case, the embedded button will not be displayed.
  29873. */
  29874. useCustomUnlockedButton: boolean;
  29875. /**
  29876. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29877. */
  29878. readonly unlocked: boolean;
  29879. /**
  29880. * Event raised when audio has been unlocked on the browser.
  29881. */
  29882. onAudioUnlockedObservable: Observable<AudioEngine>;
  29883. /**
  29884. * Event raised when audio has been locked on the browser.
  29885. */
  29886. onAudioLockedObservable: Observable<AudioEngine>;
  29887. /**
  29888. * Flags the audio engine in Locked state.
  29889. * This happens due to new browser policies preventing audio to autoplay.
  29890. */
  29891. lock(): void;
  29892. /**
  29893. * Unlocks the audio engine once a user action has been done on the dom.
  29894. * This is helpful to resume play once browser policies have been satisfied.
  29895. */
  29896. unlock(): void;
  29897. }
  29898. /**
  29899. * This represents the default audio engine used in babylon.
  29900. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29902. */
  29903. export class AudioEngine implements IAudioEngine {
  29904. private _audioContext;
  29905. private _audioContextInitialized;
  29906. private _muteButton;
  29907. private _hostElement;
  29908. /**
  29909. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29910. */
  29911. canUseWebAudio: boolean;
  29912. /**
  29913. * The master gain node defines the global audio volume of your audio engine.
  29914. */
  29915. masterGain: GainNode;
  29916. /**
  29917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29918. * @ignoreNaming
  29919. */
  29920. WarnedWebAudioUnsupported: boolean;
  29921. /**
  29922. * Gets whether or not mp3 are supported by your browser.
  29923. */
  29924. isMP3supported: boolean;
  29925. /**
  29926. * Gets whether or not ogg are supported by your browser.
  29927. */
  29928. isOGGsupported: boolean;
  29929. /**
  29930. * Gets whether audio has been unlocked on the device.
  29931. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29932. * a user interaction has happened.
  29933. */
  29934. unlocked: boolean;
  29935. /**
  29936. * Defines if the audio engine relies on a custom unlocked button.
  29937. * In this case, the embedded button will not be displayed.
  29938. */
  29939. useCustomUnlockedButton: boolean;
  29940. /**
  29941. * Event raised when audio has been unlocked on the browser.
  29942. */
  29943. onAudioUnlockedObservable: Observable<AudioEngine>;
  29944. /**
  29945. * Event raised when audio has been locked on the browser.
  29946. */
  29947. onAudioLockedObservable: Observable<AudioEngine>;
  29948. /**
  29949. * Gets the current AudioContext if available.
  29950. */
  29951. readonly audioContext: Nullable<AudioContext>;
  29952. private _connectedAnalyser;
  29953. /**
  29954. * Instantiates a new audio engine.
  29955. *
  29956. * There should be only one per page as some browsers restrict the number
  29957. * of audio contexts you can create.
  29958. * @param hostElement defines the host element where to display the mute icon if necessary
  29959. */
  29960. constructor(hostElement?: Nullable<HTMLElement>);
  29961. /**
  29962. * Flags the audio engine in Locked state.
  29963. * This happens due to new browser policies preventing audio to autoplay.
  29964. */
  29965. lock(): void;
  29966. /**
  29967. * Unlocks the audio engine once a user action has been done on the dom.
  29968. * This is helpful to resume play once browser policies have been satisfied.
  29969. */
  29970. unlock(): void;
  29971. private _resumeAudioContext;
  29972. private _initializeAudioContext;
  29973. private _tryToRun;
  29974. private _triggerRunningState;
  29975. private _triggerSuspendedState;
  29976. private _displayMuteButton;
  29977. private _moveButtonToTopLeft;
  29978. private _onResize;
  29979. private _hideMuteButton;
  29980. /**
  29981. * Destroy and release the resources associated with the audio ccontext.
  29982. */
  29983. dispose(): void;
  29984. /**
  29985. * Gets the global volume sets on the master gain.
  29986. * @returns the global volume if set or -1 otherwise
  29987. */
  29988. getGlobalVolume(): number;
  29989. /**
  29990. * Sets the global volume of your experience (sets on the master gain).
  29991. * @param newVolume Defines the new global volume of the application
  29992. */
  29993. setGlobalVolume(newVolume: number): void;
  29994. /**
  29995. * Connect the audio engine to an audio analyser allowing some amazing
  29996. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29998. * @param analyser The analyser to connect to the engine
  29999. */
  30000. connectToAnalyser(analyser: Analyser): void;
  30001. }
  30002. }
  30003. declare module "babylonjs/Loading/loadingScreen" {
  30004. /**
  30005. * Interface used to present a loading screen while loading a scene
  30006. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30007. */
  30008. export interface ILoadingScreen {
  30009. /**
  30010. * Function called to display the loading screen
  30011. */
  30012. displayLoadingUI: () => void;
  30013. /**
  30014. * Function called to hide the loading screen
  30015. */
  30016. hideLoadingUI: () => void;
  30017. /**
  30018. * Gets or sets the color to use for the background
  30019. */
  30020. loadingUIBackgroundColor: string;
  30021. /**
  30022. * Gets or sets the text to display while loading
  30023. */
  30024. loadingUIText: string;
  30025. }
  30026. /**
  30027. * Class used for the default loading screen
  30028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30029. */
  30030. export class DefaultLoadingScreen implements ILoadingScreen {
  30031. private _renderingCanvas;
  30032. private _loadingText;
  30033. private _loadingDivBackgroundColor;
  30034. private _loadingDiv;
  30035. private _loadingTextDiv;
  30036. /** Gets or sets the logo url to use for the default loading screen */
  30037. static DefaultLogoUrl: string;
  30038. /** Gets or sets the spinner url to use for the default loading screen */
  30039. static DefaultSpinnerUrl: string;
  30040. /**
  30041. * Creates a new default loading screen
  30042. * @param _renderingCanvas defines the canvas used to render the scene
  30043. * @param _loadingText defines the default text to display
  30044. * @param _loadingDivBackgroundColor defines the default background color
  30045. */
  30046. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30047. /**
  30048. * Function called to display the loading screen
  30049. */
  30050. displayLoadingUI(): void;
  30051. /**
  30052. * Function called to hide the loading screen
  30053. */
  30054. hideLoadingUI(): void;
  30055. /**
  30056. * Gets or sets the text to display while loading
  30057. */
  30058. loadingUIText: string;
  30059. /**
  30060. * Gets or sets the color to use for the background
  30061. */
  30062. loadingUIBackgroundColor: string;
  30063. private _resizeLoadingUI;
  30064. }
  30065. }
  30066. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30067. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30068. import { Engine } from "babylonjs/Engines/engine";
  30069. import { Nullable } from "babylonjs/types";
  30070. /** @hidden */
  30071. export class WebGLPipelineContext implements IPipelineContext {
  30072. engine: Engine;
  30073. program: Nullable<WebGLProgram>;
  30074. context?: WebGLRenderingContext;
  30075. vertexShader?: WebGLShader;
  30076. fragmentShader?: WebGLShader;
  30077. isParallelCompiled: boolean;
  30078. onCompiled?: () => void;
  30079. transformFeedback?: WebGLTransformFeedback | null;
  30080. readonly isAsync: boolean;
  30081. readonly isReady: boolean;
  30082. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30083. }
  30084. }
  30085. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30086. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30087. /** @hidden */
  30088. export class WebGLDataBuffer extends DataBuffer {
  30089. private _buffer;
  30090. constructor(resource: WebGLBuffer);
  30091. readonly underlyingResource: any;
  30092. }
  30093. }
  30094. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30095. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30096. /** @hidden */
  30097. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30098. attributeProcessor(attribute: string): string;
  30099. varyingProcessor(varying: string, isFragment: boolean): string;
  30100. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30101. }
  30102. }
  30103. declare module "babylonjs/Misc/perfCounter" {
  30104. /**
  30105. * This class is used to track a performance counter which is number based.
  30106. * The user has access to many properties which give statistics of different nature.
  30107. *
  30108. * The implementer can track two kinds of Performance Counter: time and count.
  30109. * 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.
  30110. * 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.
  30111. */
  30112. export class PerfCounter {
  30113. /**
  30114. * Gets or sets a global boolean to turn on and off all the counters
  30115. */
  30116. static Enabled: boolean;
  30117. /**
  30118. * Returns the smallest value ever
  30119. */
  30120. readonly min: number;
  30121. /**
  30122. * Returns the biggest value ever
  30123. */
  30124. readonly max: number;
  30125. /**
  30126. * Returns the average value since the performance counter is running
  30127. */
  30128. readonly average: number;
  30129. /**
  30130. * Returns the average value of the last second the counter was monitored
  30131. */
  30132. readonly lastSecAverage: number;
  30133. /**
  30134. * Returns the current value
  30135. */
  30136. readonly current: number;
  30137. /**
  30138. * Gets the accumulated total
  30139. */
  30140. readonly total: number;
  30141. /**
  30142. * Gets the total value count
  30143. */
  30144. readonly count: number;
  30145. /**
  30146. * Creates a new counter
  30147. */
  30148. constructor();
  30149. /**
  30150. * Call this method to start monitoring a new frame.
  30151. * 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.
  30152. */
  30153. fetchNewFrame(): void;
  30154. /**
  30155. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30156. * @param newCount the count value to add to the monitored count
  30157. * @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.
  30158. */
  30159. addCount(newCount: number, fetchResult: boolean): void;
  30160. /**
  30161. * Start monitoring this performance counter
  30162. */
  30163. beginMonitoring(): void;
  30164. /**
  30165. * Compute the time lapsed since the previous beginMonitoring() call.
  30166. * @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
  30167. */
  30168. endMonitoring(newFrame?: boolean): void;
  30169. private _fetchResult;
  30170. private _startMonitoringTime;
  30171. private _min;
  30172. private _max;
  30173. private _average;
  30174. private _current;
  30175. private _totalValueCount;
  30176. private _totalAccumulated;
  30177. private _lastSecAverage;
  30178. private _lastSecAccumulated;
  30179. private _lastSecTime;
  30180. private _lastSecValueCount;
  30181. }
  30182. }
  30183. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30184. /**
  30185. * Interface for any object that can request an animation frame
  30186. */
  30187. export interface ICustomAnimationFrameRequester {
  30188. /**
  30189. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30190. */
  30191. renderFunction?: Function;
  30192. /**
  30193. * Called to request the next frame to render to
  30194. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30195. */
  30196. requestAnimationFrame: Function;
  30197. /**
  30198. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30199. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30200. */
  30201. requestID?: number;
  30202. }
  30203. }
  30204. declare module "babylonjs/Materials/Textures/videoTexture" {
  30205. import { Observable } from "babylonjs/Misc/observable";
  30206. import { Nullable } from "babylonjs/types";
  30207. import { Scene } from "babylonjs/scene";
  30208. import { Texture } from "babylonjs/Materials/Textures/texture";
  30209. /**
  30210. * Settings for finer control over video usage
  30211. */
  30212. export interface VideoTextureSettings {
  30213. /**
  30214. * Applies `autoplay` to video, if specified
  30215. */
  30216. autoPlay?: boolean;
  30217. /**
  30218. * Applies `loop` to video, if specified
  30219. */
  30220. loop?: boolean;
  30221. /**
  30222. * Automatically updates internal texture from video at every frame in the render loop
  30223. */
  30224. autoUpdateTexture: boolean;
  30225. /**
  30226. * Image src displayed during the video loading or until the user interacts with the video.
  30227. */
  30228. poster?: string;
  30229. }
  30230. /**
  30231. * If you want to display a video in your scene, this is the special texture for that.
  30232. * This special texture works similar to other textures, with the exception of a few parameters.
  30233. * @see https://doc.babylonjs.com/how_to/video_texture
  30234. */
  30235. export class VideoTexture extends Texture {
  30236. /**
  30237. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30238. */
  30239. readonly autoUpdateTexture: boolean;
  30240. /**
  30241. * The video instance used by the texture internally
  30242. */
  30243. readonly video: HTMLVideoElement;
  30244. private _onUserActionRequestedObservable;
  30245. /**
  30246. * Event triggerd when a dom action is required by the user to play the video.
  30247. * This happens due to recent changes in browser policies preventing video to auto start.
  30248. */
  30249. readonly onUserActionRequestedObservable: Observable<Texture>;
  30250. private _generateMipMaps;
  30251. private _engine;
  30252. private _stillImageCaptured;
  30253. private _displayingPosterTexture;
  30254. private _settings;
  30255. private _createInternalTextureOnEvent;
  30256. /**
  30257. * Creates a video texture.
  30258. * If you want to display a video in your scene, this is the special texture for that.
  30259. * This special texture works similar to other textures, with the exception of a few parameters.
  30260. * @see https://doc.babylonjs.com/how_to/video_texture
  30261. * @param name optional name, will detect from video source, if not defined
  30262. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30263. * @param scene is obviously the current scene.
  30264. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30265. * @param invertY is false by default but can be used to invert video on Y axis
  30266. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30267. * @param settings allows finer control over video usage
  30268. */
  30269. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30270. private _getName;
  30271. private _getVideo;
  30272. private _createInternalTexture;
  30273. private reset;
  30274. /**
  30275. * @hidden Internal method to initiate `update`.
  30276. */
  30277. _rebuild(): void;
  30278. /**
  30279. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30280. */
  30281. update(): void;
  30282. /**
  30283. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30284. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30285. */
  30286. updateTexture(isVisible: boolean): void;
  30287. protected _updateInternalTexture: () => void;
  30288. /**
  30289. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30290. * @param url New url.
  30291. */
  30292. updateURL(url: string): void;
  30293. /**
  30294. * Dispose the texture and release its associated resources.
  30295. */
  30296. dispose(): void;
  30297. /**
  30298. * Creates a video texture straight from a stream.
  30299. * @param scene Define the scene the texture should be created in
  30300. * @param stream Define the stream the texture should be created from
  30301. * @returns The created video texture as a promise
  30302. */
  30303. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30304. /**
  30305. * Creates a video texture straight from your WebCam video feed.
  30306. * @param scene Define the scene the texture should be created in
  30307. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30308. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30309. * @returns The created video texture as a promise
  30310. */
  30311. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30312. minWidth: number;
  30313. maxWidth: number;
  30314. minHeight: number;
  30315. maxHeight: number;
  30316. deviceId: string;
  30317. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30318. /**
  30319. * Creates a video texture straight from your WebCam video feed.
  30320. * @param scene Define the scene the texture should be created in
  30321. * @param onReady Define a callback to triggered once the texture will be ready
  30322. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30323. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30324. */
  30325. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30326. minWidth: number;
  30327. maxWidth: number;
  30328. minHeight: number;
  30329. maxHeight: number;
  30330. deviceId: string;
  30331. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30332. }
  30333. }
  30334. declare module "babylonjs/Engines/engine" {
  30335. import { Observable } from "babylonjs/Misc/observable";
  30336. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30337. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30338. import { Scene } from "babylonjs/scene";
  30339. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30340. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30341. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30342. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30343. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30345. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30346. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30347. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30348. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30349. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30350. import { WebRequest } from "babylonjs/Misc/webRequest";
  30351. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30352. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30353. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30354. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30355. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30356. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30357. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30358. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30359. import { Material } from "babylonjs/Materials/material";
  30360. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30362. /**
  30363. * Defines the interface used by objects containing a viewport (like a camera)
  30364. */
  30365. interface IViewportOwnerLike {
  30366. /**
  30367. * Gets or sets the viewport
  30368. */
  30369. viewport: IViewportLike;
  30370. }
  30371. /**
  30372. * Interface for attribute information associated with buffer instanciation
  30373. */
  30374. export class InstancingAttributeInfo {
  30375. /**
  30376. * Index/offset of the attribute in the vertex shader
  30377. */
  30378. index: number;
  30379. /**
  30380. * size of the attribute, 1, 2, 3 or 4
  30381. */
  30382. attributeSize: number;
  30383. /**
  30384. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30385. * default is FLOAT
  30386. */
  30387. attribyteType: number;
  30388. /**
  30389. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30390. */
  30391. normalized: boolean;
  30392. /**
  30393. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30394. */
  30395. offset: number;
  30396. /**
  30397. * Name of the GLSL attribute, for debugging purpose only
  30398. */
  30399. attributeName: string;
  30400. }
  30401. /**
  30402. * Define options used to create a depth texture
  30403. */
  30404. export class DepthTextureCreationOptions {
  30405. /** Specifies whether or not a stencil should be allocated in the texture */
  30406. generateStencil?: boolean;
  30407. /** Specifies whether or not bilinear filtering is enable on the texture */
  30408. bilinearFiltering?: boolean;
  30409. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30410. comparisonFunction?: number;
  30411. /** Specifies if the created texture is a cube texture */
  30412. isCube?: boolean;
  30413. }
  30414. /**
  30415. * Class used to describe the capabilities of the engine relatively to the current browser
  30416. */
  30417. export class EngineCapabilities {
  30418. /** Maximum textures units per fragment shader */
  30419. maxTexturesImageUnits: number;
  30420. /** Maximum texture units per vertex shader */
  30421. maxVertexTextureImageUnits: number;
  30422. /** Maximum textures units in the entire pipeline */
  30423. maxCombinedTexturesImageUnits: number;
  30424. /** Maximum texture size */
  30425. maxTextureSize: number;
  30426. /** Maximum cube texture size */
  30427. maxCubemapTextureSize: number;
  30428. /** Maximum render texture size */
  30429. maxRenderTextureSize: number;
  30430. /** Maximum number of vertex attributes */
  30431. maxVertexAttribs: number;
  30432. /** Maximum number of varyings */
  30433. maxVaryingVectors: number;
  30434. /** Maximum number of uniforms per vertex shader */
  30435. maxVertexUniformVectors: number;
  30436. /** Maximum number of uniforms per fragment shader */
  30437. maxFragmentUniformVectors: number;
  30438. /** Defines if standard derivates (dx/dy) are supported */
  30439. standardDerivatives: boolean;
  30440. /** Defines if s3tc texture compression is supported */
  30441. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30442. /** Defines if pvrtc texture compression is supported */
  30443. pvrtc: any;
  30444. /** Defines if etc1 texture compression is supported */
  30445. etc1: any;
  30446. /** Defines if etc2 texture compression is supported */
  30447. etc2: any;
  30448. /** Defines if astc texture compression is supported */
  30449. astc: any;
  30450. /** Defines if float textures are supported */
  30451. textureFloat: boolean;
  30452. /** Defines if vertex array objects are supported */
  30453. vertexArrayObject: boolean;
  30454. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30455. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30456. /** Gets the maximum level of anisotropy supported */
  30457. maxAnisotropy: number;
  30458. /** Defines if instancing is supported */
  30459. instancedArrays: boolean;
  30460. /** Defines if 32 bits indices are supported */
  30461. uintIndices: boolean;
  30462. /** Defines if high precision shaders are supported */
  30463. highPrecisionShaderSupported: boolean;
  30464. /** Defines if depth reading in the fragment shader is supported */
  30465. fragmentDepthSupported: boolean;
  30466. /** Defines if float texture linear filtering is supported*/
  30467. textureFloatLinearFiltering: boolean;
  30468. /** Defines if rendering to float textures is supported */
  30469. textureFloatRender: boolean;
  30470. /** Defines if half float textures are supported*/
  30471. textureHalfFloat: boolean;
  30472. /** Defines if half float texture linear filtering is supported*/
  30473. textureHalfFloatLinearFiltering: boolean;
  30474. /** Defines if rendering to half float textures is supported */
  30475. textureHalfFloatRender: boolean;
  30476. /** Defines if textureLOD shader command is supported */
  30477. textureLOD: boolean;
  30478. /** Defines if draw buffers extension is supported */
  30479. drawBuffersExtension: boolean;
  30480. /** Defines if depth textures are supported */
  30481. depthTextureExtension: boolean;
  30482. /** Defines if float color buffer are supported */
  30483. colorBufferFloat: boolean;
  30484. /** Gets disjoint timer query extension (null if not supported) */
  30485. timerQuery: EXT_disjoint_timer_query;
  30486. /** Defines if timestamp can be used with timer query */
  30487. canUseTimestampForTimerQuery: boolean;
  30488. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30489. multiview: any;
  30490. /** Function used to let the system compiles shaders in background */
  30491. parallelShaderCompile: {
  30492. COMPLETION_STATUS_KHR: number;
  30493. };
  30494. /** Max number of texture samples for MSAA */
  30495. maxMSAASamples: number;
  30496. }
  30497. /** Interface defining initialization parameters for Engine class */
  30498. export interface EngineOptions extends WebGLContextAttributes {
  30499. /**
  30500. * Defines if the engine should no exceed a specified device ratio
  30501. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30502. */
  30503. limitDeviceRatio?: number;
  30504. /**
  30505. * Defines if webvr should be enabled automatically
  30506. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30507. */
  30508. autoEnableWebVR?: boolean;
  30509. /**
  30510. * Defines if webgl2 should be turned off even if supported
  30511. * @see http://doc.babylonjs.com/features/webgl2
  30512. */
  30513. disableWebGL2Support?: boolean;
  30514. /**
  30515. * Defines if webaudio should be initialized as well
  30516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30517. */
  30518. audioEngine?: boolean;
  30519. /**
  30520. * Defines if animations should run using a deterministic lock step
  30521. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30522. */
  30523. deterministicLockstep?: boolean;
  30524. /** Defines the maximum steps to use with deterministic lock step mode */
  30525. lockstepMaxSteps?: number;
  30526. /**
  30527. * Defines that engine should ignore context lost events
  30528. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30529. */
  30530. doNotHandleContextLost?: boolean;
  30531. /**
  30532. * Defines that engine should ignore modifying touch action attribute and style
  30533. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30534. */
  30535. doNotHandleTouchAction?: boolean;
  30536. /**
  30537. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30538. */
  30539. useHighPrecisionFloats?: boolean;
  30540. }
  30541. /**
  30542. * Defines the interface used by display changed events
  30543. */
  30544. export interface IDisplayChangedEventArgs {
  30545. /** Gets the vrDisplay object (if any) */
  30546. vrDisplay: Nullable<any>;
  30547. /** Gets a boolean indicating if webVR is supported */
  30548. vrSupported: boolean;
  30549. }
  30550. /**
  30551. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30552. */
  30553. export class Engine {
  30554. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30555. static ExceptionList: ({
  30556. key: string;
  30557. capture: string;
  30558. captureConstraint: number;
  30559. targets: string[];
  30560. } | {
  30561. key: string;
  30562. capture: null;
  30563. captureConstraint: null;
  30564. targets: string[];
  30565. })[];
  30566. /** Gets the list of created engines */
  30567. static readonly Instances: Engine[];
  30568. /**
  30569. * Gets the latest created engine
  30570. */
  30571. static readonly LastCreatedEngine: Nullable<Engine>;
  30572. /**
  30573. * Gets the latest created scene
  30574. */
  30575. static readonly LastCreatedScene: Nullable<Scene>;
  30576. /**
  30577. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30578. * @param flag defines which part of the materials must be marked as dirty
  30579. * @param predicate defines a predicate used to filter which materials should be affected
  30580. */
  30581. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30582. /** @hidden */
  30583. static _TextureLoaders: IInternalTextureLoader[];
  30584. /** Defines that alpha blending is disabled */
  30585. static readonly ALPHA_DISABLE: number;
  30586. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30587. static readonly ALPHA_ADD: number;
  30588. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30589. static readonly ALPHA_COMBINE: number;
  30590. /** Defines that alpha blending to DEST - SRC * DEST */
  30591. static readonly ALPHA_SUBTRACT: number;
  30592. /** Defines that alpha blending to SRC * DEST */
  30593. static readonly ALPHA_MULTIPLY: number;
  30594. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30595. static readonly ALPHA_MAXIMIZED: number;
  30596. /** Defines that alpha blending to SRC + DEST */
  30597. static readonly ALPHA_ONEONE: number;
  30598. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30599. static readonly ALPHA_PREMULTIPLIED: number;
  30600. /**
  30601. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30603. */
  30604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30605. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30606. static readonly ALPHA_INTERPOLATE: number;
  30607. /**
  30608. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30610. */
  30611. static readonly ALPHA_SCREENMODE: number;
  30612. /** Defines that the ressource is not delayed*/
  30613. static readonly DELAYLOADSTATE_NONE: number;
  30614. /** Defines that the ressource was successfully delay loaded */
  30615. static readonly DELAYLOADSTATE_LOADED: number;
  30616. /** Defines that the ressource is currently delay loading */
  30617. static readonly DELAYLOADSTATE_LOADING: number;
  30618. /** Defines that the ressource is delayed and has not started loading */
  30619. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30621. static readonly NEVER: number;
  30622. /** 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 */
  30623. static readonly ALWAYS: number;
  30624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30625. static readonly LESS: number;
  30626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30627. static readonly EQUAL: number;
  30628. /** 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 */
  30629. static readonly LEQUAL: number;
  30630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30631. static readonly GREATER: number;
  30632. /** 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 */
  30633. static readonly GEQUAL: number;
  30634. /** 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 */
  30635. static readonly NOTEQUAL: number;
  30636. /** Passed to stencilOperation to specify that stencil value must be kept */
  30637. static readonly KEEP: number;
  30638. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30639. static readonly REPLACE: number;
  30640. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30641. static readonly INCR: number;
  30642. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30643. static readonly DECR: number;
  30644. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30645. static readonly INVERT: number;
  30646. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30647. static readonly INCR_WRAP: number;
  30648. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30649. static readonly DECR_WRAP: number;
  30650. /** Texture is not repeating outside of 0..1 UVs */
  30651. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30652. /** Texture is repeating outside of 0..1 UVs */
  30653. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30654. /** Texture is repeating and mirrored */
  30655. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30656. /** ALPHA */
  30657. static readonly TEXTUREFORMAT_ALPHA: number;
  30658. /** LUMINANCE */
  30659. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30660. /** LUMINANCE_ALPHA */
  30661. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30662. /** RGB */
  30663. static readonly TEXTUREFORMAT_RGB: number;
  30664. /** RGBA */
  30665. static readonly TEXTUREFORMAT_RGBA: number;
  30666. /** RED */
  30667. static readonly TEXTUREFORMAT_RED: number;
  30668. /** RED (2nd reference) */
  30669. static readonly TEXTUREFORMAT_R: number;
  30670. /** RG */
  30671. static readonly TEXTUREFORMAT_RG: number;
  30672. /** RED_INTEGER */
  30673. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30674. /** RED_INTEGER (2nd reference) */
  30675. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30676. /** RG_INTEGER */
  30677. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30678. /** RGB_INTEGER */
  30679. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30680. /** RGBA_INTEGER */
  30681. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30682. /** UNSIGNED_BYTE */
  30683. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30684. /** UNSIGNED_BYTE (2nd reference) */
  30685. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30686. /** FLOAT */
  30687. static readonly TEXTURETYPE_FLOAT: number;
  30688. /** HALF_FLOAT */
  30689. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30690. /** BYTE */
  30691. static readonly TEXTURETYPE_BYTE: number;
  30692. /** SHORT */
  30693. static readonly TEXTURETYPE_SHORT: number;
  30694. /** UNSIGNED_SHORT */
  30695. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30696. /** INT */
  30697. static readonly TEXTURETYPE_INT: number;
  30698. /** UNSIGNED_INT */
  30699. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30700. /** UNSIGNED_SHORT_4_4_4_4 */
  30701. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30702. /** UNSIGNED_SHORT_5_5_5_1 */
  30703. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30704. /** UNSIGNED_SHORT_5_6_5 */
  30705. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30706. /** UNSIGNED_INT_2_10_10_10_REV */
  30707. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30708. /** UNSIGNED_INT_24_8 */
  30709. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30710. /** UNSIGNED_INT_10F_11F_11F_REV */
  30711. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30712. /** UNSIGNED_INT_5_9_9_9_REV */
  30713. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30714. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30715. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30716. /** nearest is mag = nearest and min = nearest and mip = linear */
  30717. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30718. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30719. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30720. /** Trilinear is mag = linear and min = linear and mip = linear */
  30721. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30722. /** nearest is mag = nearest and min = nearest and mip = linear */
  30723. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30724. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30725. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30726. /** Trilinear is mag = linear and min = linear and mip = linear */
  30727. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30728. /** mag = nearest and min = nearest and mip = nearest */
  30729. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30730. /** mag = nearest and min = linear and mip = nearest */
  30731. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30732. /** mag = nearest and min = linear and mip = linear */
  30733. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30734. /** mag = nearest and min = linear and mip = none */
  30735. static readonly TEXTURE_NEAREST_LINEAR: number;
  30736. /** mag = nearest and min = nearest and mip = none */
  30737. static readonly TEXTURE_NEAREST_NEAREST: number;
  30738. /** mag = linear and min = nearest and mip = nearest */
  30739. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30740. /** mag = linear and min = nearest and mip = linear */
  30741. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30742. /** mag = linear and min = linear and mip = none */
  30743. static readonly TEXTURE_LINEAR_LINEAR: number;
  30744. /** mag = linear and min = nearest and mip = none */
  30745. static readonly TEXTURE_LINEAR_NEAREST: number;
  30746. /** Explicit coordinates mode */
  30747. static readonly TEXTURE_EXPLICIT_MODE: number;
  30748. /** Spherical coordinates mode */
  30749. static readonly TEXTURE_SPHERICAL_MODE: number;
  30750. /** Planar coordinates mode */
  30751. static readonly TEXTURE_PLANAR_MODE: number;
  30752. /** Cubic coordinates mode */
  30753. static readonly TEXTURE_CUBIC_MODE: number;
  30754. /** Projection coordinates mode */
  30755. static readonly TEXTURE_PROJECTION_MODE: number;
  30756. /** Skybox coordinates mode */
  30757. static readonly TEXTURE_SKYBOX_MODE: number;
  30758. /** Inverse Cubic coordinates mode */
  30759. static readonly TEXTURE_INVCUBIC_MODE: number;
  30760. /** Equirectangular coordinates mode */
  30761. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30762. /** Equirectangular Fixed coordinates mode */
  30763. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30764. /** Equirectangular Fixed Mirrored coordinates mode */
  30765. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30766. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30767. static readonly SCALEMODE_FLOOR: number;
  30768. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30769. static readonly SCALEMODE_NEAREST: number;
  30770. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30771. static readonly SCALEMODE_CEILING: number;
  30772. /**
  30773. * Returns the current npm package of the sdk
  30774. */
  30775. static readonly NpmPackage: string;
  30776. /**
  30777. * Returns the current version of the framework
  30778. */
  30779. static readonly Version: string;
  30780. /**
  30781. * Returns a string describing the current engine
  30782. */
  30783. readonly description: string;
  30784. /**
  30785. * Gets or sets the epsilon value used by collision engine
  30786. */
  30787. static CollisionsEpsilon: number;
  30788. /**
  30789. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30790. */
  30791. static ShadersRepository: string;
  30792. /**
  30793. * Method called to create the default loading screen.
  30794. * This can be overriden in your own app.
  30795. * @param canvas The rendering canvas element
  30796. * @returns The loading screen
  30797. */
  30798. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30799. /**
  30800. * Method called to create the default rescale post process on each engine.
  30801. */
  30802. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30803. /** @hidden */
  30804. _shaderProcessor: IShaderProcessor;
  30805. /**
  30806. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30807. */
  30808. forcePOTTextures: boolean;
  30809. /**
  30810. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30811. */
  30812. isFullscreen: boolean;
  30813. /**
  30814. * Gets a boolean indicating if the pointer is currently locked
  30815. */
  30816. isPointerLock: boolean;
  30817. /**
  30818. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30819. */
  30820. cullBackFaces: boolean;
  30821. /**
  30822. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30823. */
  30824. renderEvenInBackground: boolean;
  30825. /**
  30826. * Gets or sets a boolean indicating that cache can be kept between frames
  30827. */
  30828. preventCacheWipeBetweenFrames: boolean;
  30829. /**
  30830. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30831. **/
  30832. enableOfflineSupport: boolean;
  30833. /**
  30834. * 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)
  30835. **/
  30836. disableManifestCheck: boolean;
  30837. /**
  30838. * Gets the list of created scenes
  30839. */
  30840. scenes: Scene[];
  30841. /**
  30842. * Event raised when a new scene is created
  30843. */
  30844. onNewSceneAddedObservable: Observable<Scene>;
  30845. /**
  30846. * Gets the list of created postprocesses
  30847. */
  30848. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30849. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30850. validateShaderPrograms: boolean;
  30851. /**
  30852. * Observable event triggered each time the rendering canvas is resized
  30853. */
  30854. onResizeObservable: Observable<Engine>;
  30855. /**
  30856. * Observable event triggered each time the canvas loses focus
  30857. */
  30858. onCanvasBlurObservable: Observable<Engine>;
  30859. /**
  30860. * Observable event triggered each time the canvas gains focus
  30861. */
  30862. onCanvasFocusObservable: Observable<Engine>;
  30863. /**
  30864. * Observable event triggered each time the canvas receives pointerout event
  30865. */
  30866. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30867. /**
  30868. * Observable event triggered before each texture is initialized
  30869. */
  30870. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30871. /**
  30872. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30873. */
  30874. disableUniformBuffers: boolean;
  30875. /** @hidden */
  30876. _uniformBuffers: UniformBuffer[];
  30877. /**
  30878. * Gets a boolean indicating that the engine supports uniform buffers
  30879. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30880. */
  30881. readonly supportsUniformBuffers: boolean;
  30882. /**
  30883. * Observable raised when the engine begins a new frame
  30884. */
  30885. onBeginFrameObservable: Observable<Engine>;
  30886. /**
  30887. * If set, will be used to request the next animation frame for the render loop
  30888. */
  30889. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30890. /**
  30891. * Observable raised when the engine ends the current frame
  30892. */
  30893. onEndFrameObservable: Observable<Engine>;
  30894. /**
  30895. * Observable raised when the engine is about to compile a shader
  30896. */
  30897. onBeforeShaderCompilationObservable: Observable<Engine>;
  30898. /**
  30899. * Observable raised when the engine has jsut compiled a shader
  30900. */
  30901. onAfterShaderCompilationObservable: Observable<Engine>;
  30902. /** @hidden */
  30903. _gl: WebGLRenderingContext;
  30904. private _renderingCanvas;
  30905. private _windowIsBackground;
  30906. private _webGLVersion;
  30907. protected _highPrecisionShadersAllowed: boolean;
  30908. /** @hidden */
  30909. readonly _shouldUseHighPrecisionShader: boolean;
  30910. /**
  30911. * Gets a boolean indicating that only power of 2 textures are supported
  30912. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30913. */
  30914. readonly needPOTTextures: boolean;
  30915. /** @hidden */
  30916. _badOS: boolean;
  30917. /** @hidden */
  30918. _badDesktopOS: boolean;
  30919. /**
  30920. * Gets the audio engine
  30921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30922. * @ignorenaming
  30923. */
  30924. static audioEngine: IAudioEngine;
  30925. /**
  30926. * Default AudioEngine factory responsible of creating the Audio Engine.
  30927. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30928. */
  30929. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30930. /**
  30931. * Default offline support factory responsible of creating a tool used to store data locally.
  30932. * By default, this will create a Database object if the workload has been embedded.
  30933. */
  30934. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30935. private _onFocus;
  30936. private _onBlur;
  30937. private _onCanvasPointerOut;
  30938. private _onCanvasBlur;
  30939. private _onCanvasFocus;
  30940. private _onFullscreenChange;
  30941. private _onPointerLockChange;
  30942. private _hardwareScalingLevel;
  30943. /** @hidden */
  30944. _caps: EngineCapabilities;
  30945. private _pointerLockRequested;
  30946. private _isStencilEnable;
  30947. private _colorWrite;
  30948. private _loadingScreen;
  30949. /** @hidden */
  30950. _drawCalls: PerfCounter;
  30951. private _glVersion;
  30952. private _glRenderer;
  30953. private _glVendor;
  30954. private _videoTextureSupported;
  30955. private _renderingQueueLaunched;
  30956. private _activeRenderLoops;
  30957. private _deterministicLockstep;
  30958. private _lockstepMaxSteps;
  30959. /**
  30960. * Observable signaled when a context lost event is raised
  30961. */
  30962. onContextLostObservable: Observable<Engine>;
  30963. /**
  30964. * Observable signaled when a context restored event is raised
  30965. */
  30966. onContextRestoredObservable: Observable<Engine>;
  30967. private _onContextLost;
  30968. private _onContextRestored;
  30969. private _contextWasLost;
  30970. /** @hidden */
  30971. _doNotHandleContextLost: boolean;
  30972. /**
  30973. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30974. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30975. */
  30976. doNotHandleContextLost: boolean;
  30977. private _performanceMonitor;
  30978. private _fps;
  30979. private _deltaTime;
  30980. /**
  30981. * Turn this value on if you want to pause FPS computation when in background
  30982. */
  30983. disablePerformanceMonitorInBackground: boolean;
  30984. /**
  30985. * Gets the performance monitor attached to this engine
  30986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30987. */
  30988. readonly performanceMonitor: PerformanceMonitor;
  30989. /**
  30990. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30991. */
  30992. disableVertexArrayObjects: boolean;
  30993. /** @hidden */
  30994. protected _depthCullingState: _DepthCullingState;
  30995. /** @hidden */
  30996. protected _stencilState: _StencilState;
  30997. /** @hidden */
  30998. protected _alphaState: _AlphaState;
  30999. /** @hidden */
  31000. protected _alphaMode: number;
  31001. /** @hidden */
  31002. _internalTexturesCache: InternalTexture[];
  31003. /** @hidden */
  31004. protected _activeChannel: number;
  31005. private _currentTextureChannel;
  31006. /** @hidden */
  31007. protected _boundTexturesCache: {
  31008. [key: string]: Nullable<InternalTexture>;
  31009. };
  31010. /** @hidden */
  31011. protected _currentEffect: Nullable<Effect>;
  31012. /** @hidden */
  31013. protected _currentProgram: Nullable<WebGLProgram>;
  31014. private _compiledEffects;
  31015. private _vertexAttribArraysEnabled;
  31016. /** @hidden */
  31017. protected _cachedViewport: Nullable<IViewportLike>;
  31018. private _cachedVertexArrayObject;
  31019. /** @hidden */
  31020. protected _cachedVertexBuffers: any;
  31021. /** @hidden */
  31022. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31023. /** @hidden */
  31024. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31025. /** @hidden */
  31026. _currentRenderTarget: Nullable<InternalTexture>;
  31027. private _uintIndicesCurrentlySet;
  31028. private _currentBoundBuffer;
  31029. /** @hidden */
  31030. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31031. private _currentBufferPointers;
  31032. private _currentInstanceLocations;
  31033. private _currentInstanceBuffers;
  31034. private _textureUnits;
  31035. /** @hidden */
  31036. _workingCanvas: Nullable<HTMLCanvasElement>;
  31037. /** @hidden */
  31038. _workingContext: Nullable<CanvasRenderingContext2D>;
  31039. private _rescalePostProcess;
  31040. private _dummyFramebuffer;
  31041. private _externalData;
  31042. /** @hidden */
  31043. _bindedRenderFunction: any;
  31044. private _vaoRecordInProgress;
  31045. private _mustWipeVertexAttributes;
  31046. private _emptyTexture;
  31047. private _emptyCubeTexture;
  31048. private _emptyTexture3D;
  31049. /** @hidden */
  31050. _frameHandler: number;
  31051. private _nextFreeTextureSlots;
  31052. private _maxSimultaneousTextures;
  31053. private _activeRequests;
  31054. private _texturesSupported;
  31055. /** @hidden */
  31056. _textureFormatInUse: Nullable<string>;
  31057. /**
  31058. * Gets the list of texture formats supported
  31059. */
  31060. readonly texturesSupported: Array<string>;
  31061. /**
  31062. * Gets the list of texture formats in use
  31063. */
  31064. readonly textureFormatInUse: Nullable<string>;
  31065. /**
  31066. * Gets the current viewport
  31067. */
  31068. readonly currentViewport: Nullable<IViewportLike>;
  31069. /**
  31070. * Gets the default empty texture
  31071. */
  31072. readonly emptyTexture: InternalTexture;
  31073. /**
  31074. * Gets the default empty 3D texture
  31075. */
  31076. readonly emptyTexture3D: InternalTexture;
  31077. /**
  31078. * Gets the default empty cube texture
  31079. */
  31080. readonly emptyCubeTexture: InternalTexture;
  31081. /**
  31082. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31083. */
  31084. readonly premultipliedAlpha: boolean;
  31085. /**
  31086. * Creates a new engine
  31087. * @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
  31088. * @param antialias defines enable antialiasing (default: false)
  31089. * @param options defines further options to be sent to the getContext() function
  31090. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31091. */
  31092. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31093. /**
  31094. * Initializes a webVR display and starts listening to display change events
  31095. * The onVRDisplayChangedObservable will be notified upon these changes
  31096. * @returns The onVRDisplayChangedObservable
  31097. */
  31098. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31099. /** @hidden */
  31100. _prepareVRComponent(): void;
  31101. /** @hidden */
  31102. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31103. /** @hidden */
  31104. _submitVRFrame(): void;
  31105. /**
  31106. * Call this function to leave webVR mode
  31107. * Will do nothing if webVR is not supported or if there is no webVR device
  31108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31109. */
  31110. disableVR(): void;
  31111. /**
  31112. * Gets a boolean indicating that the system is in VR mode and is presenting
  31113. * @returns true if VR mode is engaged
  31114. */
  31115. isVRPresenting(): boolean;
  31116. /** @hidden */
  31117. _requestVRFrame(): void;
  31118. private _disableTouchAction;
  31119. private _rebuildInternalTextures;
  31120. private _rebuildEffects;
  31121. /**
  31122. * Gets a boolean indicating if all created effects are ready
  31123. * @returns true if all effects are ready
  31124. */
  31125. areAllEffectsReady(): boolean;
  31126. private _rebuildBuffers;
  31127. private _initGLContext;
  31128. /**
  31129. * Gets version of the current webGL context
  31130. */
  31131. readonly webGLVersion: number;
  31132. /**
  31133. * Gets a string idenfifying the name of the class
  31134. * @returns "Engine" string
  31135. */
  31136. getClassName(): string;
  31137. /**
  31138. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31139. */
  31140. readonly isStencilEnable: boolean;
  31141. /** @hidden */
  31142. _prepareWorkingCanvas(): void;
  31143. /**
  31144. * Reset the texture cache to empty state
  31145. */
  31146. resetTextureCache(): void;
  31147. /**
  31148. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31150. * @returns true if engine is in deterministic lock step mode
  31151. */
  31152. isDeterministicLockStep(): boolean;
  31153. /**
  31154. * Gets the max steps when engine is running in deterministic lock step
  31155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31156. * @returns the max steps
  31157. */
  31158. getLockstepMaxSteps(): number;
  31159. /**
  31160. * Gets an object containing information about the current webGL context
  31161. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31162. */
  31163. getGlInfo(): {
  31164. vendor: string;
  31165. renderer: string;
  31166. version: string;
  31167. };
  31168. /**
  31169. * Gets current aspect ratio
  31170. * @param viewportOwner defines the camera to use to get the aspect ratio
  31171. * @param useScreen defines if screen size must be used (or the current render target if any)
  31172. * @returns a number defining the aspect ratio
  31173. */
  31174. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31175. /**
  31176. * Gets current screen aspect ratio
  31177. * @returns a number defining the aspect ratio
  31178. */
  31179. getScreenAspectRatio(): number;
  31180. /**
  31181. * Gets the current render width
  31182. * @param useScreen defines if screen size must be used (or the current render target if any)
  31183. * @returns a number defining the current render width
  31184. */
  31185. getRenderWidth(useScreen?: boolean): number;
  31186. /**
  31187. * Gets the current render height
  31188. * @param useScreen defines if screen size must be used (or the current render target if any)
  31189. * @returns a number defining the current render height
  31190. */
  31191. getRenderHeight(useScreen?: boolean): number;
  31192. /**
  31193. * Gets the HTML canvas attached with the current webGL context
  31194. * @returns a HTML canvas
  31195. */
  31196. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31197. /**
  31198. * Gets host window
  31199. * @returns the host window object
  31200. */
  31201. getHostWindow(): Window;
  31202. /**
  31203. * Gets host document
  31204. * @returns the host document object
  31205. */
  31206. getHostDocument(): Document;
  31207. /**
  31208. * Gets the client rect of the HTML canvas attached with the current webGL context
  31209. * @returns a client rectanglee
  31210. */
  31211. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31212. /**
  31213. * Defines the hardware scaling level.
  31214. * By default the hardware scaling level is computed from the window device ratio.
  31215. * 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.
  31216. * @param level defines the level to use
  31217. */
  31218. setHardwareScalingLevel(level: number): void;
  31219. /**
  31220. * Gets the current hardware scaling level.
  31221. * By default the hardware scaling level is computed from the window device ratio.
  31222. * 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.
  31223. * @returns a number indicating the current hardware scaling level
  31224. */
  31225. getHardwareScalingLevel(): number;
  31226. /**
  31227. * Gets the list of loaded textures
  31228. * @returns an array containing all loaded textures
  31229. */
  31230. getLoadedTexturesCache(): InternalTexture[];
  31231. /**
  31232. * Gets the object containing all engine capabilities
  31233. * @returns the EngineCapabilities object
  31234. */
  31235. getCaps(): EngineCapabilities;
  31236. /**
  31237. * Gets the current depth function
  31238. * @returns a number defining the depth function
  31239. */
  31240. getDepthFunction(): Nullable<number>;
  31241. /**
  31242. * Sets the current depth function
  31243. * @param depthFunc defines the function to use
  31244. */
  31245. setDepthFunction(depthFunc: number): void;
  31246. /**
  31247. * Sets the current depth function to GREATER
  31248. */
  31249. setDepthFunctionToGreater(): void;
  31250. /**
  31251. * Sets the current depth function to GEQUAL
  31252. */
  31253. setDepthFunctionToGreaterOrEqual(): void;
  31254. /**
  31255. * Sets the current depth function to LESS
  31256. */
  31257. setDepthFunctionToLess(): void;
  31258. private _cachedStencilBuffer;
  31259. private _cachedStencilFunction;
  31260. private _cachedStencilMask;
  31261. private _cachedStencilOperationPass;
  31262. private _cachedStencilOperationFail;
  31263. private _cachedStencilOperationDepthFail;
  31264. private _cachedStencilReference;
  31265. /**
  31266. * Caches the the state of the stencil buffer
  31267. */
  31268. cacheStencilState(): void;
  31269. /**
  31270. * Restores the state of the stencil buffer
  31271. */
  31272. restoreStencilState(): void;
  31273. /**
  31274. * Sets the current depth function to LEQUAL
  31275. */
  31276. setDepthFunctionToLessOrEqual(): void;
  31277. /**
  31278. * Gets a boolean indicating if stencil buffer is enabled
  31279. * @returns the current stencil buffer state
  31280. */
  31281. getStencilBuffer(): boolean;
  31282. /**
  31283. * Enable or disable the stencil buffer
  31284. * @param enable defines if the stencil buffer must be enabled or disabled
  31285. */
  31286. setStencilBuffer(enable: boolean): void;
  31287. /**
  31288. * Gets the current stencil mask
  31289. * @returns a number defining the new stencil mask to use
  31290. */
  31291. getStencilMask(): number;
  31292. /**
  31293. * Sets the current stencil mask
  31294. * @param mask defines the new stencil mask to use
  31295. */
  31296. setStencilMask(mask: number): void;
  31297. /**
  31298. * Gets the current stencil function
  31299. * @returns a number defining the stencil function to use
  31300. */
  31301. getStencilFunction(): number;
  31302. /**
  31303. * Gets the current stencil reference value
  31304. * @returns a number defining the stencil reference value to use
  31305. */
  31306. getStencilFunctionReference(): number;
  31307. /**
  31308. * Gets the current stencil mask
  31309. * @returns a number defining the stencil mask to use
  31310. */
  31311. getStencilFunctionMask(): number;
  31312. /**
  31313. * Sets the current stencil function
  31314. * @param stencilFunc defines the new stencil function to use
  31315. */
  31316. setStencilFunction(stencilFunc: number): void;
  31317. /**
  31318. * Sets the current stencil reference
  31319. * @param reference defines the new stencil reference to use
  31320. */
  31321. setStencilFunctionReference(reference: number): void;
  31322. /**
  31323. * Sets the current stencil mask
  31324. * @param mask defines the new stencil mask to use
  31325. */
  31326. setStencilFunctionMask(mask: number): void;
  31327. /**
  31328. * Gets the current stencil operation when stencil fails
  31329. * @returns a number defining stencil operation to use when stencil fails
  31330. */
  31331. getStencilOperationFail(): number;
  31332. /**
  31333. * Gets the current stencil operation when depth fails
  31334. * @returns a number defining stencil operation to use when depth fails
  31335. */
  31336. getStencilOperationDepthFail(): number;
  31337. /**
  31338. * Gets the current stencil operation when stencil passes
  31339. * @returns a number defining stencil operation to use when stencil passes
  31340. */
  31341. getStencilOperationPass(): number;
  31342. /**
  31343. * Sets the stencil operation to use when stencil fails
  31344. * @param operation defines the stencil operation to use when stencil fails
  31345. */
  31346. setStencilOperationFail(operation: number): void;
  31347. /**
  31348. * Sets the stencil operation to use when depth fails
  31349. * @param operation defines the stencil operation to use when depth fails
  31350. */
  31351. setStencilOperationDepthFail(operation: number): void;
  31352. /**
  31353. * Sets the stencil operation to use when stencil passes
  31354. * @param operation defines the stencil operation to use when stencil passes
  31355. */
  31356. setStencilOperationPass(operation: number): void;
  31357. /**
  31358. * Sets a boolean indicating if the dithering state is enabled or disabled
  31359. * @param value defines the dithering state
  31360. */
  31361. setDitheringState(value: boolean): void;
  31362. /**
  31363. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31364. * @param value defines the rasterizer state
  31365. */
  31366. setRasterizerState(value: boolean): void;
  31367. /**
  31368. * stop executing a render loop function and remove it from the execution array
  31369. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31370. */
  31371. stopRenderLoop(renderFunction?: () => void): void;
  31372. /** @hidden */
  31373. _renderLoop(): void;
  31374. /**
  31375. * Register and execute a render loop. The engine can have more than one render function
  31376. * @param renderFunction defines the function to continuously execute
  31377. */
  31378. runRenderLoop(renderFunction: () => void): void;
  31379. /**
  31380. * Toggle full screen mode
  31381. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31382. */
  31383. switchFullscreen(requestPointerLock: boolean): void;
  31384. /**
  31385. * Enters full screen mode
  31386. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31387. */
  31388. enterFullscreen(requestPointerLock: boolean): void;
  31389. /**
  31390. * Exits full screen mode
  31391. */
  31392. exitFullscreen(): void;
  31393. /**
  31394. * Enters Pointerlock mode
  31395. */
  31396. enterPointerlock(): void;
  31397. /**
  31398. * Exits Pointerlock mode
  31399. */
  31400. exitPointerlock(): void;
  31401. /**
  31402. * Clear the current render buffer or the current render target (if any is set up)
  31403. * @param color defines the color to use
  31404. * @param backBuffer defines if the back buffer must be cleared
  31405. * @param depth defines if the depth buffer must be cleared
  31406. * @param stencil defines if the stencil buffer must be cleared
  31407. */
  31408. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31409. /**
  31410. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31411. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31412. * @param y defines the y-coordinate of the corner of the clear rectangle
  31413. * @param width defines the width of the clear rectangle
  31414. * @param height defines the height of the clear rectangle
  31415. * @param clearColor defines the clear color
  31416. */
  31417. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31418. /**
  31419. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31420. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31421. * @param y defines the y-coordinate of the corner of the clear rectangle
  31422. * @param width defines the width of the clear rectangle
  31423. * @param height defines the height of the clear rectangle
  31424. */
  31425. enableScissor(x: number, y: number, width: number, height: number): void;
  31426. /**
  31427. * Disable previously set scissor test rectangle
  31428. */
  31429. disableScissor(): void;
  31430. private _viewportCached;
  31431. /** @hidden */
  31432. _viewport(x: number, y: number, width: number, height: number): void;
  31433. /**
  31434. * Set the WebGL's viewport
  31435. * @param viewport defines the viewport element to be used
  31436. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31437. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31438. */
  31439. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31440. /**
  31441. * Directly set the WebGL Viewport
  31442. * @param x defines the x coordinate of the viewport (in screen space)
  31443. * @param y defines the y coordinate of the viewport (in screen space)
  31444. * @param width defines the width of the viewport (in screen space)
  31445. * @param height defines the height of the viewport (in screen space)
  31446. * @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
  31447. */
  31448. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31449. /**
  31450. * Begin a new frame
  31451. */
  31452. beginFrame(): void;
  31453. /**
  31454. * Enf the current frame
  31455. */
  31456. endFrame(): void;
  31457. /**
  31458. * Resize the view according to the canvas' size
  31459. */
  31460. resize(): void;
  31461. /**
  31462. * Force a specific size of the canvas
  31463. * @param width defines the new canvas' width
  31464. * @param height defines the new canvas' height
  31465. */
  31466. setSize(width: number, height: number): void;
  31467. /**
  31468. * Binds the frame buffer to the specified texture.
  31469. * @param texture The texture to render to or null for the default canvas
  31470. * @param faceIndex The face of the texture to render to in case of cube texture
  31471. * @param requiredWidth The width of the target to render to
  31472. * @param requiredHeight The height of the target to render to
  31473. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31474. * @param depthStencilTexture The depth stencil texture to use to render
  31475. * @param lodLevel defines le lod level to bind to the frame buffer
  31476. */
  31477. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31478. /** @hidden */
  31479. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31480. /**
  31481. * Unbind the current render target texture from the webGL context
  31482. * @param texture defines the render target texture to unbind
  31483. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31484. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31485. */
  31486. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31487. /**
  31488. * Force the mipmap generation for the given render target texture
  31489. * @param texture defines the render target texture to use
  31490. */
  31491. generateMipMapsForCubemap(texture: InternalTexture): void;
  31492. /**
  31493. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31494. */
  31495. flushFramebuffer(): void;
  31496. /**
  31497. * Unbind the current render target and bind the default framebuffer
  31498. */
  31499. restoreDefaultFramebuffer(): void;
  31500. /**
  31501. * Create an uniform buffer
  31502. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31503. * @param elements defines the content of the uniform buffer
  31504. * @returns the webGL uniform buffer
  31505. */
  31506. createUniformBuffer(elements: FloatArray): DataBuffer;
  31507. /**
  31508. * Create a dynamic uniform buffer
  31509. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31510. * @param elements defines the content of the uniform buffer
  31511. * @returns the webGL uniform buffer
  31512. */
  31513. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31514. /**
  31515. * Update an existing uniform buffer
  31516. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31517. * @param uniformBuffer defines the target uniform buffer
  31518. * @param elements defines the content to update
  31519. * @param offset defines the offset in the uniform buffer where update should start
  31520. * @param count defines the size of the data to update
  31521. */
  31522. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31523. private _resetVertexBufferBinding;
  31524. /**
  31525. * Creates a vertex buffer
  31526. * @param data the data for the vertex buffer
  31527. * @returns the new WebGL static buffer
  31528. */
  31529. createVertexBuffer(data: DataArray): DataBuffer;
  31530. /**
  31531. * Creates a dynamic vertex buffer
  31532. * @param data the data for the dynamic vertex buffer
  31533. * @returns the new WebGL dynamic buffer
  31534. */
  31535. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31536. /**
  31537. * Update a dynamic index buffer
  31538. * @param indexBuffer defines the target index buffer
  31539. * @param indices defines the data to update
  31540. * @param offset defines the offset in the target index buffer where update should start
  31541. */
  31542. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31543. /**
  31544. * Updates a dynamic vertex buffer.
  31545. * @param vertexBuffer the vertex buffer to update
  31546. * @param data the data used to update the vertex buffer
  31547. * @param byteOffset the byte offset of the data
  31548. * @param byteLength the byte length of the data
  31549. */
  31550. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31551. private _resetIndexBufferBinding;
  31552. /**
  31553. * Creates a new index buffer
  31554. * @param indices defines the content of the index buffer
  31555. * @param updatable defines if the index buffer must be updatable
  31556. * @returns a new webGL buffer
  31557. */
  31558. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31559. /**
  31560. * Bind a webGL buffer to the webGL context
  31561. * @param buffer defines the buffer to bind
  31562. */
  31563. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31564. /**
  31565. * Bind an uniform buffer to the current webGL context
  31566. * @param buffer defines the buffer to bind
  31567. */
  31568. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31569. /**
  31570. * Bind a buffer to the current webGL context at a given location
  31571. * @param buffer defines the buffer to bind
  31572. * @param location defines the index where to bind the buffer
  31573. */
  31574. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31575. /**
  31576. * Bind a specific block at a given index in a specific shader program
  31577. * @param pipelineContext defines the pipeline context to use
  31578. * @param blockName defines the block name
  31579. * @param index defines the index where to bind the block
  31580. */
  31581. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31582. private bindIndexBuffer;
  31583. private bindBuffer;
  31584. /**
  31585. * update the bound buffer with the given data
  31586. * @param data defines the data to update
  31587. */
  31588. updateArrayBuffer(data: Float32Array): void;
  31589. private _vertexAttribPointer;
  31590. private _bindIndexBufferWithCache;
  31591. private _bindVertexBuffersAttributes;
  31592. /**
  31593. * Records a vertex array object
  31594. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31595. * @param vertexBuffers defines the list of vertex buffers to store
  31596. * @param indexBuffer defines the index buffer to store
  31597. * @param effect defines the effect to store
  31598. * @returns the new vertex array object
  31599. */
  31600. recordVertexArrayObject(vertexBuffers: {
  31601. [key: string]: VertexBuffer;
  31602. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31603. /**
  31604. * Bind a specific vertex array object
  31605. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31606. * @param vertexArrayObject defines the vertex array object to bind
  31607. * @param indexBuffer defines the index buffer to bind
  31608. */
  31609. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31610. /**
  31611. * Bind webGl buffers directly to the webGL context
  31612. * @param vertexBuffer defines the vertex buffer to bind
  31613. * @param indexBuffer defines the index buffer to bind
  31614. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31615. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31616. * @param effect defines the effect associated with the vertex buffer
  31617. */
  31618. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31619. private _unbindVertexArrayObject;
  31620. /**
  31621. * Bind a list of vertex buffers to the webGL context
  31622. * @param vertexBuffers defines the list of vertex buffers to bind
  31623. * @param indexBuffer defines the index buffer to bind
  31624. * @param effect defines the effect associated with the vertex buffers
  31625. */
  31626. bindBuffers(vertexBuffers: {
  31627. [key: string]: Nullable<VertexBuffer>;
  31628. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31629. /**
  31630. * Unbind all instance attributes
  31631. */
  31632. unbindInstanceAttributes(): void;
  31633. /**
  31634. * Release and free the memory of a vertex array object
  31635. * @param vao defines the vertex array object to delete
  31636. */
  31637. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31638. /** @hidden */
  31639. _releaseBuffer(buffer: DataBuffer): boolean;
  31640. /**
  31641. * Creates a webGL buffer to use with instanciation
  31642. * @param capacity defines the size of the buffer
  31643. * @returns the webGL buffer
  31644. */
  31645. createInstancesBuffer(capacity: number): DataBuffer;
  31646. /**
  31647. * Delete a webGL buffer used with instanciation
  31648. * @param buffer defines the webGL buffer to delete
  31649. */
  31650. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31651. /**
  31652. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31653. * @param instancesBuffer defines the webGL buffer to update and bind
  31654. * @param data defines the data to store in the buffer
  31655. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31656. */
  31657. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31658. /**
  31659. * Apply all cached states (depth, culling, stencil and alpha)
  31660. */
  31661. applyStates(): void;
  31662. /**
  31663. * Send a draw order
  31664. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31665. * @param indexStart defines the starting index
  31666. * @param indexCount defines the number of index to draw
  31667. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31668. */
  31669. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31670. /**
  31671. * Draw a list of points
  31672. * @param verticesStart defines the index of first vertex to draw
  31673. * @param verticesCount defines the count of vertices to draw
  31674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31675. */
  31676. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31677. /**
  31678. * Draw a list of unindexed primitives
  31679. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31680. * @param verticesStart defines the index of first vertex to draw
  31681. * @param verticesCount defines the count of vertices to draw
  31682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31683. */
  31684. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31685. /**
  31686. * Draw a list of indexed primitives
  31687. * @param fillMode defines the primitive to use
  31688. * @param indexStart defines the starting index
  31689. * @param indexCount defines the number of index to draw
  31690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31691. */
  31692. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31693. /**
  31694. * Draw a list of unindexed primitives
  31695. * @param fillMode defines the primitive to use
  31696. * @param verticesStart defines the index of first vertex to draw
  31697. * @param verticesCount defines the count of vertices to draw
  31698. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31699. */
  31700. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31701. private _drawMode;
  31702. /** @hidden */
  31703. _releaseEffect(effect: Effect): void;
  31704. /** @hidden */
  31705. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31706. /**
  31707. * Create a new effect (used to store vertex/fragment shaders)
  31708. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31709. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31710. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31711. * @param samplers defines an array of string used to represent textures
  31712. * @param defines defines the string containing the defines to use to compile the shaders
  31713. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31714. * @param onCompiled defines a function to call when the effect creation is successful
  31715. * @param onError defines a function to call when the effect creation has failed
  31716. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31717. * @returns the new Effect
  31718. */
  31719. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31720. private _compileShader;
  31721. private _compileRawShader;
  31722. /**
  31723. * Directly creates a webGL program
  31724. * @param pipelineContext defines the pipeline context to attach to
  31725. * @param vertexCode defines the vertex shader code to use
  31726. * @param fragmentCode defines the fragment shader code to use
  31727. * @param context defines the webGL context to use (if not set, the current one will be used)
  31728. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31729. * @returns the new webGL program
  31730. */
  31731. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31732. /**
  31733. * Creates a webGL program
  31734. * @param pipelineContext defines the pipeline context to attach to
  31735. * @param vertexCode defines the vertex shader code to use
  31736. * @param fragmentCode defines the fragment shader code to use
  31737. * @param defines defines the string containing the defines to use to compile the shaders
  31738. * @param context defines the webGL context to use (if not set, the current one will be used)
  31739. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31740. * @returns the new webGL program
  31741. */
  31742. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31743. /**
  31744. * Creates a new pipeline context
  31745. * @returns the new pipeline
  31746. */
  31747. createPipelineContext(): WebGLPipelineContext;
  31748. private _createShaderProgram;
  31749. private _finalizePipelineContext;
  31750. /** @hidden */
  31751. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31752. /** @hidden */
  31753. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31754. /** @hidden */
  31755. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31756. /**
  31757. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31758. * @param pipelineContext defines the pipeline context to use
  31759. * @param uniformsNames defines the list of uniform names
  31760. * @returns an array of webGL uniform locations
  31761. */
  31762. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31763. /**
  31764. * Gets the lsit of active attributes for a given webGL program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param attributesNames defines the list of attribute names to get
  31767. * @returns an array of indices indicating the offset of each attribute
  31768. */
  31769. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31770. /**
  31771. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31772. * @param effect defines the effect to activate
  31773. */
  31774. enableEffect(effect: Nullable<Effect>): void;
  31775. /**
  31776. * Set the value of an uniform to an array of int32
  31777. * @param uniform defines the webGL uniform location where to store the value
  31778. * @param array defines the array of int32 to store
  31779. */
  31780. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31781. /**
  31782. * Set the value of an uniform to an array of int32 (stored as vec2)
  31783. * @param uniform defines the webGL uniform location where to store the value
  31784. * @param array defines the array of int32 to store
  31785. */
  31786. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31787. /**
  31788. * Set the value of an uniform to an array of int32 (stored as vec3)
  31789. * @param uniform defines the webGL uniform location where to store the value
  31790. * @param array defines the array of int32 to store
  31791. */
  31792. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31793. /**
  31794. * Set the value of an uniform to an array of int32 (stored as vec4)
  31795. * @param uniform defines the webGL uniform location where to store the value
  31796. * @param array defines the array of int32 to store
  31797. */
  31798. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31799. /**
  31800. * Set the value of an uniform to an array of float32
  31801. * @param uniform defines the webGL uniform location where to store the value
  31802. * @param array defines the array of float32 to store
  31803. */
  31804. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31805. /**
  31806. * Set the value of an uniform to an array of float32 (stored as vec2)
  31807. * @param uniform defines the webGL uniform location where to store the value
  31808. * @param array defines the array of float32 to store
  31809. */
  31810. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31811. /**
  31812. * Set the value of an uniform to an array of float32 (stored as vec3)
  31813. * @param uniform defines the webGL uniform location where to store the value
  31814. * @param array defines the array of float32 to store
  31815. */
  31816. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31817. /**
  31818. * Set the value of an uniform to an array of float32 (stored as vec4)
  31819. * @param uniform defines the webGL uniform location where to store the value
  31820. * @param array defines the array of float32 to store
  31821. */
  31822. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31823. /**
  31824. * Set the value of an uniform to an array of number
  31825. * @param uniform defines the webGL uniform location where to store the value
  31826. * @param array defines the array of number to store
  31827. */
  31828. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31829. /**
  31830. * Set the value of an uniform to an array of number (stored as vec2)
  31831. * @param uniform defines the webGL uniform location where to store the value
  31832. * @param array defines the array of number to store
  31833. */
  31834. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31835. /**
  31836. * Set the value of an uniform to an array of number (stored as vec3)
  31837. * @param uniform defines the webGL uniform location where to store the value
  31838. * @param array defines the array of number to store
  31839. */
  31840. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31841. /**
  31842. * Set the value of an uniform to an array of number (stored as vec4)
  31843. * @param uniform defines the webGL uniform location where to store the value
  31844. * @param array defines the array of number to store
  31845. */
  31846. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31847. /**
  31848. * Set the value of an uniform to an array of float32 (stored as matrices)
  31849. * @param uniform defines the webGL uniform location where to store the value
  31850. * @param matrices defines the array of float32 to store
  31851. */
  31852. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31853. /**
  31854. * Set the value of an uniform to a matrix (3x3)
  31855. * @param uniform defines the webGL uniform location where to store the value
  31856. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31857. */
  31858. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31859. /**
  31860. * Set the value of an uniform to a matrix (2x2)
  31861. * @param uniform defines the webGL uniform location where to store the value
  31862. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31863. */
  31864. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31865. /**
  31866. * Set the value of an uniform to a number (int)
  31867. * @param uniform defines the webGL uniform location where to store the value
  31868. * @param value defines the int number to store
  31869. */
  31870. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31871. /**
  31872. * Set the value of an uniform to a number (float)
  31873. * @param uniform defines the webGL uniform location where to store the value
  31874. * @param value defines the float number to store
  31875. */
  31876. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31877. /**
  31878. * Set the value of an uniform to a vec2
  31879. * @param uniform defines the webGL uniform location where to store the value
  31880. * @param x defines the 1st component of the value
  31881. * @param y defines the 2nd component of the value
  31882. */
  31883. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31884. /**
  31885. * Set the value of an uniform to a vec3
  31886. * @param uniform defines the webGL uniform location where to store the value
  31887. * @param x defines the 1st component of the value
  31888. * @param y defines the 2nd component of the value
  31889. * @param z defines the 3rd component of the value
  31890. */
  31891. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31892. /**
  31893. * Set the value of an uniform to a boolean
  31894. * @param uniform defines the webGL uniform location where to store the value
  31895. * @param bool defines the boolean to store
  31896. */
  31897. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31898. /**
  31899. * Set the value of an uniform to a vec4
  31900. * @param uniform defines the webGL uniform location where to store the value
  31901. * @param x defines the 1st component of the value
  31902. * @param y defines the 2nd component of the value
  31903. * @param z defines the 3rd component of the value
  31904. * @param w defines the 4th component of the value
  31905. */
  31906. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31907. /**
  31908. * Sets a Color4 on a uniform variable
  31909. * @param uniform defines the uniform location
  31910. * @param color4 defines the value to be set
  31911. */
  31912. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31913. /**
  31914. * Set various states to the webGL context
  31915. * @param culling defines backface culling state
  31916. * @param zOffset defines the value to apply to zOffset (0 by default)
  31917. * @param force defines if states must be applied even if cache is up to date
  31918. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31919. */
  31920. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31921. /**
  31922. * Set the z offset to apply to current rendering
  31923. * @param value defines the offset to apply
  31924. */
  31925. setZOffset(value: number): void;
  31926. /**
  31927. * Gets the current value of the zOffset
  31928. * @returns the current zOffset state
  31929. */
  31930. getZOffset(): number;
  31931. /**
  31932. * Enable or disable depth buffering
  31933. * @param enable defines the state to set
  31934. */
  31935. setDepthBuffer(enable: boolean): void;
  31936. /**
  31937. * Gets a boolean indicating if depth writing is enabled
  31938. * @returns the current depth writing state
  31939. */
  31940. getDepthWrite(): boolean;
  31941. /**
  31942. * Enable or disable depth writing
  31943. * @param enable defines the state to set
  31944. */
  31945. setDepthWrite(enable: boolean): void;
  31946. /**
  31947. * Enable or disable color writing
  31948. * @param enable defines the state to set
  31949. */
  31950. setColorWrite(enable: boolean): void;
  31951. /**
  31952. * Gets a boolean indicating if color writing is enabled
  31953. * @returns the current color writing state
  31954. */
  31955. getColorWrite(): boolean;
  31956. /**
  31957. * Sets alpha constants used by some alpha blending modes
  31958. * @param r defines the red component
  31959. * @param g defines the green component
  31960. * @param b defines the blue component
  31961. * @param a defines the alpha component
  31962. */
  31963. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31964. /**
  31965. * Sets the current alpha mode
  31966. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31967. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31969. */
  31970. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31971. /**
  31972. * Gets the current alpha mode
  31973. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31974. * @returns the current alpha mode
  31975. */
  31976. getAlphaMode(): number;
  31977. /**
  31978. * Clears the list of texture accessible through engine.
  31979. * This can help preventing texture load conflict due to name collision.
  31980. */
  31981. clearInternalTexturesCache(): void;
  31982. /**
  31983. * Force the entire cache to be cleared
  31984. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31985. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31986. */
  31987. wipeCaches(bruteForce?: boolean): void;
  31988. /**
  31989. * Set the compressed texture format to use, based on the formats you have, and the formats
  31990. * supported by the hardware / browser.
  31991. *
  31992. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31993. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31994. * to API arguments needed to compressed textures. This puts the burden on the container
  31995. * generator to house the arcane code for determining these for current & future formats.
  31996. *
  31997. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31998. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31999. *
  32000. * Note: The result of this call is not taken into account when a texture is base64.
  32001. *
  32002. * @param formatsAvailable defines the list of those format families you have created
  32003. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32004. *
  32005. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32006. * @returns The extension selected.
  32007. */
  32008. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32009. /** @hidden */
  32010. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32011. min: number;
  32012. mag: number;
  32013. };
  32014. /** @hidden */
  32015. _createTexture(): WebGLTexture;
  32016. /**
  32017. * Usually called from Texture.ts.
  32018. * Passed information to create a WebGLTexture
  32019. * @param urlArg defines a value which contains one of the following:
  32020. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32021. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32022. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32023. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32024. * @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)
  32025. * @param scene needed for loading to the correct scene
  32026. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32027. * @param onLoad optional callback to be called upon successful completion
  32028. * @param onError optional callback to be called upon failure
  32029. * @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
  32030. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32031. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32032. * @param forcedExtension defines the extension to use to pick the right loader
  32033. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32034. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32035. */
  32036. 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;
  32037. /**
  32038. * @hidden
  32039. * Rescales a texture
  32040. * @param source input texutre
  32041. * @param destination destination texture
  32042. * @param scene scene to use to render the resize
  32043. * @param internalFormat format to use when resizing
  32044. * @param onComplete callback to be called when resize has completed
  32045. */
  32046. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32047. private _unpackFlipYCached;
  32048. /**
  32049. * In case you are sharing the context with other applications, it might
  32050. * be interested to not cache the unpack flip y state to ensure a consistent
  32051. * value would be set.
  32052. */
  32053. enableUnpackFlipYCached: boolean;
  32054. /** @hidden */
  32055. _unpackFlipY(value: boolean): void;
  32056. /** @hidden */
  32057. _getUnpackAlignement(): number;
  32058. /**
  32059. * Creates a dynamic texture
  32060. * @param width defines the width of the texture
  32061. * @param height defines the height of the texture
  32062. * @param generateMipMaps defines if the engine should generate the mip levels
  32063. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32064. * @returns the dynamic texture inside an InternalTexture
  32065. */
  32066. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32067. /**
  32068. * Update the sampling mode of a given texture
  32069. * @param samplingMode defines the required sampling mode
  32070. * @param texture defines the texture to update
  32071. */
  32072. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32073. /**
  32074. * Update the content of a dynamic texture
  32075. * @param texture defines the texture to update
  32076. * @param canvas defines the canvas containing the source
  32077. * @param invertY defines if data must be stored with Y axis inverted
  32078. * @param premulAlpha defines if alpha is stored as premultiplied
  32079. * @param format defines the format of the data
  32080. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32081. */
  32082. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32083. /**
  32084. * Update a video texture
  32085. * @param texture defines the texture to update
  32086. * @param video defines the video element to use
  32087. * @param invertY defines if data must be stored with Y axis inverted
  32088. */
  32089. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32090. /**
  32091. * Updates a depth texture Comparison Mode and Function.
  32092. * If the comparison Function is equal to 0, the mode will be set to none.
  32093. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32094. * @param texture The texture to set the comparison function for
  32095. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32096. */
  32097. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32098. /** @hidden */
  32099. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32100. width: number;
  32101. height: number;
  32102. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32103. /**
  32104. * Creates a depth stencil texture.
  32105. * This is only available in WebGL 2 or with the depth texture extension available.
  32106. * @param size The size of face edge in the texture.
  32107. * @param options The options defining the texture.
  32108. * @returns The texture
  32109. */
  32110. createDepthStencilTexture(size: number | {
  32111. width: number;
  32112. height: number;
  32113. }, options: DepthTextureCreationOptions): InternalTexture;
  32114. /**
  32115. * Creates a depth stencil texture.
  32116. * This is only available in WebGL 2 or with the depth texture extension available.
  32117. * @param size The size of face edge in the texture.
  32118. * @param options The options defining the texture.
  32119. * @returns The texture
  32120. */
  32121. private _createDepthStencilTexture;
  32122. /**
  32123. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32124. * @param renderTarget The render target to set the frame buffer for
  32125. */
  32126. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32127. /**
  32128. * Creates a new render target texture
  32129. * @param size defines the size of the texture
  32130. * @param options defines the options used to create the texture
  32131. * @returns a new render target texture stored in an InternalTexture
  32132. */
  32133. createRenderTargetTexture(size: number | {
  32134. width: number;
  32135. height: number;
  32136. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32137. /** @hidden */
  32138. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32139. /**
  32140. * Updates the sample count of a render target texture
  32141. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32142. * @param texture defines the texture to update
  32143. * @param samples defines the sample count to set
  32144. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32145. */
  32146. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32147. /** @hidden */
  32148. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32149. /** @hidden */
  32150. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32151. /** @hidden */
  32152. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32153. /** @hidden */
  32154. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32155. /**
  32156. * @hidden
  32157. */
  32158. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32159. private _prepareWebGLTextureContinuation;
  32160. private _prepareWebGLTexture;
  32161. /** @hidden */
  32162. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32163. /** @hidden */
  32164. _releaseFramebufferObjects(texture: InternalTexture): void;
  32165. /** @hidden */
  32166. _releaseTexture(texture: InternalTexture): void;
  32167. private setProgram;
  32168. private _boundUniforms;
  32169. /**
  32170. * Binds an effect to the webGL context
  32171. * @param effect defines the effect to bind
  32172. */
  32173. bindSamplers(effect: Effect): void;
  32174. private _activateCurrentTexture;
  32175. /** @hidden */
  32176. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32177. /** @hidden */
  32178. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32179. /**
  32180. * Sets a texture to the webGL context from a postprocess
  32181. * @param channel defines the channel to use
  32182. * @param postProcess defines the source postprocess
  32183. */
  32184. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32185. /**
  32186. * Binds the output of the passed in post process to the texture channel specified
  32187. * @param channel The channel the texture should be bound to
  32188. * @param postProcess The post process which's output should be bound
  32189. */
  32190. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32191. /**
  32192. * Unbind all textures from the webGL context
  32193. */
  32194. unbindAllTextures(): void;
  32195. /**
  32196. * Sets a texture to the according uniform.
  32197. * @param channel The texture channel
  32198. * @param uniform The uniform to set
  32199. * @param texture The texture to apply
  32200. */
  32201. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32202. /**
  32203. * Sets a depth stencil texture from a render target to the according uniform.
  32204. * @param channel The texture channel
  32205. * @param uniform The uniform to set
  32206. * @param texture The render target texture containing the depth stencil texture to apply
  32207. */
  32208. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32209. private _bindSamplerUniformToChannel;
  32210. private _getTextureWrapMode;
  32211. private _setTexture;
  32212. /**
  32213. * Sets an array of texture to the webGL context
  32214. * @param channel defines the channel where the texture array must be set
  32215. * @param uniform defines the associated uniform location
  32216. * @param textures defines the array of textures to bind
  32217. */
  32218. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32219. /** @hidden */
  32220. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32221. private _setTextureParameterFloat;
  32222. private _setTextureParameterInteger;
  32223. /**
  32224. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32225. * @param x defines the x coordinate of the rectangle where pixels must be read
  32226. * @param y defines the y coordinate of the rectangle where pixels must be read
  32227. * @param width defines the width of the rectangle where pixels must be read
  32228. * @param height defines the height of the rectangle where pixels must be read
  32229. * @returns a Uint8Array containing RGBA colors
  32230. */
  32231. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32232. /**
  32233. * Add an externaly attached data from its key.
  32234. * This method call will fail and return false, if such key already exists.
  32235. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32236. * @param key the unique key that identifies the data
  32237. * @param data the data object to associate to the key for this Engine instance
  32238. * @return true if no such key were already present and the data was added successfully, false otherwise
  32239. */
  32240. addExternalData<T>(key: string, data: T): boolean;
  32241. /**
  32242. * Get an externaly attached data from its key
  32243. * @param key the unique key that identifies the data
  32244. * @return the associated data, if present (can be null), or undefined if not present
  32245. */
  32246. getExternalData<T>(key: string): T;
  32247. /**
  32248. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32249. * @param key the unique key that identifies the data
  32250. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32251. * @return the associated data, can be null if the factory returned null.
  32252. */
  32253. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32254. /**
  32255. * Remove an externaly attached data from the Engine instance
  32256. * @param key the unique key that identifies the data
  32257. * @return true if the data was successfully removed, false if it doesn't exist
  32258. */
  32259. removeExternalData(key: string): boolean;
  32260. /**
  32261. * Unbind all vertex attributes from the webGL context
  32262. */
  32263. unbindAllAttributes(): void;
  32264. /**
  32265. * 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
  32266. */
  32267. releaseEffects(): void;
  32268. /**
  32269. * Dispose and release all associated resources
  32270. */
  32271. dispose(): void;
  32272. /**
  32273. * Display the loading screen
  32274. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32275. */
  32276. displayLoadingUI(): void;
  32277. /**
  32278. * Hide the loading screen
  32279. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32280. */
  32281. hideLoadingUI(): void;
  32282. /**
  32283. * Gets the current loading screen object
  32284. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32285. */
  32286. /**
  32287. * Sets the current loading screen object
  32288. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32289. */
  32290. loadingScreen: ILoadingScreen;
  32291. /**
  32292. * Sets the current loading screen text
  32293. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32294. */
  32295. loadingUIText: string;
  32296. /**
  32297. * Sets the current loading screen background color
  32298. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32299. */
  32300. loadingUIBackgroundColor: string;
  32301. /**
  32302. * Attach a new callback raised when context lost event is fired
  32303. * @param callback defines the callback to call
  32304. */
  32305. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32306. /**
  32307. * Attach a new callback raised when context restored event is fired
  32308. * @param callback defines the callback to call
  32309. */
  32310. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32311. /**
  32312. * Gets the source code of the vertex shader associated with a specific webGL program
  32313. * @param program defines the program to use
  32314. * @returns a string containing the source code of the vertex shader associated with the program
  32315. */
  32316. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32317. /**
  32318. * Gets the source code of the fragment shader associated with a specific webGL program
  32319. * @param program defines the program to use
  32320. * @returns a string containing the source code of the fragment shader associated with the program
  32321. */
  32322. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32323. /**
  32324. * Get the current error code of the webGL context
  32325. * @returns the error code
  32326. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32327. */
  32328. getError(): number;
  32329. /**
  32330. * Gets the current framerate
  32331. * @returns a number representing the framerate
  32332. */
  32333. getFps(): number;
  32334. /**
  32335. * Gets the time spent between current and previous frame
  32336. * @returns a number representing the delta time in ms
  32337. */
  32338. getDeltaTime(): number;
  32339. private _measureFps;
  32340. /** @hidden */
  32341. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32342. private _canRenderToFloatFramebuffer;
  32343. private _canRenderToHalfFloatFramebuffer;
  32344. private _canRenderToFramebuffer;
  32345. /** @hidden */
  32346. _getWebGLTextureType(type: number): number;
  32347. /** @hidden */
  32348. _getInternalFormat(format: number): number;
  32349. /** @hidden */
  32350. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32351. /** @hidden */
  32352. _getRGBAMultiSampleBufferFormat(type: number): number;
  32353. /** @hidden */
  32354. _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;
  32355. /** @hidden */
  32356. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32357. /**
  32358. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32359. * @returns true if the engine can be created
  32360. * @ignorenaming
  32361. */
  32362. static isSupported(): boolean;
  32363. /**
  32364. * Find the next highest power of two.
  32365. * @param x Number to start search from.
  32366. * @return Next highest power of two.
  32367. */
  32368. static CeilingPOT(x: number): number;
  32369. /**
  32370. * Find the next lowest power of two.
  32371. * @param x Number to start search from.
  32372. * @return Next lowest power of two.
  32373. */
  32374. static FloorPOT(x: number): number;
  32375. /**
  32376. * Find the nearest power of two.
  32377. * @param x Number to start search from.
  32378. * @return Next nearest power of two.
  32379. */
  32380. static NearestPOT(x: number): number;
  32381. /**
  32382. * Get the closest exponent of two
  32383. * @param value defines the value to approximate
  32384. * @param max defines the maximum value to return
  32385. * @param mode defines how to define the closest value
  32386. * @returns closest exponent of two of the given value
  32387. */
  32388. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32389. /**
  32390. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32391. * @param func - the function to be called
  32392. * @param requester - the object that will request the next frame. Falls back to window.
  32393. * @returns frame number
  32394. */
  32395. static QueueNewFrame(func: () => void, requester?: any): number;
  32396. /**
  32397. * Ask the browser to promote the current element to pointerlock mode
  32398. * @param element defines the DOM element to promote
  32399. */
  32400. static _RequestPointerlock(element: HTMLElement): void;
  32401. /**
  32402. * Asks the browser to exit pointerlock mode
  32403. */
  32404. static _ExitPointerlock(): void;
  32405. /**
  32406. * Ask the browser to promote the current element to fullscreen rendering mode
  32407. * @param element defines the DOM element to promote
  32408. */
  32409. static _RequestFullscreen(element: HTMLElement): void;
  32410. /**
  32411. * Asks the browser to exit fullscreen mode
  32412. */
  32413. static _ExitFullscreen(): void;
  32414. }
  32415. }
  32416. declare module "babylonjs/Engines/engineStore" {
  32417. import { Nullable } from "babylonjs/types";
  32418. import { Engine } from "babylonjs/Engines/engine";
  32419. import { Scene } from "babylonjs/scene";
  32420. /**
  32421. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32422. * during the life time of the application.
  32423. */
  32424. export class EngineStore {
  32425. /** Gets the list of created engines */
  32426. static Instances: import("babylonjs/Engines/engine").Engine[];
  32427. /** @hidden */
  32428. static _LastCreatedScene: Nullable<Scene>;
  32429. /**
  32430. * Gets the latest created engine
  32431. */
  32432. static readonly LastCreatedEngine: Nullable<Engine>;
  32433. /**
  32434. * Gets the latest created scene
  32435. */
  32436. static readonly LastCreatedScene: Nullable<Scene>;
  32437. /**
  32438. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32439. * @ignorenaming
  32440. */
  32441. static UseFallbackTexture: boolean;
  32442. /**
  32443. * Texture content used if a texture cannot loaded
  32444. * @ignorenaming
  32445. */
  32446. static FallbackTexture: string;
  32447. }
  32448. }
  32449. declare module "babylonjs/Misc/promise" {
  32450. /**
  32451. * Helper class that provides a small promise polyfill
  32452. */
  32453. export class PromisePolyfill {
  32454. /**
  32455. * Static function used to check if the polyfill is required
  32456. * If this is the case then the function will inject the polyfill to window.Promise
  32457. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32458. */
  32459. static Apply(force?: boolean): void;
  32460. }
  32461. }
  32462. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32463. /**
  32464. * Interface for screenshot methods with describe argument called `size` as object with options
  32465. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32466. */
  32467. export interface IScreenshotSize {
  32468. /**
  32469. * number in pixels for canvas height
  32470. */
  32471. height?: number;
  32472. /**
  32473. * multiplier allowing render at a higher or lower resolution
  32474. * If value is defined then height and width will be ignored and taken from camera
  32475. */
  32476. precision?: number;
  32477. /**
  32478. * number in pixels for canvas width
  32479. */
  32480. width?: number;
  32481. }
  32482. }
  32483. declare module "babylonjs/Misc/tools" {
  32484. import { Nullable, float } from "babylonjs/types";
  32485. import { DomManagement } from "babylonjs/Misc/domManagement";
  32486. import { WebRequest } from "babylonjs/Misc/webRequest";
  32487. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32488. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32489. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32490. import { Camera } from "babylonjs/Cameras/camera";
  32491. import { Engine } from "babylonjs/Engines/engine";
  32492. interface IColor4Like {
  32493. r: float;
  32494. g: float;
  32495. b: float;
  32496. a: float;
  32497. }
  32498. /**
  32499. * Class containing a set of static utilities functions
  32500. */
  32501. export class Tools {
  32502. /**
  32503. * Gets or sets the base URL to use to load assets
  32504. */
  32505. static BaseUrl: string;
  32506. /**
  32507. * Enable/Disable Custom HTTP Request Headers globally.
  32508. * default = false
  32509. * @see CustomRequestHeaders
  32510. */
  32511. static UseCustomRequestHeaders: boolean;
  32512. /**
  32513. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32514. * i.e. when loading files, where the server/service expects an Authorization header
  32515. */
  32516. static CustomRequestHeaders: {
  32517. [key: string]: string;
  32518. };
  32519. /**
  32520. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32521. */
  32522. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32523. /**
  32524. * Default behaviour for cors in the application.
  32525. * It can be a string if the expected behavior is identical in the entire app.
  32526. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32527. */
  32528. static CorsBehavior: string | ((url: string | string[]) => string);
  32529. /**
  32530. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32531. * @ignorenaming
  32532. */
  32533. static UseFallbackTexture: boolean;
  32534. /**
  32535. * Use this object to register external classes like custom textures or material
  32536. * to allow the laoders to instantiate them
  32537. */
  32538. static RegisteredExternalClasses: {
  32539. [key: string]: Object;
  32540. };
  32541. /**
  32542. * Texture content used if a texture cannot loaded
  32543. * @ignorenaming
  32544. */
  32545. static fallbackTexture: string;
  32546. /**
  32547. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32548. * @param u defines the coordinate on X axis
  32549. * @param v defines the coordinate on Y axis
  32550. * @param width defines the width of the source data
  32551. * @param height defines the height of the source data
  32552. * @param pixels defines the source byte array
  32553. * @param color defines the output color
  32554. */
  32555. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32556. /**
  32557. * Interpolates between a and b via alpha
  32558. * @param a The lower value (returned when alpha = 0)
  32559. * @param b The upper value (returned when alpha = 1)
  32560. * @param alpha The interpolation-factor
  32561. * @return The mixed value
  32562. */
  32563. static Mix(a: number, b: number, alpha: number): number;
  32564. /**
  32565. * Tries to instantiate a new object from a given class name
  32566. * @param className defines the class name to instantiate
  32567. * @returns the new object or null if the system was not able to do the instantiation
  32568. */
  32569. static Instantiate(className: string): any;
  32570. /**
  32571. * Provides a slice function that will work even on IE
  32572. * @param data defines the array to slice
  32573. * @param start defines the start of the data (optional)
  32574. * @param end defines the end of the data (optional)
  32575. * @returns the new sliced array
  32576. */
  32577. static Slice<T>(data: T, start?: number, end?: number): T;
  32578. /**
  32579. * Polyfill for setImmediate
  32580. * @param action defines the action to execute after the current execution block
  32581. */
  32582. static SetImmediate(action: () => void): void;
  32583. /**
  32584. * Function indicating if a number is an exponent of 2
  32585. * @param value defines the value to test
  32586. * @returns true if the value is an exponent of 2
  32587. */
  32588. static IsExponentOfTwo(value: number): boolean;
  32589. private static _tmpFloatArray;
  32590. /**
  32591. * Returns the nearest 32-bit single precision float representation of a Number
  32592. * @param value A Number. If the parameter is of a different type, it will get converted
  32593. * to a number or to NaN if it cannot be converted
  32594. * @returns number
  32595. */
  32596. static FloatRound(value: number): number;
  32597. /**
  32598. * Extracts the filename from a path
  32599. * @param path defines the path to use
  32600. * @returns the filename
  32601. */
  32602. static GetFilename(path: string): string;
  32603. /**
  32604. * Extracts the "folder" part of a path (everything before the filename).
  32605. * @param uri The URI to extract the info from
  32606. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32607. * @returns The "folder" part of the path
  32608. */
  32609. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32610. /**
  32611. * Extracts text content from a DOM element hierarchy
  32612. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32613. */
  32614. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32615. /**
  32616. * Convert an angle in radians to degrees
  32617. * @param angle defines the angle to convert
  32618. * @returns the angle in degrees
  32619. */
  32620. static ToDegrees(angle: number): number;
  32621. /**
  32622. * Convert an angle in degrees to radians
  32623. * @param angle defines the angle to convert
  32624. * @returns the angle in radians
  32625. */
  32626. static ToRadians(angle: number): number;
  32627. /**
  32628. * Encode a buffer to a base64 string
  32629. * @param buffer defines the buffer to encode
  32630. * @returns the encoded string
  32631. */
  32632. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32633. /**
  32634. * Returns an array if obj is not an array
  32635. * @param obj defines the object to evaluate as an array
  32636. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32637. * @returns either obj directly if obj is an array or a new array containing obj
  32638. */
  32639. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32640. /**
  32641. * Gets the pointer prefix to use
  32642. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32643. */
  32644. static GetPointerPrefix(): string;
  32645. /**
  32646. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32647. * @param url define the url we are trying
  32648. * @param element define the dom element where to configure the cors policy
  32649. */
  32650. static SetCorsBehavior(url: string | string[], element: {
  32651. crossOrigin: string | null;
  32652. }): void;
  32653. /**
  32654. * Removes unwanted characters from an url
  32655. * @param url defines the url to clean
  32656. * @returns the cleaned url
  32657. */
  32658. static CleanUrl(url: string): string;
  32659. /**
  32660. * Gets or sets a function used to pre-process url before using them to load assets
  32661. */
  32662. static PreprocessUrl: (url: string) => string;
  32663. /**
  32664. * Loads an image as an HTMLImageElement.
  32665. * @param input url string, ArrayBuffer, or Blob to load
  32666. * @param onLoad callback called when the image successfully loads
  32667. * @param onError callback called when the image fails to load
  32668. * @param offlineProvider offline provider for caching
  32669. * @returns the HTMLImageElement of the loaded image
  32670. */
  32671. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32672. /**
  32673. * Loads a file
  32674. * @param url url string, ArrayBuffer, or Blob to load
  32675. * @param onSuccess callback called when the file successfully loads
  32676. * @param onProgress callback called while file is loading (if the server supports this mode)
  32677. * @param offlineProvider defines the offline provider for caching
  32678. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32679. * @param onError callback called when the file fails to load
  32680. * @returns a file request object
  32681. */
  32682. 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;
  32683. /**
  32684. * Loads a file from a url
  32685. * @param url the file url to load
  32686. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32687. */
  32688. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32689. /**
  32690. * Load a script (identified by an url). When the url returns, the
  32691. * content of this file is added into a new script element, attached to the DOM (body element)
  32692. * @param scriptUrl defines the url of the script to laod
  32693. * @param onSuccess defines the callback called when the script is loaded
  32694. * @param onError defines the callback to call if an error occurs
  32695. * @param scriptId defines the id of the script element
  32696. */
  32697. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32698. /**
  32699. * Load an asynchronous script (identified by an url). When the url returns, the
  32700. * content of this file is added into a new script element, attached to the DOM (body element)
  32701. * @param scriptUrl defines the url of the script to laod
  32702. * @param scriptId defines the id of the script element
  32703. * @returns a promise request object
  32704. */
  32705. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32706. /**
  32707. * Loads a file from a blob
  32708. * @param fileToLoad defines the blob to use
  32709. * @param callback defines the callback to call when data is loaded
  32710. * @param progressCallback defines the callback to call during loading process
  32711. * @returns a file request object
  32712. */
  32713. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32714. /**
  32715. * Loads a file
  32716. * @param fileToLoad defines the file to load
  32717. * @param callback defines the callback to call when data is loaded
  32718. * @param progressCallBack defines the callback to call during loading process
  32719. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32720. * @returns a file request object
  32721. */
  32722. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32723. /**
  32724. * Creates a data url from a given string content
  32725. * @param content defines the content to convert
  32726. * @returns the new data url link
  32727. */
  32728. static FileAsURL(content: string): string;
  32729. /**
  32730. * Format the given number to a specific decimal format
  32731. * @param value defines the number to format
  32732. * @param decimals defines the number of decimals to use
  32733. * @returns the formatted string
  32734. */
  32735. static Format(value: number, decimals?: number): string;
  32736. /**
  32737. * Tries to copy an object by duplicating every property
  32738. * @param source defines the source object
  32739. * @param destination defines the target object
  32740. * @param doNotCopyList defines a list of properties to avoid
  32741. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32742. */
  32743. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32744. /**
  32745. * Gets a boolean indicating if the given object has no own property
  32746. * @param obj defines the object to test
  32747. * @returns true if object has no own property
  32748. */
  32749. static IsEmpty(obj: any): boolean;
  32750. /**
  32751. * Function used to register events at window level
  32752. * @param windowElement defines the Window object to use
  32753. * @param events defines the events to register
  32754. */
  32755. static RegisterTopRootEvents(windowElement: Window, events: {
  32756. name: string;
  32757. handler: Nullable<(e: FocusEvent) => any>;
  32758. }[]): void;
  32759. /**
  32760. * Function used to unregister events from window level
  32761. * @param windowElement defines the Window object to use
  32762. * @param events defines the events to unregister
  32763. */
  32764. static UnregisterTopRootEvents(windowElement: Window, events: {
  32765. name: string;
  32766. handler: Nullable<(e: FocusEvent) => any>;
  32767. }[]): void;
  32768. /**
  32769. * @ignore
  32770. */
  32771. static _ScreenshotCanvas: HTMLCanvasElement;
  32772. /**
  32773. * Dumps the current bound framebuffer
  32774. * @param width defines the rendering width
  32775. * @param height defines the rendering height
  32776. * @param engine defines the hosting engine
  32777. * @param successCallback defines the callback triggered once the data are available
  32778. * @param mimeType defines the mime type of the result
  32779. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32780. */
  32781. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32782. /**
  32783. * Converts the canvas data to blob.
  32784. * This acts as a polyfill for browsers not supporting the to blob function.
  32785. * @param canvas Defines the canvas to extract the data from
  32786. * @param successCallback Defines the callback triggered once the data are available
  32787. * @param mimeType Defines the mime type of the result
  32788. */
  32789. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32790. /**
  32791. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32792. * @param successCallback defines the callback triggered once the data are available
  32793. * @param mimeType defines the mime type of the result
  32794. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32795. */
  32796. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32797. /**
  32798. * Downloads a blob in the browser
  32799. * @param blob defines the blob to download
  32800. * @param fileName defines the name of the downloaded file
  32801. */
  32802. static Download(blob: Blob, fileName: string): void;
  32803. /**
  32804. * Captures a screenshot of the current rendering
  32805. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32806. * @param engine defines the rendering engine
  32807. * @param camera defines the source camera
  32808. * @param size This parameter can be set to a single number or to an object with the
  32809. * following (optional) properties: precision, width, height. If a single number is passed,
  32810. * it will be used for both width and height. If an object is passed, the screenshot size
  32811. * will be derived from the parameters. The precision property is a multiplier allowing
  32812. * rendering at a higher or lower resolution
  32813. * @param successCallback defines the callback receives a single parameter which contains the
  32814. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32815. * src parameter of an <img> to display it
  32816. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32817. * Check your browser for supported MIME types
  32818. */
  32819. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32820. /**
  32821. * Captures a screenshot of the current rendering
  32822. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32823. * @param engine defines the rendering engine
  32824. * @param camera defines the source camera
  32825. * @param size This parameter can be set to a single number or to an object with the
  32826. * following (optional) properties: precision, width, height. If a single number is passed,
  32827. * it will be used for both width and height. If an object is passed, the screenshot size
  32828. * will be derived from the parameters. The precision property is a multiplier allowing
  32829. * rendering at a higher or lower resolution
  32830. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32831. * Check your browser for supported MIME types
  32832. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32833. * to the src parameter of an <img> to display it
  32834. */
  32835. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32836. /**
  32837. * Generates an image screenshot from the specified camera.
  32838. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32839. * @param engine The engine to use for rendering
  32840. * @param camera The camera to use for rendering
  32841. * @param size This parameter can be set to a single number or to an object with the
  32842. * following (optional) properties: precision, width, height. If a single number is passed,
  32843. * it will be used for both width and height. If an object is passed, the screenshot size
  32844. * will be derived from the parameters. The precision property is a multiplier allowing
  32845. * rendering at a higher or lower resolution
  32846. * @param successCallback The callback receives a single parameter which contains the
  32847. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32848. * src parameter of an <img> to display it
  32849. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32850. * Check your browser for supported MIME types
  32851. * @param samples Texture samples (default: 1)
  32852. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32853. * @param fileName A name for for the downloaded file.
  32854. */
  32855. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32856. /**
  32857. * Generates an image screenshot from the specified camera.
  32858. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32859. * @param engine The engine to use for rendering
  32860. * @param camera The camera to use for rendering
  32861. * @param size This parameter can be set to a single number or to an object with the
  32862. * following (optional) properties: precision, width, height. If a single number is passed,
  32863. * it will be used for both width and height. If an object is passed, the screenshot size
  32864. * will be derived from the parameters. The precision property is a multiplier allowing
  32865. * rendering at a higher or lower resolution
  32866. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32867. * Check your browser for supported MIME types
  32868. * @param samples Texture samples (default: 1)
  32869. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32870. * @param fileName A name for for the downloaded file.
  32871. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32872. * to the src parameter of an <img> to display it
  32873. */
  32874. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32875. /**
  32876. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32877. * Be aware Math.random() could cause collisions, but:
  32878. * "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"
  32879. * @returns a pseudo random id
  32880. */
  32881. static RandomId(): string;
  32882. /**
  32883. * Test if the given uri is a base64 string
  32884. * @param uri The uri to test
  32885. * @return True if the uri is a base64 string or false otherwise
  32886. */
  32887. static IsBase64(uri: string): boolean;
  32888. /**
  32889. * Decode the given base64 uri.
  32890. * @param uri The uri to decode
  32891. * @return The decoded base64 data.
  32892. */
  32893. static DecodeBase64(uri: string): ArrayBuffer;
  32894. /**
  32895. * Gets the absolute url.
  32896. * @param url the input url
  32897. * @return the absolute url
  32898. */
  32899. static GetAbsoluteUrl(url: string): string;
  32900. /**
  32901. * No log
  32902. */
  32903. static readonly NoneLogLevel: number;
  32904. /**
  32905. * Only message logs
  32906. */
  32907. static readonly MessageLogLevel: number;
  32908. /**
  32909. * Only warning logs
  32910. */
  32911. static readonly WarningLogLevel: number;
  32912. /**
  32913. * Only error logs
  32914. */
  32915. static readonly ErrorLogLevel: number;
  32916. /**
  32917. * All logs
  32918. */
  32919. static readonly AllLogLevel: number;
  32920. /**
  32921. * Gets a value indicating the number of loading errors
  32922. * @ignorenaming
  32923. */
  32924. static readonly errorsCount: number;
  32925. /**
  32926. * Callback called when a new log is added
  32927. */
  32928. static OnNewCacheEntry: (entry: string) => void;
  32929. /**
  32930. * Log a message to the console
  32931. * @param message defines the message to log
  32932. */
  32933. static Log(message: string): void;
  32934. /**
  32935. * Write a warning message to the console
  32936. * @param message defines the message to log
  32937. */
  32938. static Warn(message: string): void;
  32939. /**
  32940. * Write an error message to the console
  32941. * @param message defines the message to log
  32942. */
  32943. static Error(message: string): void;
  32944. /**
  32945. * Gets current log cache (list of logs)
  32946. */
  32947. static readonly LogCache: string;
  32948. /**
  32949. * Clears the log cache
  32950. */
  32951. static ClearLogCache(): void;
  32952. /**
  32953. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32954. */
  32955. static LogLevels: number;
  32956. /**
  32957. * Checks if the window object exists
  32958. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32959. */
  32960. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32961. /**
  32962. * No performance log
  32963. */
  32964. static readonly PerformanceNoneLogLevel: number;
  32965. /**
  32966. * Use user marks to log performance
  32967. */
  32968. static readonly PerformanceUserMarkLogLevel: number;
  32969. /**
  32970. * Log performance to the console
  32971. */
  32972. static readonly PerformanceConsoleLogLevel: number;
  32973. private static _performance;
  32974. /**
  32975. * Sets the current performance log level
  32976. */
  32977. static PerformanceLogLevel: number;
  32978. private static _StartPerformanceCounterDisabled;
  32979. private static _EndPerformanceCounterDisabled;
  32980. private static _StartUserMark;
  32981. private static _EndUserMark;
  32982. private static _StartPerformanceConsole;
  32983. private static _EndPerformanceConsole;
  32984. /**
  32985. * Starts a performance counter
  32986. */
  32987. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32988. /**
  32989. * Ends a specific performance coutner
  32990. */
  32991. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32992. /**
  32993. * Gets either window.performance.now() if supported or Date.now() else
  32994. */
  32995. static readonly Now: number;
  32996. /**
  32997. * This method will return the name of the class used to create the instance of the given object.
  32998. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32999. * @param object the object to get the class name from
  33000. * @param isType defines if the object is actually a type
  33001. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33002. */
  33003. static GetClassName(object: any, isType?: boolean): string;
  33004. /**
  33005. * Gets the first element of an array satisfying a given predicate
  33006. * @param array defines the array to browse
  33007. * @param predicate defines the predicate to use
  33008. * @returns null if not found or the element
  33009. */
  33010. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33011. /**
  33012. * This method will return the name of the full name of the class, including its owning module (if any).
  33013. * 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).
  33014. * @param object the object to get the class name from
  33015. * @param isType defines if the object is actually a type
  33016. * @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.
  33017. * @ignorenaming
  33018. */
  33019. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33020. /**
  33021. * Returns a promise that resolves after the given amount of time.
  33022. * @param delay Number of milliseconds to delay
  33023. * @returns Promise that resolves after the given amount of time
  33024. */
  33025. static DelayAsync(delay: number): Promise<void>;
  33026. }
  33027. /**
  33028. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33029. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33030. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33031. * @param name The name of the class, case should be preserved
  33032. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33033. */
  33034. export function className(name: string, module?: string): (target: Object) => void;
  33035. /**
  33036. * An implementation of a loop for asynchronous functions.
  33037. */
  33038. export class AsyncLoop {
  33039. /**
  33040. * Defines the number of iterations for the loop
  33041. */
  33042. iterations: number;
  33043. /**
  33044. * Defines the current index of the loop.
  33045. */
  33046. index: number;
  33047. private _done;
  33048. private _fn;
  33049. private _successCallback;
  33050. /**
  33051. * Constructor.
  33052. * @param iterations the number of iterations.
  33053. * @param func the function to run each iteration
  33054. * @param successCallback the callback that will be called upon succesful execution
  33055. * @param offset starting offset.
  33056. */
  33057. constructor(
  33058. /**
  33059. * Defines the number of iterations for the loop
  33060. */
  33061. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33062. /**
  33063. * Execute the next iteration. Must be called after the last iteration was finished.
  33064. */
  33065. executeNext(): void;
  33066. /**
  33067. * Break the loop and run the success callback.
  33068. */
  33069. breakLoop(): void;
  33070. /**
  33071. * Create and run an async loop.
  33072. * @param iterations the number of iterations.
  33073. * @param fn the function to run each iteration
  33074. * @param successCallback the callback that will be called upon succesful execution
  33075. * @param offset starting offset.
  33076. * @returns the created async loop object
  33077. */
  33078. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33079. /**
  33080. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33081. * @param iterations total number of iterations
  33082. * @param syncedIterations number of synchronous iterations in each async iteration.
  33083. * @param fn the function to call each iteration.
  33084. * @param callback a success call back that will be called when iterating stops.
  33085. * @param breakFunction a break condition (optional)
  33086. * @param timeout timeout settings for the setTimeout function. default - 0.
  33087. * @returns the created async loop object
  33088. */
  33089. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33090. }
  33091. }
  33092. declare module "babylonjs/Collisions/collisionCoordinator" {
  33093. import { Nullable } from "babylonjs/types";
  33094. import { Scene } from "babylonjs/scene";
  33095. import { Vector3 } from "babylonjs/Maths/math.vector";
  33096. import { Collider } from "babylonjs/Collisions/collider";
  33097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33098. /** @hidden */
  33099. export interface ICollisionCoordinator {
  33100. createCollider(): Collider;
  33101. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33102. init(scene: Scene): void;
  33103. }
  33104. /** @hidden */
  33105. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33106. private _scene;
  33107. private _scaledPosition;
  33108. private _scaledVelocity;
  33109. private _finalPosition;
  33110. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33111. createCollider(): Collider;
  33112. init(scene: Scene): void;
  33113. private _collideWithWorld;
  33114. }
  33115. }
  33116. declare module "babylonjs/Inputs/scene.inputManager" {
  33117. import { Nullable } from "babylonjs/types";
  33118. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33119. import { Vector2 } from "babylonjs/Maths/math.vector";
  33120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33121. import { Scene } from "babylonjs/scene";
  33122. /**
  33123. * Class used to manage all inputs for the scene.
  33124. */
  33125. export class InputManager {
  33126. /** The distance in pixel that you have to move to prevent some events */
  33127. static DragMovementThreshold: number;
  33128. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33129. static LongPressDelay: number;
  33130. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33131. static DoubleClickDelay: number;
  33132. /** If you need to check double click without raising a single click at first click, enable this flag */
  33133. static ExclusiveDoubleClickMode: boolean;
  33134. private _wheelEventName;
  33135. private _onPointerMove;
  33136. private _onPointerDown;
  33137. private _onPointerUp;
  33138. private _initClickEvent;
  33139. private _initActionManager;
  33140. private _delayedSimpleClick;
  33141. private _delayedSimpleClickTimeout;
  33142. private _previousDelayedSimpleClickTimeout;
  33143. private _meshPickProceed;
  33144. private _previousButtonPressed;
  33145. private _currentPickResult;
  33146. private _previousPickResult;
  33147. private _totalPointersPressed;
  33148. private _doubleClickOccured;
  33149. private _pointerOverMesh;
  33150. private _pickedDownMesh;
  33151. private _pickedUpMesh;
  33152. private _pointerX;
  33153. private _pointerY;
  33154. private _unTranslatedPointerX;
  33155. private _unTranslatedPointerY;
  33156. private _startingPointerPosition;
  33157. private _previousStartingPointerPosition;
  33158. private _startingPointerTime;
  33159. private _previousStartingPointerTime;
  33160. private _pointerCaptures;
  33161. private _onKeyDown;
  33162. private _onKeyUp;
  33163. private _onCanvasFocusObserver;
  33164. private _onCanvasBlurObserver;
  33165. private _scene;
  33166. /**
  33167. * Creates a new InputManager
  33168. * @param scene defines the hosting scene
  33169. */
  33170. constructor(scene: Scene);
  33171. /**
  33172. * Gets the mesh that is currently under the pointer
  33173. */
  33174. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33175. /**
  33176. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33177. */
  33178. readonly unTranslatedPointer: Vector2;
  33179. /**
  33180. * Gets or sets the current on-screen X position of the pointer
  33181. */
  33182. pointerX: number;
  33183. /**
  33184. * Gets or sets the current on-screen Y position of the pointer
  33185. */
  33186. pointerY: number;
  33187. private _updatePointerPosition;
  33188. private _processPointerMove;
  33189. private _setRayOnPointerInfo;
  33190. private _checkPrePointerObservable;
  33191. /**
  33192. * Use this method to simulate a pointer move on a mesh
  33193. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33194. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33195. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33196. */
  33197. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33198. /**
  33199. * Use this method to simulate a pointer down on a mesh
  33200. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33201. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33202. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33203. */
  33204. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33205. private _processPointerDown;
  33206. /** @hidden */
  33207. _isPointerSwiping(): boolean;
  33208. /**
  33209. * Use this method to simulate a pointer up on a mesh
  33210. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33211. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33212. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33213. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33214. */
  33215. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33216. private _processPointerUp;
  33217. /**
  33218. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33219. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33220. * @returns true if the pointer was captured
  33221. */
  33222. isPointerCaptured(pointerId?: number): boolean;
  33223. /**
  33224. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33225. * @param attachUp defines if you want to attach events to pointerup
  33226. * @param attachDown defines if you want to attach events to pointerdown
  33227. * @param attachMove defines if you want to attach events to pointermove
  33228. */
  33229. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33230. /**
  33231. * Detaches all event handlers
  33232. */
  33233. detachControl(): void;
  33234. /**
  33235. * Force the value of meshUnderPointer
  33236. * @param mesh defines the mesh to use
  33237. */
  33238. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33239. /**
  33240. * Gets the mesh under the pointer
  33241. * @returns a Mesh or null if no mesh is under the pointer
  33242. */
  33243. getPointerOverMesh(): Nullable<AbstractMesh>;
  33244. }
  33245. }
  33246. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33247. /**
  33248. * Helper class used to generate session unique ID
  33249. */
  33250. export class UniqueIdGenerator {
  33251. private static _UniqueIdCounter;
  33252. /**
  33253. * Gets an unique (relatively to the current scene) Id
  33254. */
  33255. static readonly UniqueId: number;
  33256. }
  33257. }
  33258. declare module "babylonjs/Animations/animationGroup" {
  33259. import { Animatable } from "babylonjs/Animations/animatable";
  33260. import { Animation } from "babylonjs/Animations/animation";
  33261. import { Scene, IDisposable } from "babylonjs/scene";
  33262. import { Observable } from "babylonjs/Misc/observable";
  33263. import { Nullable } from "babylonjs/types";
  33264. import "babylonjs/Animations/animatable";
  33265. /**
  33266. * This class defines the direct association between an animation and a target
  33267. */
  33268. export class TargetedAnimation {
  33269. /**
  33270. * Animation to perform
  33271. */
  33272. animation: Animation;
  33273. /**
  33274. * Target to animate
  33275. */
  33276. target: any;
  33277. /**
  33278. * Serialize the object
  33279. * @returns the JSON object representing the current entity
  33280. */
  33281. serialize(): any;
  33282. }
  33283. /**
  33284. * Use this class to create coordinated animations on multiple targets
  33285. */
  33286. export class AnimationGroup implements IDisposable {
  33287. /** The name of the animation group */
  33288. name: string;
  33289. private _scene;
  33290. private _targetedAnimations;
  33291. private _animatables;
  33292. private _from;
  33293. private _to;
  33294. private _isStarted;
  33295. private _isPaused;
  33296. private _speedRatio;
  33297. private _loopAnimation;
  33298. /**
  33299. * Gets or sets the unique id of the node
  33300. */
  33301. uniqueId: number;
  33302. /**
  33303. * This observable will notify when one animation have ended
  33304. */
  33305. onAnimationEndObservable: Observable<TargetedAnimation>;
  33306. /**
  33307. * Observer raised when one animation loops
  33308. */
  33309. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33310. /**
  33311. * This observable will notify when all animations have ended.
  33312. */
  33313. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33314. /**
  33315. * This observable will notify when all animations have paused.
  33316. */
  33317. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33318. /**
  33319. * This observable will notify when all animations are playing.
  33320. */
  33321. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33322. /**
  33323. * Gets the first frame
  33324. */
  33325. readonly from: number;
  33326. /**
  33327. * Gets the last frame
  33328. */
  33329. readonly to: number;
  33330. /**
  33331. * Define if the animations are started
  33332. */
  33333. readonly isStarted: boolean;
  33334. /**
  33335. * Gets a value indicating that the current group is playing
  33336. */
  33337. readonly isPlaying: boolean;
  33338. /**
  33339. * Gets or sets the speed ratio to use for all animations
  33340. */
  33341. /**
  33342. * Gets or sets the speed ratio to use for all animations
  33343. */
  33344. speedRatio: number;
  33345. /**
  33346. * Gets or sets if all animations should loop or not
  33347. */
  33348. loopAnimation: boolean;
  33349. /**
  33350. * Gets the targeted animations for this animation group
  33351. */
  33352. readonly targetedAnimations: Array<TargetedAnimation>;
  33353. /**
  33354. * returning the list of animatables controlled by this animation group.
  33355. */
  33356. readonly animatables: Array<Animatable>;
  33357. /**
  33358. * Instantiates a new Animation Group.
  33359. * This helps managing several animations at once.
  33360. * @see http://doc.babylonjs.com/how_to/group
  33361. * @param name Defines the name of the group
  33362. * @param scene Defines the scene the group belongs to
  33363. */
  33364. constructor(
  33365. /** The name of the animation group */
  33366. name: string, scene?: Nullable<Scene>);
  33367. /**
  33368. * Add an animation (with its target) in the group
  33369. * @param animation defines the animation we want to add
  33370. * @param target defines the target of the animation
  33371. * @returns the TargetedAnimation object
  33372. */
  33373. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33374. /**
  33375. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33376. * It can add constant keys at begin or end
  33377. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33378. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33379. * @returns the animation group
  33380. */
  33381. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33382. /**
  33383. * Start all animations on given targets
  33384. * @param loop defines if animations must loop
  33385. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33386. * @param from defines the from key (optional)
  33387. * @param to defines the to key (optional)
  33388. * @returns the current animation group
  33389. */
  33390. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33391. /**
  33392. * Pause all animations
  33393. * @returns the animation group
  33394. */
  33395. pause(): AnimationGroup;
  33396. /**
  33397. * Play all animations to initial state
  33398. * This function will start() the animations if they were not started or will restart() them if they were paused
  33399. * @param loop defines if animations must loop
  33400. * @returns the animation group
  33401. */
  33402. play(loop?: boolean): AnimationGroup;
  33403. /**
  33404. * Reset all animations to initial state
  33405. * @returns the animation group
  33406. */
  33407. reset(): AnimationGroup;
  33408. /**
  33409. * Restart animations from key 0
  33410. * @returns the animation group
  33411. */
  33412. restart(): AnimationGroup;
  33413. /**
  33414. * Stop all animations
  33415. * @returns the animation group
  33416. */
  33417. stop(): AnimationGroup;
  33418. /**
  33419. * Set animation weight for all animatables
  33420. * @param weight defines the weight to use
  33421. * @return the animationGroup
  33422. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33423. */
  33424. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33425. /**
  33426. * Synchronize and normalize all animatables with a source animatable
  33427. * @param root defines the root animatable to synchronize with
  33428. * @return the animationGroup
  33429. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33430. */
  33431. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33432. /**
  33433. * Goes to a specific frame in this animation group
  33434. * @param frame the frame number to go to
  33435. * @return the animationGroup
  33436. */
  33437. goToFrame(frame: number): AnimationGroup;
  33438. /**
  33439. * Dispose all associated resources
  33440. */
  33441. dispose(): void;
  33442. private _checkAnimationGroupEnded;
  33443. /**
  33444. * Clone the current animation group and returns a copy
  33445. * @param newName defines the name of the new group
  33446. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33447. * @returns the new aniamtion group
  33448. */
  33449. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33450. /**
  33451. * Serializes the animationGroup to an object
  33452. * @returns Serialized object
  33453. */
  33454. serialize(): any;
  33455. /**
  33456. * Returns a new AnimationGroup object parsed from the source provided.
  33457. * @param parsedAnimationGroup defines the source
  33458. * @param scene defines the scene that will receive the animationGroup
  33459. * @returns a new AnimationGroup
  33460. */
  33461. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33462. /**
  33463. * Returns the string "AnimationGroup"
  33464. * @returns "AnimationGroup"
  33465. */
  33466. getClassName(): string;
  33467. /**
  33468. * Creates a detailled string about the object
  33469. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33470. * @returns a string representing the object
  33471. */
  33472. toString(fullDetails?: boolean): string;
  33473. }
  33474. }
  33475. declare module "babylonjs/scene" {
  33476. import { Nullable } from "babylonjs/types";
  33477. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33478. import { Observable } from "babylonjs/Misc/observable";
  33479. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33480. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33481. import { Geometry } from "babylonjs/Meshes/geometry";
  33482. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33483. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33485. import { Mesh } from "babylonjs/Meshes/mesh";
  33486. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33487. import { Bone } from "babylonjs/Bones/bone";
  33488. import { Skeleton } from "babylonjs/Bones/skeleton";
  33489. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33490. import { Camera } from "babylonjs/Cameras/camera";
  33491. import { AbstractScene } from "babylonjs/abstractScene";
  33492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33494. import { Material } from "babylonjs/Materials/material";
  33495. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33496. import { Effect } from "babylonjs/Materials/effect";
  33497. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33498. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33499. import { Light } from "babylonjs/Lights/light";
  33500. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33501. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33502. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33503. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33504. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33505. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33506. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33507. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33508. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33509. import { Engine } from "babylonjs/Engines/engine";
  33510. import { Node } from "babylonjs/node";
  33511. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33512. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33513. import { WebRequest } from "babylonjs/Misc/webRequest";
  33514. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33515. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33517. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33518. import { Plane } from "babylonjs/Maths/math.plane";
  33519. import { Ray } from "babylonjs/Culling/ray";
  33520. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33521. import { Animation } from "babylonjs/Animations/animation";
  33522. import { Animatable } from "babylonjs/Animations/animatable";
  33523. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33524. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33525. import { Collider } from "babylonjs/Collisions/collider";
  33526. /**
  33527. * Define an interface for all classes that will hold resources
  33528. */
  33529. export interface IDisposable {
  33530. /**
  33531. * Releases all held resources
  33532. */
  33533. dispose(): void;
  33534. }
  33535. /** Interface defining initialization parameters for Scene class */
  33536. export interface SceneOptions {
  33537. /**
  33538. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33539. * It will improve performance when the number of geometries becomes important.
  33540. */
  33541. useGeometryUniqueIdsMap?: boolean;
  33542. /**
  33543. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33544. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33545. */
  33546. useMaterialMeshMap?: boolean;
  33547. /**
  33548. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33549. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33550. */
  33551. useClonedMeshhMap?: boolean;
  33552. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33553. virtual?: boolean;
  33554. }
  33555. /**
  33556. * Represents a scene to be rendered by the engine.
  33557. * @see http://doc.babylonjs.com/features/scene
  33558. */
  33559. export class Scene extends AbstractScene implements IAnimatable {
  33560. /** The fog is deactivated */
  33561. static readonly FOGMODE_NONE: number;
  33562. /** The fog density is following an exponential function */
  33563. static readonly FOGMODE_EXP: number;
  33564. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33565. static readonly FOGMODE_EXP2: number;
  33566. /** The fog density is following a linear function. */
  33567. static readonly FOGMODE_LINEAR: number;
  33568. /**
  33569. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33570. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33571. */
  33572. static MinDeltaTime: number;
  33573. /**
  33574. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33575. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33576. */
  33577. static MaxDeltaTime: number;
  33578. /**
  33579. * Factory used to create the default material.
  33580. * @param name The name of the material to create
  33581. * @param scene The scene to create the material for
  33582. * @returns The default material
  33583. */
  33584. static DefaultMaterialFactory(scene: Scene): Material;
  33585. /**
  33586. * Factory used to create the a collision coordinator.
  33587. * @returns The collision coordinator
  33588. */
  33589. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33590. /** @hidden */
  33591. _inputManager: InputManager;
  33592. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33593. cameraToUseForPointers: Nullable<Camera>;
  33594. /** @hidden */
  33595. readonly _isScene: boolean;
  33596. /**
  33597. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33598. */
  33599. autoClear: boolean;
  33600. /**
  33601. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33602. */
  33603. autoClearDepthAndStencil: boolean;
  33604. /**
  33605. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33606. */
  33607. clearColor: Color4;
  33608. /**
  33609. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33610. */
  33611. ambientColor: Color3;
  33612. /**
  33613. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33614. * It should only be one of the following (if not the default embedded one):
  33615. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33616. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33617. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33618. * The material properties need to be setup according to the type of texture in use.
  33619. */
  33620. environmentBRDFTexture: BaseTexture;
  33621. /** @hidden */
  33622. protected _environmentTexture: Nullable<BaseTexture>;
  33623. /**
  33624. * Texture used in all pbr material as the reflection texture.
  33625. * As in the majority of the scene they are the same (exception for multi room and so on),
  33626. * this is easier to reference from here than from all the materials.
  33627. */
  33628. /**
  33629. * Texture used in all pbr material as the reflection texture.
  33630. * As in the majority of the scene they are the same (exception for multi room and so on),
  33631. * this is easier to set here than in all the materials.
  33632. */
  33633. environmentTexture: Nullable<BaseTexture>;
  33634. /** @hidden */
  33635. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33636. /**
  33637. * Default image processing configuration used either in the rendering
  33638. * Forward main pass or through the imageProcessingPostProcess if present.
  33639. * As in the majority of the scene they are the same (exception for multi camera),
  33640. * this is easier to reference from here than from all the materials and post process.
  33641. *
  33642. * No setter as we it is a shared configuration, you can set the values instead.
  33643. */
  33644. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33645. private _forceWireframe;
  33646. /**
  33647. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33648. */
  33649. forceWireframe: boolean;
  33650. private _forcePointsCloud;
  33651. /**
  33652. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33653. */
  33654. forcePointsCloud: boolean;
  33655. /**
  33656. * Gets or sets the active clipplane 1
  33657. */
  33658. clipPlane: Nullable<Plane>;
  33659. /**
  33660. * Gets or sets the active clipplane 2
  33661. */
  33662. clipPlane2: Nullable<Plane>;
  33663. /**
  33664. * Gets or sets the active clipplane 3
  33665. */
  33666. clipPlane3: Nullable<Plane>;
  33667. /**
  33668. * Gets or sets the active clipplane 4
  33669. */
  33670. clipPlane4: Nullable<Plane>;
  33671. /**
  33672. * Gets or sets a boolean indicating if animations are enabled
  33673. */
  33674. animationsEnabled: boolean;
  33675. private _animationPropertiesOverride;
  33676. /**
  33677. * Gets or sets the animation properties override
  33678. */
  33679. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33680. /**
  33681. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33682. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33683. */
  33684. useConstantAnimationDeltaTime: boolean;
  33685. /**
  33686. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33687. * Please note that it requires to run a ray cast through the scene on every frame
  33688. */
  33689. constantlyUpdateMeshUnderPointer: boolean;
  33690. /**
  33691. * Defines the HTML cursor to use when hovering over interactive elements
  33692. */
  33693. hoverCursor: string;
  33694. /**
  33695. * Defines the HTML default cursor to use (empty by default)
  33696. */
  33697. defaultCursor: string;
  33698. /**
  33699. * This is used to call preventDefault() on pointer down
  33700. * in order to block unwanted artifacts like system double clicks
  33701. */
  33702. preventDefaultOnPointerDown: boolean;
  33703. /**
  33704. * This is used to call preventDefault() on pointer up
  33705. * in order to block unwanted artifacts like system double clicks
  33706. */
  33707. preventDefaultOnPointerUp: boolean;
  33708. /**
  33709. * Gets or sets user defined metadata
  33710. */
  33711. metadata: any;
  33712. /**
  33713. * For internal use only. Please do not use.
  33714. */
  33715. reservedDataStore: any;
  33716. /**
  33717. * Gets the name of the plugin used to load this scene (null by default)
  33718. */
  33719. loadingPluginName: string;
  33720. /**
  33721. * Use this array to add regular expressions used to disable offline support for specific urls
  33722. */
  33723. disableOfflineSupportExceptionRules: RegExp[];
  33724. /**
  33725. * An event triggered when the scene is disposed.
  33726. */
  33727. onDisposeObservable: Observable<Scene>;
  33728. private _onDisposeObserver;
  33729. /** Sets a function to be executed when this scene is disposed. */
  33730. onDispose: () => void;
  33731. /**
  33732. * An event triggered before rendering the scene (right after animations and physics)
  33733. */
  33734. onBeforeRenderObservable: Observable<Scene>;
  33735. private _onBeforeRenderObserver;
  33736. /** Sets a function to be executed before rendering this scene */
  33737. beforeRender: Nullable<() => void>;
  33738. /**
  33739. * An event triggered after rendering the scene
  33740. */
  33741. onAfterRenderObservable: Observable<Scene>;
  33742. /**
  33743. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33744. */
  33745. onAfterRenderCameraObservable: Observable<Camera>;
  33746. private _onAfterRenderObserver;
  33747. /** Sets a function to be executed after rendering this scene */
  33748. afterRender: Nullable<() => void>;
  33749. /**
  33750. * An event triggered before animating the scene
  33751. */
  33752. onBeforeAnimationsObservable: Observable<Scene>;
  33753. /**
  33754. * An event triggered after animations processing
  33755. */
  33756. onAfterAnimationsObservable: Observable<Scene>;
  33757. /**
  33758. * An event triggered before draw calls are ready to be sent
  33759. */
  33760. onBeforeDrawPhaseObservable: Observable<Scene>;
  33761. /**
  33762. * An event triggered after draw calls have been sent
  33763. */
  33764. onAfterDrawPhaseObservable: Observable<Scene>;
  33765. /**
  33766. * An event triggered when the scene is ready
  33767. */
  33768. onReadyObservable: Observable<Scene>;
  33769. /**
  33770. * An event triggered before rendering a camera
  33771. */
  33772. onBeforeCameraRenderObservable: Observable<Camera>;
  33773. private _onBeforeCameraRenderObserver;
  33774. /** Sets a function to be executed before rendering a camera*/
  33775. beforeCameraRender: () => void;
  33776. /**
  33777. * An event triggered after rendering a camera
  33778. */
  33779. onAfterCameraRenderObservable: Observable<Camera>;
  33780. private _onAfterCameraRenderObserver;
  33781. /** Sets a function to be executed after rendering a camera*/
  33782. afterCameraRender: () => void;
  33783. /**
  33784. * An event triggered when active meshes evaluation is about to start
  33785. */
  33786. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33787. /**
  33788. * An event triggered when active meshes evaluation is done
  33789. */
  33790. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33791. /**
  33792. * An event triggered when particles rendering is about to start
  33793. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33794. */
  33795. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33796. /**
  33797. * An event triggered when particles rendering is done
  33798. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33799. */
  33800. onAfterParticlesRenderingObservable: Observable<Scene>;
  33801. /**
  33802. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33803. */
  33804. onDataLoadedObservable: Observable<Scene>;
  33805. /**
  33806. * An event triggered when a camera is created
  33807. */
  33808. onNewCameraAddedObservable: Observable<Camera>;
  33809. /**
  33810. * An event triggered when a camera is removed
  33811. */
  33812. onCameraRemovedObservable: Observable<Camera>;
  33813. /**
  33814. * An event triggered when a light is created
  33815. */
  33816. onNewLightAddedObservable: Observable<Light>;
  33817. /**
  33818. * An event triggered when a light is removed
  33819. */
  33820. onLightRemovedObservable: Observable<Light>;
  33821. /**
  33822. * An event triggered when a geometry is created
  33823. */
  33824. onNewGeometryAddedObservable: Observable<Geometry>;
  33825. /**
  33826. * An event triggered when a geometry is removed
  33827. */
  33828. onGeometryRemovedObservable: Observable<Geometry>;
  33829. /**
  33830. * An event triggered when a transform node is created
  33831. */
  33832. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33833. /**
  33834. * An event triggered when a transform node is removed
  33835. */
  33836. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33837. /**
  33838. * An event triggered when a mesh is created
  33839. */
  33840. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33841. /**
  33842. * An event triggered when a mesh is removed
  33843. */
  33844. onMeshRemovedObservable: Observable<AbstractMesh>;
  33845. /**
  33846. * An event triggered when a skeleton is created
  33847. */
  33848. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33849. /**
  33850. * An event triggered when a skeleton is removed
  33851. */
  33852. onSkeletonRemovedObservable: Observable<Skeleton>;
  33853. /**
  33854. * An event triggered when a material is created
  33855. */
  33856. onNewMaterialAddedObservable: Observable<Material>;
  33857. /**
  33858. * An event triggered when a material is removed
  33859. */
  33860. onMaterialRemovedObservable: Observable<Material>;
  33861. /**
  33862. * An event triggered when a texture is created
  33863. */
  33864. onNewTextureAddedObservable: Observable<BaseTexture>;
  33865. /**
  33866. * An event triggered when a texture is removed
  33867. */
  33868. onTextureRemovedObservable: Observable<BaseTexture>;
  33869. /**
  33870. * An event triggered when render targets are about to be rendered
  33871. * Can happen multiple times per frame.
  33872. */
  33873. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33874. /**
  33875. * An event triggered when render targets were rendered.
  33876. * Can happen multiple times per frame.
  33877. */
  33878. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33879. /**
  33880. * An event triggered before calculating deterministic simulation step
  33881. */
  33882. onBeforeStepObservable: Observable<Scene>;
  33883. /**
  33884. * An event triggered after calculating deterministic simulation step
  33885. */
  33886. onAfterStepObservable: Observable<Scene>;
  33887. /**
  33888. * An event triggered when the activeCamera property is updated
  33889. */
  33890. onActiveCameraChanged: Observable<Scene>;
  33891. /**
  33892. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33893. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33894. * 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)
  33895. */
  33896. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33897. /**
  33898. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33899. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33900. * 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)
  33901. */
  33902. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33903. /**
  33904. * This Observable will when a mesh has been imported into the scene.
  33905. */
  33906. onMeshImportedObservable: Observable<AbstractMesh>;
  33907. /**
  33908. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33909. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33910. */
  33911. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33912. /** @hidden */
  33913. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33914. /**
  33915. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33916. */
  33917. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33918. /**
  33919. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33920. */
  33921. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33922. /**
  33923. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33924. */
  33925. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33926. /** Callback called when a pointer move is detected */
  33927. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33928. /** Callback called when a pointer down is detected */
  33929. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33930. /** Callback called when a pointer up is detected */
  33931. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33932. /** Callback called when a pointer pick is detected */
  33933. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33934. /**
  33935. * 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).
  33936. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33937. */
  33938. onPrePointerObservable: Observable<PointerInfoPre>;
  33939. /**
  33940. * Observable event triggered each time an input event is received from the rendering canvas
  33941. */
  33942. onPointerObservable: Observable<PointerInfo>;
  33943. /**
  33944. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33945. */
  33946. readonly unTranslatedPointer: Vector2;
  33947. /**
  33948. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33949. */
  33950. static DragMovementThreshold: number;
  33951. /**
  33952. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33953. */
  33954. static LongPressDelay: number;
  33955. /**
  33956. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33957. */
  33958. static DoubleClickDelay: number;
  33959. /** If you need to check double click without raising a single click at first click, enable this flag */
  33960. static ExclusiveDoubleClickMode: boolean;
  33961. /** @hidden */
  33962. _mirroredCameraPosition: Nullable<Vector3>;
  33963. /**
  33964. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33965. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33966. */
  33967. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33968. /**
  33969. * Observable event triggered each time an keyboard event is received from the hosting window
  33970. */
  33971. onKeyboardObservable: Observable<KeyboardInfo>;
  33972. private _useRightHandedSystem;
  33973. /**
  33974. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33975. */
  33976. useRightHandedSystem: boolean;
  33977. private _timeAccumulator;
  33978. private _currentStepId;
  33979. private _currentInternalStep;
  33980. /**
  33981. * Sets the step Id used by deterministic lock step
  33982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33983. * @param newStepId defines the step Id
  33984. */
  33985. setStepId(newStepId: number): void;
  33986. /**
  33987. * Gets the step Id used by deterministic lock step
  33988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33989. * @returns the step Id
  33990. */
  33991. getStepId(): number;
  33992. /**
  33993. * Gets the internal step used by deterministic lock step
  33994. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33995. * @returns the internal step
  33996. */
  33997. getInternalStep(): number;
  33998. private _fogEnabled;
  33999. /**
  34000. * Gets or sets a boolean indicating if fog is enabled on this scene
  34001. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34002. * (Default is true)
  34003. */
  34004. fogEnabled: boolean;
  34005. private _fogMode;
  34006. /**
  34007. * Gets or sets the fog mode to use
  34008. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34009. * | mode | value |
  34010. * | --- | --- |
  34011. * | FOGMODE_NONE | 0 |
  34012. * | FOGMODE_EXP | 1 |
  34013. * | FOGMODE_EXP2 | 2 |
  34014. * | FOGMODE_LINEAR | 3 |
  34015. */
  34016. fogMode: number;
  34017. /**
  34018. * Gets or sets the fog color to use
  34019. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34020. * (Default is Color3(0.2, 0.2, 0.3))
  34021. */
  34022. fogColor: Color3;
  34023. /**
  34024. * Gets or sets the fog density to use
  34025. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34026. * (Default is 0.1)
  34027. */
  34028. fogDensity: number;
  34029. /**
  34030. * Gets or sets the fog start distance to use
  34031. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34032. * (Default is 0)
  34033. */
  34034. fogStart: number;
  34035. /**
  34036. * Gets or sets the fog end distance to use
  34037. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34038. * (Default is 1000)
  34039. */
  34040. fogEnd: number;
  34041. private _shadowsEnabled;
  34042. /**
  34043. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34044. */
  34045. shadowsEnabled: boolean;
  34046. private _lightsEnabled;
  34047. /**
  34048. * Gets or sets a boolean indicating if lights are enabled on this scene
  34049. */
  34050. lightsEnabled: boolean;
  34051. /** All of the active cameras added to this scene. */
  34052. activeCameras: Camera[];
  34053. /** @hidden */
  34054. _activeCamera: Nullable<Camera>;
  34055. /** Gets or sets the current active camera */
  34056. activeCamera: Nullable<Camera>;
  34057. private _defaultMaterial;
  34058. /** The default material used on meshes when no material is affected */
  34059. /** The default material used on meshes when no material is affected */
  34060. defaultMaterial: Material;
  34061. private _texturesEnabled;
  34062. /**
  34063. * Gets or sets a boolean indicating if textures are enabled on this scene
  34064. */
  34065. texturesEnabled: boolean;
  34066. /**
  34067. * Gets or sets a boolean indicating if particles are enabled on this scene
  34068. */
  34069. particlesEnabled: boolean;
  34070. /**
  34071. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34072. */
  34073. spritesEnabled: boolean;
  34074. private _skeletonsEnabled;
  34075. /**
  34076. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34077. */
  34078. skeletonsEnabled: boolean;
  34079. /**
  34080. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34081. */
  34082. lensFlaresEnabled: boolean;
  34083. /**
  34084. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34086. */
  34087. collisionsEnabled: boolean;
  34088. private _collisionCoordinator;
  34089. /** @hidden */
  34090. readonly collisionCoordinator: ICollisionCoordinator;
  34091. /**
  34092. * Defines the gravity applied to this scene (used only for collisions)
  34093. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34094. */
  34095. gravity: Vector3;
  34096. /**
  34097. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34098. */
  34099. postProcessesEnabled: boolean;
  34100. /**
  34101. * The list of postprocesses added to the scene
  34102. */
  34103. postProcesses: PostProcess[];
  34104. /**
  34105. * Gets the current postprocess manager
  34106. */
  34107. postProcessManager: PostProcessManager;
  34108. /**
  34109. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34110. */
  34111. renderTargetsEnabled: boolean;
  34112. /**
  34113. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34114. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34115. */
  34116. dumpNextRenderTargets: boolean;
  34117. /**
  34118. * The list of user defined render targets added to the scene
  34119. */
  34120. customRenderTargets: RenderTargetTexture[];
  34121. /**
  34122. * Defines if texture loading must be delayed
  34123. * If true, textures will only be loaded when they need to be rendered
  34124. */
  34125. useDelayedTextureLoading: boolean;
  34126. /**
  34127. * Gets the list of meshes imported to the scene through SceneLoader
  34128. */
  34129. importedMeshesFiles: String[];
  34130. /**
  34131. * Gets or sets a boolean indicating if probes are enabled on this scene
  34132. */
  34133. probesEnabled: boolean;
  34134. /**
  34135. * Gets or sets the current offline provider to use to store scene data
  34136. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34137. */
  34138. offlineProvider: IOfflineProvider;
  34139. /**
  34140. * Gets or sets the action manager associated with the scene
  34141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34142. */
  34143. actionManager: AbstractActionManager;
  34144. private _meshesForIntersections;
  34145. /**
  34146. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34147. */
  34148. proceduralTexturesEnabled: boolean;
  34149. private _engine;
  34150. private _totalVertices;
  34151. /** @hidden */
  34152. _activeIndices: PerfCounter;
  34153. /** @hidden */
  34154. _activeParticles: PerfCounter;
  34155. /** @hidden */
  34156. _activeBones: PerfCounter;
  34157. private _animationRatio;
  34158. /** @hidden */
  34159. _animationTimeLast: number;
  34160. /** @hidden */
  34161. _animationTime: number;
  34162. /**
  34163. * Gets or sets a general scale for animation speed
  34164. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34165. */
  34166. animationTimeScale: number;
  34167. /** @hidden */
  34168. _cachedMaterial: Nullable<Material>;
  34169. /** @hidden */
  34170. _cachedEffect: Nullable<Effect>;
  34171. /** @hidden */
  34172. _cachedVisibility: Nullable<number>;
  34173. private _renderId;
  34174. private _frameId;
  34175. private _executeWhenReadyTimeoutId;
  34176. private _intermediateRendering;
  34177. private _viewUpdateFlag;
  34178. private _projectionUpdateFlag;
  34179. /** @hidden */
  34180. _toBeDisposed: Nullable<IDisposable>[];
  34181. private _activeRequests;
  34182. /** @hidden */
  34183. _pendingData: any[];
  34184. private _isDisposed;
  34185. /**
  34186. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34187. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34188. */
  34189. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34190. private _activeMeshes;
  34191. private _processedMaterials;
  34192. private _renderTargets;
  34193. /** @hidden */
  34194. _activeParticleSystems: SmartArray<IParticleSystem>;
  34195. private _activeSkeletons;
  34196. private _softwareSkinnedMeshes;
  34197. private _renderingManager;
  34198. /** @hidden */
  34199. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34200. private _transformMatrix;
  34201. private _sceneUbo;
  34202. /** @hidden */
  34203. _viewMatrix: Matrix;
  34204. private _projectionMatrix;
  34205. /** @hidden */
  34206. _forcedViewPosition: Nullable<Vector3>;
  34207. /** @hidden */
  34208. _frustumPlanes: Plane[];
  34209. /**
  34210. * Gets the list of frustum planes (built from the active camera)
  34211. */
  34212. readonly frustumPlanes: Plane[];
  34213. /**
  34214. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34215. * This is useful if there are more lights that the maximum simulteanous authorized
  34216. */
  34217. requireLightSorting: boolean;
  34218. /** @hidden */
  34219. readonly useMaterialMeshMap: boolean;
  34220. /** @hidden */
  34221. readonly useClonedMeshhMap: boolean;
  34222. private _externalData;
  34223. private _uid;
  34224. /**
  34225. * @hidden
  34226. * Backing store of defined scene components.
  34227. */
  34228. _components: ISceneComponent[];
  34229. /**
  34230. * @hidden
  34231. * Backing store of defined scene components.
  34232. */
  34233. _serializableComponents: ISceneSerializableComponent[];
  34234. /**
  34235. * List of components to register on the next registration step.
  34236. */
  34237. private _transientComponents;
  34238. /**
  34239. * Registers the transient components if needed.
  34240. */
  34241. private _registerTransientComponents;
  34242. /**
  34243. * @hidden
  34244. * Add a component to the scene.
  34245. * Note that the ccomponent could be registered on th next frame if this is called after
  34246. * the register component stage.
  34247. * @param component Defines the component to add to the scene
  34248. */
  34249. _addComponent(component: ISceneComponent): void;
  34250. /**
  34251. * @hidden
  34252. * Gets a component from the scene.
  34253. * @param name defines the name of the component to retrieve
  34254. * @returns the component or null if not present
  34255. */
  34256. _getComponent(name: string): Nullable<ISceneComponent>;
  34257. /**
  34258. * @hidden
  34259. * Defines the actions happening before camera updates.
  34260. */
  34261. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34262. /**
  34263. * @hidden
  34264. * Defines the actions happening before clear the canvas.
  34265. */
  34266. _beforeClearStage: Stage<SimpleStageAction>;
  34267. /**
  34268. * @hidden
  34269. * Defines the actions when collecting render targets for the frame.
  34270. */
  34271. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34272. /**
  34273. * @hidden
  34274. * Defines the actions happening for one camera in the frame.
  34275. */
  34276. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34277. /**
  34278. * @hidden
  34279. * Defines the actions happening during the per mesh ready checks.
  34280. */
  34281. _isReadyForMeshStage: Stage<MeshStageAction>;
  34282. /**
  34283. * @hidden
  34284. * Defines the actions happening before evaluate active mesh checks.
  34285. */
  34286. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34287. /**
  34288. * @hidden
  34289. * Defines the actions happening during the evaluate sub mesh checks.
  34290. */
  34291. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34292. /**
  34293. * @hidden
  34294. * Defines the actions happening during the active mesh stage.
  34295. */
  34296. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34297. /**
  34298. * @hidden
  34299. * Defines the actions happening during the per camera render target step.
  34300. */
  34301. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34302. /**
  34303. * @hidden
  34304. * Defines the actions happening just before the active camera is drawing.
  34305. */
  34306. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34307. /**
  34308. * @hidden
  34309. * Defines the actions happening just before a render target is drawing.
  34310. */
  34311. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34312. /**
  34313. * @hidden
  34314. * Defines the actions happening just before a rendering group is drawing.
  34315. */
  34316. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34317. /**
  34318. * @hidden
  34319. * Defines the actions happening just before a mesh is drawing.
  34320. */
  34321. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34322. /**
  34323. * @hidden
  34324. * Defines the actions happening just after a mesh has been drawn.
  34325. */
  34326. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34327. /**
  34328. * @hidden
  34329. * Defines the actions happening just after a rendering group has been drawn.
  34330. */
  34331. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34332. /**
  34333. * @hidden
  34334. * Defines the actions happening just after the active camera has been drawn.
  34335. */
  34336. _afterCameraDrawStage: Stage<CameraStageAction>;
  34337. /**
  34338. * @hidden
  34339. * Defines the actions happening just after a render target has been drawn.
  34340. */
  34341. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34342. /**
  34343. * @hidden
  34344. * Defines the actions happening just after rendering all cameras and computing intersections.
  34345. */
  34346. _afterRenderStage: Stage<SimpleStageAction>;
  34347. /**
  34348. * @hidden
  34349. * Defines the actions happening when a pointer move event happens.
  34350. */
  34351. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34352. /**
  34353. * @hidden
  34354. * Defines the actions happening when a pointer down event happens.
  34355. */
  34356. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34357. /**
  34358. * @hidden
  34359. * Defines the actions happening when a pointer up event happens.
  34360. */
  34361. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34362. /**
  34363. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34364. */
  34365. private geometriesByUniqueId;
  34366. /**
  34367. * Creates a new Scene
  34368. * @param engine defines the engine to use to render this scene
  34369. * @param options defines the scene options
  34370. */
  34371. constructor(engine: Engine, options?: SceneOptions);
  34372. /**
  34373. * Gets a string idenfifying the name of the class
  34374. * @returns "Scene" string
  34375. */
  34376. getClassName(): string;
  34377. private _defaultMeshCandidates;
  34378. /**
  34379. * @hidden
  34380. */
  34381. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34382. private _defaultSubMeshCandidates;
  34383. /**
  34384. * @hidden
  34385. */
  34386. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34387. /**
  34388. * Sets the default candidate providers for the scene.
  34389. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34390. * and getCollidingSubMeshCandidates to their default function
  34391. */
  34392. setDefaultCandidateProviders(): void;
  34393. /**
  34394. * Gets the mesh that is currently under the pointer
  34395. */
  34396. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34397. /**
  34398. * Gets or sets the current on-screen X position of the pointer
  34399. */
  34400. pointerX: number;
  34401. /**
  34402. * Gets or sets the current on-screen Y position of the pointer
  34403. */
  34404. pointerY: number;
  34405. /**
  34406. * Gets the cached material (ie. the latest rendered one)
  34407. * @returns the cached material
  34408. */
  34409. getCachedMaterial(): Nullable<Material>;
  34410. /**
  34411. * Gets the cached effect (ie. the latest rendered one)
  34412. * @returns the cached effect
  34413. */
  34414. getCachedEffect(): Nullable<Effect>;
  34415. /**
  34416. * Gets the cached visibility state (ie. the latest rendered one)
  34417. * @returns the cached visibility state
  34418. */
  34419. getCachedVisibility(): Nullable<number>;
  34420. /**
  34421. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34422. * @param material defines the current material
  34423. * @param effect defines the current effect
  34424. * @param visibility defines the current visibility state
  34425. * @returns true if one parameter is not cached
  34426. */
  34427. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34428. /**
  34429. * Gets the engine associated with the scene
  34430. * @returns an Engine
  34431. */
  34432. getEngine(): Engine;
  34433. /**
  34434. * Gets the total number of vertices rendered per frame
  34435. * @returns the total number of vertices rendered per frame
  34436. */
  34437. getTotalVertices(): number;
  34438. /**
  34439. * Gets the performance counter for total vertices
  34440. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34441. */
  34442. readonly totalVerticesPerfCounter: PerfCounter;
  34443. /**
  34444. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34445. * @returns the total number of active indices rendered per frame
  34446. */
  34447. getActiveIndices(): number;
  34448. /**
  34449. * Gets the performance counter for active indices
  34450. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34451. */
  34452. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34453. /**
  34454. * Gets the total number of active particles rendered per frame
  34455. * @returns the total number of active particles rendered per frame
  34456. */
  34457. getActiveParticles(): number;
  34458. /**
  34459. * Gets the performance counter for active particles
  34460. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34461. */
  34462. readonly activeParticlesPerfCounter: PerfCounter;
  34463. /**
  34464. * Gets the total number of active bones rendered per frame
  34465. * @returns the total number of active bones rendered per frame
  34466. */
  34467. getActiveBones(): number;
  34468. /**
  34469. * Gets the performance counter for active bones
  34470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34471. */
  34472. readonly activeBonesPerfCounter: PerfCounter;
  34473. /**
  34474. * Gets the array of active meshes
  34475. * @returns an array of AbstractMesh
  34476. */
  34477. getActiveMeshes(): SmartArray<AbstractMesh>;
  34478. /**
  34479. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34480. * @returns a number
  34481. */
  34482. getAnimationRatio(): number;
  34483. /**
  34484. * Gets an unique Id for the current render phase
  34485. * @returns a number
  34486. */
  34487. getRenderId(): number;
  34488. /**
  34489. * Gets an unique Id for the current frame
  34490. * @returns a number
  34491. */
  34492. getFrameId(): number;
  34493. /** Call this function if you want to manually increment the render Id*/
  34494. incrementRenderId(): void;
  34495. private _createUbo;
  34496. /**
  34497. * Use this method to simulate a pointer move on a mesh
  34498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34501. * @returns the current scene
  34502. */
  34503. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34504. /**
  34505. * Use this method to simulate a pointer down on a mesh
  34506. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34507. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34508. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34509. * @returns the current scene
  34510. */
  34511. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34512. /**
  34513. * Use this method to simulate a pointer up on a mesh
  34514. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34515. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34516. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34517. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34518. * @returns the current scene
  34519. */
  34520. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34521. /**
  34522. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34523. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34524. * @returns true if the pointer was captured
  34525. */
  34526. isPointerCaptured(pointerId?: number): boolean;
  34527. /**
  34528. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34529. * @param attachUp defines if you want to attach events to pointerup
  34530. * @param attachDown defines if you want to attach events to pointerdown
  34531. * @param attachMove defines if you want to attach events to pointermove
  34532. */
  34533. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34534. /** Detaches all event handlers*/
  34535. detachControl(): void;
  34536. /**
  34537. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34538. * Delay loaded resources are not taking in account
  34539. * @return true if all required resources are ready
  34540. */
  34541. isReady(): boolean;
  34542. /** Resets all cached information relative to material (including effect and visibility) */
  34543. resetCachedMaterial(): void;
  34544. /**
  34545. * Registers a function to be called before every frame render
  34546. * @param func defines the function to register
  34547. */
  34548. registerBeforeRender(func: () => void): void;
  34549. /**
  34550. * Unregisters a function called before every frame render
  34551. * @param func defines the function to unregister
  34552. */
  34553. unregisterBeforeRender(func: () => void): void;
  34554. /**
  34555. * Registers a function to be called after every frame render
  34556. * @param func defines the function to register
  34557. */
  34558. registerAfterRender(func: () => void): void;
  34559. /**
  34560. * Unregisters a function called after every frame render
  34561. * @param func defines the function to unregister
  34562. */
  34563. unregisterAfterRender(func: () => void): void;
  34564. private _executeOnceBeforeRender;
  34565. /**
  34566. * The provided function will run before render once and will be disposed afterwards.
  34567. * A timeout delay can be provided so that the function will be executed in N ms.
  34568. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34569. * @param func The function to be executed.
  34570. * @param timeout optional delay in ms
  34571. */
  34572. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34573. /** @hidden */
  34574. _addPendingData(data: any): void;
  34575. /** @hidden */
  34576. _removePendingData(data: any): void;
  34577. /**
  34578. * Returns the number of items waiting to be loaded
  34579. * @returns the number of items waiting to be loaded
  34580. */
  34581. getWaitingItemsCount(): number;
  34582. /**
  34583. * Returns a boolean indicating if the scene is still loading data
  34584. */
  34585. readonly isLoading: boolean;
  34586. /**
  34587. * Registers a function to be executed when the scene is ready
  34588. * @param {Function} func - the function to be executed
  34589. */
  34590. executeWhenReady(func: () => void): void;
  34591. /**
  34592. * Returns a promise that resolves when the scene is ready
  34593. * @returns A promise that resolves when the scene is ready
  34594. */
  34595. whenReadyAsync(): Promise<void>;
  34596. /** @hidden */
  34597. _checkIsReady(): void;
  34598. /**
  34599. * Gets all animatable attached to the scene
  34600. */
  34601. readonly animatables: Animatable[];
  34602. /**
  34603. * Resets the last animation time frame.
  34604. * Useful to override when animations start running when loading a scene for the first time.
  34605. */
  34606. resetLastAnimationTimeFrame(): void;
  34607. /**
  34608. * Gets the current view matrix
  34609. * @returns a Matrix
  34610. */
  34611. getViewMatrix(): Matrix;
  34612. /**
  34613. * Gets the current projection matrix
  34614. * @returns a Matrix
  34615. */
  34616. getProjectionMatrix(): Matrix;
  34617. /**
  34618. * Gets the current transform matrix
  34619. * @returns a Matrix made of View * Projection
  34620. */
  34621. getTransformMatrix(): Matrix;
  34622. /**
  34623. * Sets the current transform matrix
  34624. * @param viewL defines the View matrix to use
  34625. * @param projectionL defines the Projection matrix to use
  34626. * @param viewR defines the right View matrix to use (if provided)
  34627. * @param projectionR defines the right Projection matrix to use (if provided)
  34628. */
  34629. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34630. /**
  34631. * Gets the uniform buffer used to store scene data
  34632. * @returns a UniformBuffer
  34633. */
  34634. getSceneUniformBuffer(): UniformBuffer;
  34635. /**
  34636. * Gets an unique (relatively to the current scene) Id
  34637. * @returns an unique number for the scene
  34638. */
  34639. getUniqueId(): number;
  34640. /**
  34641. * Add a mesh to the list of scene's meshes
  34642. * @param newMesh defines the mesh to add
  34643. * @param recursive if all child meshes should also be added to the scene
  34644. */
  34645. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34646. /**
  34647. * Remove a mesh for the list of scene's meshes
  34648. * @param toRemove defines the mesh to remove
  34649. * @param recursive if all child meshes should also be removed from the scene
  34650. * @returns the index where the mesh was in the mesh list
  34651. */
  34652. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34653. /**
  34654. * Add a transform node to the list of scene's transform nodes
  34655. * @param newTransformNode defines the transform node to add
  34656. */
  34657. addTransformNode(newTransformNode: TransformNode): void;
  34658. /**
  34659. * Remove a transform node for the list of scene's transform nodes
  34660. * @param toRemove defines the transform node to remove
  34661. * @returns the index where the transform node was in the transform node list
  34662. */
  34663. removeTransformNode(toRemove: TransformNode): number;
  34664. /**
  34665. * Remove a skeleton for the list of scene's skeletons
  34666. * @param toRemove defines the skeleton to remove
  34667. * @returns the index where the skeleton was in the skeleton list
  34668. */
  34669. removeSkeleton(toRemove: Skeleton): number;
  34670. /**
  34671. * Remove a morph target for the list of scene's morph targets
  34672. * @param toRemove defines the morph target to remove
  34673. * @returns the index where the morph target was in the morph target list
  34674. */
  34675. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34676. /**
  34677. * Remove a light for the list of scene's lights
  34678. * @param toRemove defines the light to remove
  34679. * @returns the index where the light was in the light list
  34680. */
  34681. removeLight(toRemove: Light): number;
  34682. /**
  34683. * Remove a camera for the list of scene's cameras
  34684. * @param toRemove defines the camera to remove
  34685. * @returns the index where the camera was in the camera list
  34686. */
  34687. removeCamera(toRemove: Camera): number;
  34688. /**
  34689. * Remove a particle system for the list of scene's particle systems
  34690. * @param toRemove defines the particle system to remove
  34691. * @returns the index where the particle system was in the particle system list
  34692. */
  34693. removeParticleSystem(toRemove: IParticleSystem): number;
  34694. /**
  34695. * Remove a animation for the list of scene's animations
  34696. * @param toRemove defines the animation to remove
  34697. * @returns the index where the animation was in the animation list
  34698. */
  34699. removeAnimation(toRemove: Animation): number;
  34700. /**
  34701. * Will stop the animation of the given target
  34702. * @param target - the target
  34703. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34704. * @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)
  34705. */
  34706. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34707. /**
  34708. * Removes the given animation group from this scene.
  34709. * @param toRemove The animation group to remove
  34710. * @returns The index of the removed animation group
  34711. */
  34712. removeAnimationGroup(toRemove: AnimationGroup): number;
  34713. /**
  34714. * Removes the given multi-material from this scene.
  34715. * @param toRemove The multi-material to remove
  34716. * @returns The index of the removed multi-material
  34717. */
  34718. removeMultiMaterial(toRemove: MultiMaterial): number;
  34719. /**
  34720. * Removes the given material from this scene.
  34721. * @param toRemove The material to remove
  34722. * @returns The index of the removed material
  34723. */
  34724. removeMaterial(toRemove: Material): number;
  34725. /**
  34726. * Removes the given action manager from this scene.
  34727. * @param toRemove The action manager to remove
  34728. * @returns The index of the removed action manager
  34729. */
  34730. removeActionManager(toRemove: AbstractActionManager): number;
  34731. /**
  34732. * Removes the given texture from this scene.
  34733. * @param toRemove The texture to remove
  34734. * @returns The index of the removed texture
  34735. */
  34736. removeTexture(toRemove: BaseTexture): number;
  34737. /**
  34738. * Adds the given light to this scene
  34739. * @param newLight The light to add
  34740. */
  34741. addLight(newLight: Light): void;
  34742. /**
  34743. * Sorts the list list based on light priorities
  34744. */
  34745. sortLightsByPriority(): void;
  34746. /**
  34747. * Adds the given camera to this scene
  34748. * @param newCamera The camera to add
  34749. */
  34750. addCamera(newCamera: Camera): void;
  34751. /**
  34752. * Adds the given skeleton to this scene
  34753. * @param newSkeleton The skeleton to add
  34754. */
  34755. addSkeleton(newSkeleton: Skeleton): void;
  34756. /**
  34757. * Adds the given particle system to this scene
  34758. * @param newParticleSystem The particle system to add
  34759. */
  34760. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34761. /**
  34762. * Adds the given animation to this scene
  34763. * @param newAnimation The animation to add
  34764. */
  34765. addAnimation(newAnimation: Animation): void;
  34766. /**
  34767. * Adds the given animation group to this scene.
  34768. * @param newAnimationGroup The animation group to add
  34769. */
  34770. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34771. /**
  34772. * Adds the given multi-material to this scene
  34773. * @param newMultiMaterial The multi-material to add
  34774. */
  34775. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34776. /**
  34777. * Adds the given material to this scene
  34778. * @param newMaterial The material to add
  34779. */
  34780. addMaterial(newMaterial: Material): void;
  34781. /**
  34782. * Adds the given morph target to this scene
  34783. * @param newMorphTargetManager The morph target to add
  34784. */
  34785. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34786. /**
  34787. * Adds the given geometry to this scene
  34788. * @param newGeometry The geometry to add
  34789. */
  34790. addGeometry(newGeometry: Geometry): void;
  34791. /**
  34792. * Adds the given action manager to this scene
  34793. * @param newActionManager The action manager to add
  34794. */
  34795. addActionManager(newActionManager: AbstractActionManager): void;
  34796. /**
  34797. * Adds the given texture to this scene.
  34798. * @param newTexture The texture to add
  34799. */
  34800. addTexture(newTexture: BaseTexture): void;
  34801. /**
  34802. * Switch active camera
  34803. * @param newCamera defines the new active camera
  34804. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34805. */
  34806. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34807. /**
  34808. * sets the active camera of the scene using its ID
  34809. * @param id defines the camera's ID
  34810. * @return the new active camera or null if none found.
  34811. */
  34812. setActiveCameraByID(id: string): Nullable<Camera>;
  34813. /**
  34814. * sets the active camera of the scene using its name
  34815. * @param name defines the camera's name
  34816. * @returns the new active camera or null if none found.
  34817. */
  34818. setActiveCameraByName(name: string): Nullable<Camera>;
  34819. /**
  34820. * get an animation group using its name
  34821. * @param name defines the material's name
  34822. * @return the animation group or null if none found.
  34823. */
  34824. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34825. /**
  34826. * Get a material using its unique id
  34827. * @param uniqueId defines the material's unique id
  34828. * @return the material or null if none found.
  34829. */
  34830. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34831. /**
  34832. * get a material using its id
  34833. * @param id defines the material's ID
  34834. * @return the material or null if none found.
  34835. */
  34836. getMaterialByID(id: string): Nullable<Material>;
  34837. /**
  34838. * Gets a the last added material using a given id
  34839. * @param id defines the material's ID
  34840. * @return the last material with the given id or null if none found.
  34841. */
  34842. getLastMaterialByID(id: string): Nullable<Material>;
  34843. /**
  34844. * Gets a material using its name
  34845. * @param name defines the material's name
  34846. * @return the material or null if none found.
  34847. */
  34848. getMaterialByName(name: string): Nullable<Material>;
  34849. /**
  34850. * Get a texture using its unique id
  34851. * @param uniqueId defines the texture's unique id
  34852. * @return the texture or null if none found.
  34853. */
  34854. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34855. /**
  34856. * Gets a camera using its id
  34857. * @param id defines the id to look for
  34858. * @returns the camera or null if not found
  34859. */
  34860. getCameraByID(id: string): Nullable<Camera>;
  34861. /**
  34862. * Gets a camera using its unique id
  34863. * @param uniqueId defines the unique id to look for
  34864. * @returns the camera or null if not found
  34865. */
  34866. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34867. /**
  34868. * Gets a camera using its name
  34869. * @param name defines the camera's name
  34870. * @return the camera or null if none found.
  34871. */
  34872. getCameraByName(name: string): Nullable<Camera>;
  34873. /**
  34874. * Gets a bone using its id
  34875. * @param id defines the bone's id
  34876. * @return the bone or null if not found
  34877. */
  34878. getBoneByID(id: string): Nullable<Bone>;
  34879. /**
  34880. * Gets a bone using its id
  34881. * @param name defines the bone's name
  34882. * @return the bone or null if not found
  34883. */
  34884. getBoneByName(name: string): Nullable<Bone>;
  34885. /**
  34886. * Gets a light node using its name
  34887. * @param name defines the the light's name
  34888. * @return the light or null if none found.
  34889. */
  34890. getLightByName(name: string): Nullable<Light>;
  34891. /**
  34892. * Gets a light node using its id
  34893. * @param id defines the light's id
  34894. * @return the light or null if none found.
  34895. */
  34896. getLightByID(id: string): Nullable<Light>;
  34897. /**
  34898. * Gets a light node using its scene-generated unique ID
  34899. * @param uniqueId defines the light's unique id
  34900. * @return the light or null if none found.
  34901. */
  34902. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34903. /**
  34904. * Gets a particle system by id
  34905. * @param id defines the particle system id
  34906. * @return the corresponding system or null if none found
  34907. */
  34908. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34909. /**
  34910. * Gets a geometry using its ID
  34911. * @param id defines the geometry's id
  34912. * @return the geometry or null if none found.
  34913. */
  34914. getGeometryByID(id: string): Nullable<Geometry>;
  34915. private _getGeometryByUniqueID;
  34916. /**
  34917. * Add a new geometry to this scene
  34918. * @param geometry defines the geometry to be added to the scene.
  34919. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34920. * @return a boolean defining if the geometry was added or not
  34921. */
  34922. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34923. /**
  34924. * Removes an existing geometry
  34925. * @param geometry defines the geometry to be removed from the scene
  34926. * @return a boolean defining if the geometry was removed or not
  34927. */
  34928. removeGeometry(geometry: Geometry): boolean;
  34929. /**
  34930. * Gets the list of geometries attached to the scene
  34931. * @returns an array of Geometry
  34932. */
  34933. getGeometries(): Geometry[];
  34934. /**
  34935. * Gets the first added mesh found of a given ID
  34936. * @param id defines the id to search for
  34937. * @return the mesh found or null if not found at all
  34938. */
  34939. getMeshByID(id: string): Nullable<AbstractMesh>;
  34940. /**
  34941. * Gets a list of meshes using their id
  34942. * @param id defines the id to search for
  34943. * @returns a list of meshes
  34944. */
  34945. getMeshesByID(id: string): Array<AbstractMesh>;
  34946. /**
  34947. * Gets the first added transform node found of a given ID
  34948. * @param id defines the id to search for
  34949. * @return the found transform node or null if not found at all.
  34950. */
  34951. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34952. /**
  34953. * Gets a transform node with its auto-generated unique id
  34954. * @param uniqueId efines the unique id to search for
  34955. * @return the found transform node or null if not found at all.
  34956. */
  34957. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34958. /**
  34959. * Gets a list of transform nodes using their id
  34960. * @param id defines the id to search for
  34961. * @returns a list of transform nodes
  34962. */
  34963. getTransformNodesByID(id: string): Array<TransformNode>;
  34964. /**
  34965. * Gets a mesh with its auto-generated unique id
  34966. * @param uniqueId defines the unique id to search for
  34967. * @return the found mesh or null if not found at all.
  34968. */
  34969. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34970. /**
  34971. * Gets a the last added mesh using a given id
  34972. * @param id defines the id to search for
  34973. * @return the found mesh or null if not found at all.
  34974. */
  34975. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34976. /**
  34977. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34978. * @param id defines the id to search for
  34979. * @return the found node or null if not found at all
  34980. */
  34981. getLastEntryByID(id: string): Nullable<Node>;
  34982. /**
  34983. * Gets a node (Mesh, Camera, Light) using a given id
  34984. * @param id defines the id to search for
  34985. * @return the found node or null if not found at all
  34986. */
  34987. getNodeByID(id: string): Nullable<Node>;
  34988. /**
  34989. * Gets a node (Mesh, Camera, Light) using a given name
  34990. * @param name defines the name to search for
  34991. * @return the found node or null if not found at all.
  34992. */
  34993. getNodeByName(name: string): Nullable<Node>;
  34994. /**
  34995. * Gets a mesh using a given name
  34996. * @param name defines the name to search for
  34997. * @return the found mesh or null if not found at all.
  34998. */
  34999. getMeshByName(name: string): Nullable<AbstractMesh>;
  35000. /**
  35001. * Gets a transform node using a given name
  35002. * @param name defines the name to search for
  35003. * @return the found transform node or null if not found at all.
  35004. */
  35005. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35006. /**
  35007. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35008. * @param id defines the id to search for
  35009. * @return the found skeleton or null if not found at all.
  35010. */
  35011. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35012. /**
  35013. * Gets a skeleton using a given auto generated unique id
  35014. * @param uniqueId defines the unique id to search for
  35015. * @return the found skeleton or null if not found at all.
  35016. */
  35017. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35018. /**
  35019. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35020. * @param id defines the id to search for
  35021. * @return the found skeleton or null if not found at all.
  35022. */
  35023. getSkeletonById(id: string): Nullable<Skeleton>;
  35024. /**
  35025. * Gets a skeleton using a given name
  35026. * @param name defines the name to search for
  35027. * @return the found skeleton or null if not found at all.
  35028. */
  35029. getSkeletonByName(name: string): Nullable<Skeleton>;
  35030. /**
  35031. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35032. * @param id defines the id to search for
  35033. * @return the found morph target manager or null if not found at all.
  35034. */
  35035. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35036. /**
  35037. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35038. * @param id defines the id to search for
  35039. * @return the found morph target or null if not found at all.
  35040. */
  35041. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35042. /**
  35043. * Gets a boolean indicating if the given mesh is active
  35044. * @param mesh defines the mesh to look for
  35045. * @returns true if the mesh is in the active list
  35046. */
  35047. isActiveMesh(mesh: AbstractMesh): boolean;
  35048. /**
  35049. * Return a unique id as a string which can serve as an identifier for the scene
  35050. */
  35051. readonly uid: string;
  35052. /**
  35053. * Add an externaly attached data from its key.
  35054. * This method call will fail and return false, if such key already exists.
  35055. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35056. * @param key the unique key that identifies the data
  35057. * @param data the data object to associate to the key for this Engine instance
  35058. * @return true if no such key were already present and the data was added successfully, false otherwise
  35059. */
  35060. addExternalData<T>(key: string, data: T): boolean;
  35061. /**
  35062. * Get an externaly attached data from its key
  35063. * @param key the unique key that identifies the data
  35064. * @return the associated data, if present (can be null), or undefined if not present
  35065. */
  35066. getExternalData<T>(key: string): Nullable<T>;
  35067. /**
  35068. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35069. * @param key the unique key that identifies the data
  35070. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35071. * @return the associated data, can be null if the factory returned null.
  35072. */
  35073. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35074. /**
  35075. * Remove an externaly attached data from the Engine instance
  35076. * @param key the unique key that identifies the data
  35077. * @return true if the data was successfully removed, false if it doesn't exist
  35078. */
  35079. removeExternalData(key: string): boolean;
  35080. private _evaluateSubMesh;
  35081. /**
  35082. * Clear the processed materials smart array preventing retention point in material dispose.
  35083. */
  35084. freeProcessedMaterials(): void;
  35085. private _preventFreeActiveMeshesAndRenderingGroups;
  35086. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35087. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35088. * when disposing several meshes in a row or a hierarchy of meshes.
  35089. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35090. */
  35091. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35092. /**
  35093. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35094. */
  35095. freeActiveMeshes(): void;
  35096. /**
  35097. * Clear the info related to rendering groups preventing retention points during dispose.
  35098. */
  35099. freeRenderingGroups(): void;
  35100. /** @hidden */
  35101. _isInIntermediateRendering(): boolean;
  35102. /**
  35103. * Lambda returning the list of potentially active meshes.
  35104. */
  35105. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35106. /**
  35107. * Lambda returning the list of potentially active sub meshes.
  35108. */
  35109. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35110. /**
  35111. * Lambda returning the list of potentially intersecting sub meshes.
  35112. */
  35113. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35114. /**
  35115. * Lambda returning the list of potentially colliding sub meshes.
  35116. */
  35117. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35118. private _activeMeshesFrozen;
  35119. /**
  35120. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35121. * @returns the current scene
  35122. */
  35123. freezeActiveMeshes(): Scene;
  35124. /**
  35125. * Use this function to restart evaluating active meshes on every frame
  35126. * @returns the current scene
  35127. */
  35128. unfreezeActiveMeshes(): Scene;
  35129. private _evaluateActiveMeshes;
  35130. private _activeMesh;
  35131. /**
  35132. * Update the transform matrix to update from the current active camera
  35133. * @param force defines a boolean used to force the update even if cache is up to date
  35134. */
  35135. updateTransformMatrix(force?: boolean): void;
  35136. private _bindFrameBuffer;
  35137. /** @hidden */
  35138. _allowPostProcessClearColor: boolean;
  35139. /** @hidden */
  35140. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35141. private _processSubCameras;
  35142. private _checkIntersections;
  35143. /** @hidden */
  35144. _advancePhysicsEngineStep(step: number): void;
  35145. /**
  35146. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35147. */
  35148. getDeterministicFrameTime: () => number;
  35149. /** @hidden */
  35150. _animate(): void;
  35151. /** Execute all animations (for a frame) */
  35152. animate(): void;
  35153. /**
  35154. * Render the scene
  35155. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35156. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35157. */
  35158. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35159. /**
  35160. * Freeze all materials
  35161. * A frozen material will not be updatable but should be faster to render
  35162. */
  35163. freezeMaterials(): void;
  35164. /**
  35165. * Unfreeze all materials
  35166. * A frozen material will not be updatable but should be faster to render
  35167. */
  35168. unfreezeMaterials(): void;
  35169. /**
  35170. * Releases all held ressources
  35171. */
  35172. dispose(): void;
  35173. /**
  35174. * Gets if the scene is already disposed
  35175. */
  35176. readonly isDisposed: boolean;
  35177. /**
  35178. * Call this function to reduce memory footprint of the scene.
  35179. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35180. */
  35181. clearCachedVertexData(): void;
  35182. /**
  35183. * This function will remove the local cached buffer data from texture.
  35184. * It will save memory but will prevent the texture from being rebuilt
  35185. */
  35186. cleanCachedTextureBuffer(): void;
  35187. /**
  35188. * Get the world extend vectors with an optional filter
  35189. *
  35190. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35191. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35192. */
  35193. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35194. min: Vector3;
  35195. max: Vector3;
  35196. };
  35197. /**
  35198. * Creates a ray that can be used to pick in the scene
  35199. * @param x defines the x coordinate of the origin (on-screen)
  35200. * @param y defines the y coordinate of the origin (on-screen)
  35201. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35202. * @param camera defines the camera to use for the picking
  35203. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35204. * @returns a Ray
  35205. */
  35206. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35207. /**
  35208. * Creates a ray that can be used to pick in the scene
  35209. * @param x defines the x coordinate of the origin (on-screen)
  35210. * @param y defines the y coordinate of the origin (on-screen)
  35211. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35212. * @param result defines the ray where to store the picking ray
  35213. * @param camera defines the camera to use for the picking
  35214. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35215. * @returns the current scene
  35216. */
  35217. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35218. /**
  35219. * Creates a ray that can be used to pick in the scene
  35220. * @param x defines the x coordinate of the origin (on-screen)
  35221. * @param y defines the y coordinate of the origin (on-screen)
  35222. * @param camera defines the camera to use for the picking
  35223. * @returns a Ray
  35224. */
  35225. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35226. /**
  35227. * Creates a ray that can be used to pick in the scene
  35228. * @param x defines the x coordinate of the origin (on-screen)
  35229. * @param y defines the y coordinate of the origin (on-screen)
  35230. * @param result defines the ray where to store the picking ray
  35231. * @param camera defines the camera to use for the picking
  35232. * @returns the current scene
  35233. */
  35234. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35235. /** Launch a ray to try to pick a mesh in the scene
  35236. * @param x position on screen
  35237. * @param y position on screen
  35238. * @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
  35239. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35240. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35241. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35242. * @returns a PickingInfo
  35243. */
  35244. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35245. /** Use the given ray to pick a mesh in the scene
  35246. * @param ray The ray to use to pick meshes
  35247. * @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
  35248. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35249. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35250. * @returns a PickingInfo
  35251. */
  35252. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35253. /**
  35254. * Launch a ray to try to pick a mesh in the scene
  35255. * @param x X position on screen
  35256. * @param y Y position on screen
  35257. * @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
  35258. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35259. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35260. * @returns an array of PickingInfo
  35261. */
  35262. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35263. /**
  35264. * Launch a ray to try to pick a mesh in the scene
  35265. * @param ray Ray to use
  35266. * @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
  35267. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35268. * @returns an array of PickingInfo
  35269. */
  35270. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35271. /**
  35272. * Force the value of meshUnderPointer
  35273. * @param mesh defines the mesh to use
  35274. */
  35275. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35276. /**
  35277. * Gets the mesh under the pointer
  35278. * @returns a Mesh or null if no mesh is under the pointer
  35279. */
  35280. getPointerOverMesh(): Nullable<AbstractMesh>;
  35281. /** @hidden */
  35282. _rebuildGeometries(): void;
  35283. /** @hidden */
  35284. _rebuildTextures(): void;
  35285. private _getByTags;
  35286. /**
  35287. * Get a list of meshes by tags
  35288. * @param tagsQuery defines the tags query to use
  35289. * @param forEach defines a predicate used to filter results
  35290. * @returns an array of Mesh
  35291. */
  35292. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35293. /**
  35294. * Get a list of cameras by tags
  35295. * @param tagsQuery defines the tags query to use
  35296. * @param forEach defines a predicate used to filter results
  35297. * @returns an array of Camera
  35298. */
  35299. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35300. /**
  35301. * Get a list of lights by tags
  35302. * @param tagsQuery defines the tags query to use
  35303. * @param forEach defines a predicate used to filter results
  35304. * @returns an array of Light
  35305. */
  35306. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35307. /**
  35308. * Get a list of materials by tags
  35309. * @param tagsQuery defines the tags query to use
  35310. * @param forEach defines a predicate used to filter results
  35311. * @returns an array of Material
  35312. */
  35313. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35314. /**
  35315. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35316. * This allowed control for front to back rendering or reversly depending of the special needs.
  35317. *
  35318. * @param renderingGroupId The rendering group id corresponding to its index
  35319. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35320. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35321. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35322. */
  35323. 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;
  35324. /**
  35325. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35326. *
  35327. * @param renderingGroupId The rendering group id corresponding to its index
  35328. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35329. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35330. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35331. */
  35332. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35333. /**
  35334. * Gets the current auto clear configuration for one rendering group of the rendering
  35335. * manager.
  35336. * @param index the rendering group index to get the information for
  35337. * @returns The auto clear setup for the requested rendering group
  35338. */
  35339. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35340. private _blockMaterialDirtyMechanism;
  35341. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35342. blockMaterialDirtyMechanism: boolean;
  35343. /**
  35344. * Will flag all materials as dirty to trigger new shader compilation
  35345. * @param flag defines the flag used to specify which material part must be marked as dirty
  35346. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35347. */
  35348. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35349. /** @hidden */
  35350. _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;
  35351. /** @hidden */
  35352. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35353. }
  35354. }
  35355. declare module "babylonjs/assetContainer" {
  35356. import { AbstractScene } from "babylonjs/abstractScene";
  35357. import { Scene } from "babylonjs/scene";
  35358. import { Mesh } from "babylonjs/Meshes/mesh";
  35359. /**
  35360. * Set of assets to keep when moving a scene into an asset container.
  35361. */
  35362. export class KeepAssets extends AbstractScene {
  35363. }
  35364. /**
  35365. * Container with a set of assets that can be added or removed from a scene.
  35366. */
  35367. export class AssetContainer extends AbstractScene {
  35368. /**
  35369. * The scene the AssetContainer belongs to.
  35370. */
  35371. scene: Scene;
  35372. /**
  35373. * Instantiates an AssetContainer.
  35374. * @param scene The scene the AssetContainer belongs to.
  35375. */
  35376. constructor(scene: Scene);
  35377. /**
  35378. * Adds all the assets from the container to the scene.
  35379. */
  35380. addAllToScene(): void;
  35381. /**
  35382. * Removes all the assets in the container from the scene
  35383. */
  35384. removeAllFromScene(): void;
  35385. /**
  35386. * Disposes all the assets in the container
  35387. */
  35388. dispose(): void;
  35389. private _moveAssets;
  35390. /**
  35391. * Removes all the assets contained in the scene and adds them to the container.
  35392. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35393. */
  35394. moveAllFromScene(keepAssets?: KeepAssets): void;
  35395. /**
  35396. * 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.
  35397. * @returns the root mesh
  35398. */
  35399. createRootMesh(): Mesh;
  35400. }
  35401. }
  35402. declare module "babylonjs/abstractScene" {
  35403. import { Scene } from "babylonjs/scene";
  35404. import { Nullable } from "babylonjs/types";
  35405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35406. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35407. import { Geometry } from "babylonjs/Meshes/geometry";
  35408. import { Skeleton } from "babylonjs/Bones/skeleton";
  35409. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35410. import { AssetContainer } from "babylonjs/assetContainer";
  35411. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35412. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35414. import { Material } from "babylonjs/Materials/material";
  35415. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35416. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35417. import { Camera } from "babylonjs/Cameras/camera";
  35418. import { Light } from "babylonjs/Lights/light";
  35419. import { Node } from "babylonjs/node";
  35420. import { Animation } from "babylonjs/Animations/animation";
  35421. /**
  35422. * Defines how the parser contract is defined.
  35423. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35424. */
  35425. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35426. /**
  35427. * Defines how the individual parser contract is defined.
  35428. * These parser can parse an individual asset
  35429. */
  35430. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35431. /**
  35432. * Base class of the scene acting as a container for the different elements composing a scene.
  35433. * This class is dynamically extended by the different components of the scene increasing
  35434. * flexibility and reducing coupling
  35435. */
  35436. export abstract class AbstractScene {
  35437. /**
  35438. * Stores the list of available parsers in the application.
  35439. */
  35440. private static _BabylonFileParsers;
  35441. /**
  35442. * Stores the list of available individual parsers in the application.
  35443. */
  35444. private static _IndividualBabylonFileParsers;
  35445. /**
  35446. * Adds a parser in the list of available ones
  35447. * @param name Defines the name of the parser
  35448. * @param parser Defines the parser to add
  35449. */
  35450. static AddParser(name: string, parser: BabylonFileParser): void;
  35451. /**
  35452. * Gets a general parser from the list of avaialble ones
  35453. * @param name Defines the name of the parser
  35454. * @returns the requested parser or null
  35455. */
  35456. static GetParser(name: string): Nullable<BabylonFileParser>;
  35457. /**
  35458. * Adds n individual parser in the list of available ones
  35459. * @param name Defines the name of the parser
  35460. * @param parser Defines the parser to add
  35461. */
  35462. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35463. /**
  35464. * Gets an individual parser from the list of avaialble ones
  35465. * @param name Defines the name of the parser
  35466. * @returns the requested parser or null
  35467. */
  35468. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35469. /**
  35470. * Parser json data and populate both a scene and its associated container object
  35471. * @param jsonData Defines the data to parse
  35472. * @param scene Defines the scene to parse the data for
  35473. * @param container Defines the container attached to the parsing sequence
  35474. * @param rootUrl Defines the root url of the data
  35475. */
  35476. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35477. /**
  35478. * Gets the list of root nodes (ie. nodes with no parent)
  35479. */
  35480. rootNodes: Node[];
  35481. /** All of the cameras added to this scene
  35482. * @see http://doc.babylonjs.com/babylon101/cameras
  35483. */
  35484. cameras: Camera[];
  35485. /**
  35486. * All of the lights added to this scene
  35487. * @see http://doc.babylonjs.com/babylon101/lights
  35488. */
  35489. lights: Light[];
  35490. /**
  35491. * All of the (abstract) meshes added to this scene
  35492. */
  35493. meshes: AbstractMesh[];
  35494. /**
  35495. * The list of skeletons added to the scene
  35496. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35497. */
  35498. skeletons: Skeleton[];
  35499. /**
  35500. * All of the particle systems added to this scene
  35501. * @see http://doc.babylonjs.com/babylon101/particles
  35502. */
  35503. particleSystems: IParticleSystem[];
  35504. /**
  35505. * Gets a list of Animations associated with the scene
  35506. */
  35507. animations: Animation[];
  35508. /**
  35509. * All of the animation groups added to this scene
  35510. * @see http://doc.babylonjs.com/how_to/group
  35511. */
  35512. animationGroups: AnimationGroup[];
  35513. /**
  35514. * All of the multi-materials added to this scene
  35515. * @see http://doc.babylonjs.com/how_to/multi_materials
  35516. */
  35517. multiMaterials: MultiMaterial[];
  35518. /**
  35519. * All of the materials added to this scene
  35520. * In the context of a Scene, it is not supposed to be modified manually.
  35521. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35522. * Note also that the order of the Material wihin the array is not significant and might change.
  35523. * @see http://doc.babylonjs.com/babylon101/materials
  35524. */
  35525. materials: Material[];
  35526. /**
  35527. * The list of morph target managers added to the scene
  35528. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35529. */
  35530. morphTargetManagers: MorphTargetManager[];
  35531. /**
  35532. * The list of geometries used in the scene.
  35533. */
  35534. geometries: Geometry[];
  35535. /**
  35536. * All of the tranform nodes added to this scene
  35537. * In the context of a Scene, it is not supposed to be modified manually.
  35538. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35539. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35540. * @see http://doc.babylonjs.com/how_to/transformnode
  35541. */
  35542. transformNodes: TransformNode[];
  35543. /**
  35544. * ActionManagers available on the scene.
  35545. */
  35546. actionManagers: AbstractActionManager[];
  35547. /**
  35548. * Textures to keep.
  35549. */
  35550. textures: BaseTexture[];
  35551. /**
  35552. * Environment texture for the scene
  35553. */
  35554. environmentTexture: Nullable<BaseTexture>;
  35555. }
  35556. }
  35557. declare module "babylonjs/Audio/sound" {
  35558. import { Observable } from "babylonjs/Misc/observable";
  35559. import { Vector3 } from "babylonjs/Maths/math.vector";
  35560. import { Nullable } from "babylonjs/types";
  35561. import { Scene } from "babylonjs/scene";
  35562. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35563. /**
  35564. * Interface used to define options for Sound class
  35565. */
  35566. export interface ISoundOptions {
  35567. /**
  35568. * Does the sound autoplay once loaded.
  35569. */
  35570. autoplay?: boolean;
  35571. /**
  35572. * Does the sound loop after it finishes playing once.
  35573. */
  35574. loop?: boolean;
  35575. /**
  35576. * Sound's volume
  35577. */
  35578. volume?: number;
  35579. /**
  35580. * Is it a spatial sound?
  35581. */
  35582. spatialSound?: boolean;
  35583. /**
  35584. * Maximum distance to hear that sound
  35585. */
  35586. maxDistance?: number;
  35587. /**
  35588. * Uses user defined attenuation function
  35589. */
  35590. useCustomAttenuation?: boolean;
  35591. /**
  35592. * Define the roll off factor of spatial sounds.
  35593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35594. */
  35595. rolloffFactor?: number;
  35596. /**
  35597. * Define the reference distance the sound should be heard perfectly.
  35598. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35599. */
  35600. refDistance?: number;
  35601. /**
  35602. * Define the distance attenuation model the sound will follow.
  35603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35604. */
  35605. distanceModel?: string;
  35606. /**
  35607. * Defines the playback speed (1 by default)
  35608. */
  35609. playbackRate?: number;
  35610. /**
  35611. * Defines if the sound is from a streaming source
  35612. */
  35613. streaming?: boolean;
  35614. /**
  35615. * Defines an optional length (in seconds) inside the sound file
  35616. */
  35617. length?: number;
  35618. /**
  35619. * Defines an optional offset (in seconds) inside the sound file
  35620. */
  35621. offset?: number;
  35622. /**
  35623. * If true, URLs will not be required to state the audio file codec to use.
  35624. */
  35625. skipCodecCheck?: boolean;
  35626. }
  35627. /**
  35628. * Defines a sound that can be played in the application.
  35629. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35631. */
  35632. export class Sound {
  35633. /**
  35634. * The name of the sound in the scene.
  35635. */
  35636. name: string;
  35637. /**
  35638. * Does the sound autoplay once loaded.
  35639. */
  35640. autoplay: boolean;
  35641. /**
  35642. * Does the sound loop after it finishes playing once.
  35643. */
  35644. loop: boolean;
  35645. /**
  35646. * Does the sound use a custom attenuation curve to simulate the falloff
  35647. * happening when the source gets further away from the camera.
  35648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35649. */
  35650. useCustomAttenuation: boolean;
  35651. /**
  35652. * The sound track id this sound belongs to.
  35653. */
  35654. soundTrackId: number;
  35655. /**
  35656. * Is this sound currently played.
  35657. */
  35658. isPlaying: boolean;
  35659. /**
  35660. * Is this sound currently paused.
  35661. */
  35662. isPaused: boolean;
  35663. /**
  35664. * Does this sound enables spatial sound.
  35665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35666. */
  35667. spatialSound: boolean;
  35668. /**
  35669. * Define the reference distance the sound should be heard perfectly.
  35670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35671. */
  35672. refDistance: number;
  35673. /**
  35674. * Define the roll off factor of spatial sounds.
  35675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35676. */
  35677. rolloffFactor: number;
  35678. /**
  35679. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35681. */
  35682. maxDistance: number;
  35683. /**
  35684. * Define the distance attenuation model the sound will follow.
  35685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35686. */
  35687. distanceModel: string;
  35688. /**
  35689. * @hidden
  35690. * Back Compat
  35691. **/
  35692. onended: () => any;
  35693. /**
  35694. * Observable event when the current playing sound finishes.
  35695. */
  35696. onEndedObservable: Observable<Sound>;
  35697. private _panningModel;
  35698. private _playbackRate;
  35699. private _streaming;
  35700. private _startTime;
  35701. private _startOffset;
  35702. private _position;
  35703. /** @hidden */
  35704. _positionInEmitterSpace: boolean;
  35705. private _localDirection;
  35706. private _volume;
  35707. private _isReadyToPlay;
  35708. private _isDirectional;
  35709. private _readyToPlayCallback;
  35710. private _audioBuffer;
  35711. private _soundSource;
  35712. private _streamingSource;
  35713. private _soundPanner;
  35714. private _soundGain;
  35715. private _inputAudioNode;
  35716. private _outputAudioNode;
  35717. private _coneInnerAngle;
  35718. private _coneOuterAngle;
  35719. private _coneOuterGain;
  35720. private _scene;
  35721. private _connectedTransformNode;
  35722. private _customAttenuationFunction;
  35723. private _registerFunc;
  35724. private _isOutputConnected;
  35725. private _htmlAudioElement;
  35726. private _urlType;
  35727. private _length?;
  35728. private _offset?;
  35729. /** @hidden */
  35730. static _SceneComponentInitialization: (scene: Scene) => void;
  35731. /**
  35732. * Create a sound and attach it to a scene
  35733. * @param name Name of your sound
  35734. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35735. * @param scene defines the scene the sound belongs to
  35736. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35737. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35738. */
  35739. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35740. /**
  35741. * Release the sound and its associated resources
  35742. */
  35743. dispose(): void;
  35744. /**
  35745. * Gets if the sounds is ready to be played or not.
  35746. * @returns true if ready, otherwise false
  35747. */
  35748. isReady(): boolean;
  35749. private _soundLoaded;
  35750. /**
  35751. * Sets the data of the sound from an audiobuffer
  35752. * @param audioBuffer The audioBuffer containing the data
  35753. */
  35754. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35755. /**
  35756. * Updates the current sounds options such as maxdistance, loop...
  35757. * @param options A JSON object containing values named as the object properties
  35758. */
  35759. updateOptions(options: ISoundOptions): void;
  35760. private _createSpatialParameters;
  35761. private _updateSpatialParameters;
  35762. /**
  35763. * Switch the panning model to HRTF:
  35764. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35766. */
  35767. switchPanningModelToHRTF(): void;
  35768. /**
  35769. * Switch the panning model to Equal Power:
  35770. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35772. */
  35773. switchPanningModelToEqualPower(): void;
  35774. private _switchPanningModel;
  35775. /**
  35776. * Connect this sound to a sound track audio node like gain...
  35777. * @param soundTrackAudioNode the sound track audio node to connect to
  35778. */
  35779. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35780. /**
  35781. * Transform this sound into a directional source
  35782. * @param coneInnerAngle Size of the inner cone in degree
  35783. * @param coneOuterAngle Size of the outer cone in degree
  35784. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35785. */
  35786. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35787. /**
  35788. * Gets or sets the inner angle for the directional cone.
  35789. */
  35790. /**
  35791. * Gets or sets the inner angle for the directional cone.
  35792. */
  35793. directionalConeInnerAngle: number;
  35794. /**
  35795. * Gets or sets the outer angle for the directional cone.
  35796. */
  35797. /**
  35798. * Gets or sets the outer angle for the directional cone.
  35799. */
  35800. directionalConeOuterAngle: number;
  35801. /**
  35802. * Sets the position of the emitter if spatial sound is enabled
  35803. * @param newPosition Defines the new posisiton
  35804. */
  35805. setPosition(newPosition: Vector3): void;
  35806. /**
  35807. * Sets the local direction of the emitter if spatial sound is enabled
  35808. * @param newLocalDirection Defines the new local direction
  35809. */
  35810. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35811. private _updateDirection;
  35812. /** @hidden */
  35813. updateDistanceFromListener(): void;
  35814. /**
  35815. * Sets a new custom attenuation function for the sound.
  35816. * @param callback Defines the function used for the attenuation
  35817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35818. */
  35819. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35820. /**
  35821. * Play the sound
  35822. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35823. * @param offset (optional) Start the sound at a specific time in seconds
  35824. * @param length (optional) Sound duration (in seconds)
  35825. */
  35826. play(time?: number, offset?: number, length?: number): void;
  35827. private _onended;
  35828. /**
  35829. * Stop the sound
  35830. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35831. */
  35832. stop(time?: number): void;
  35833. /**
  35834. * Put the sound in pause
  35835. */
  35836. pause(): void;
  35837. /**
  35838. * Sets a dedicated volume for this sounds
  35839. * @param newVolume Define the new volume of the sound
  35840. * @param time Define time for gradual change to new volume
  35841. */
  35842. setVolume(newVolume: number, time?: number): void;
  35843. /**
  35844. * Set the sound play back rate
  35845. * @param newPlaybackRate Define the playback rate the sound should be played at
  35846. */
  35847. setPlaybackRate(newPlaybackRate: number): void;
  35848. /**
  35849. * Gets the volume of the sound.
  35850. * @returns the volume of the sound
  35851. */
  35852. getVolume(): number;
  35853. /**
  35854. * Attach the sound to a dedicated mesh
  35855. * @param transformNode The transform node to connect the sound with
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35857. */
  35858. attachToMesh(transformNode: TransformNode): void;
  35859. /**
  35860. * Detach the sound from the previously attached mesh
  35861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35862. */
  35863. detachFromMesh(): void;
  35864. private _onRegisterAfterWorldMatrixUpdate;
  35865. /**
  35866. * Clone the current sound in the scene.
  35867. * @returns the new sound clone
  35868. */
  35869. clone(): Nullable<Sound>;
  35870. /**
  35871. * Gets the current underlying audio buffer containing the data
  35872. * @returns the audio buffer
  35873. */
  35874. getAudioBuffer(): Nullable<AudioBuffer>;
  35875. /**
  35876. * Serializes the Sound in a JSON representation
  35877. * @returns the JSON representation of the sound
  35878. */
  35879. serialize(): any;
  35880. /**
  35881. * Parse a JSON representation of a sound to innstantiate in a given scene
  35882. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35883. * @param scene Define the scene the new parsed sound should be created in
  35884. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35885. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35886. * @returns the newly parsed sound
  35887. */
  35888. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35889. }
  35890. }
  35891. declare module "babylonjs/Actions/directAudioActions" {
  35892. import { Action } from "babylonjs/Actions/action";
  35893. import { Condition } from "babylonjs/Actions/condition";
  35894. import { Sound } from "babylonjs/Audio/sound";
  35895. /**
  35896. * This defines an action helpful to play a defined sound on a triggered action.
  35897. */
  35898. export class PlaySoundAction extends Action {
  35899. private _sound;
  35900. /**
  35901. * Instantiate the action
  35902. * @param triggerOptions defines the trigger options
  35903. * @param sound defines the sound to play
  35904. * @param condition defines the trigger related conditions
  35905. */
  35906. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35907. /** @hidden */
  35908. _prepare(): void;
  35909. /**
  35910. * Execute the action and play the sound.
  35911. */
  35912. execute(): void;
  35913. /**
  35914. * Serializes the actions and its related information.
  35915. * @param parent defines the object to serialize in
  35916. * @returns the serialized object
  35917. */
  35918. serialize(parent: any): any;
  35919. }
  35920. /**
  35921. * This defines an action helpful to stop a defined sound on a triggered action.
  35922. */
  35923. export class StopSoundAction extends Action {
  35924. private _sound;
  35925. /**
  35926. * Instantiate the action
  35927. * @param triggerOptions defines the trigger options
  35928. * @param sound defines the sound to stop
  35929. * @param condition defines the trigger related conditions
  35930. */
  35931. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35932. /** @hidden */
  35933. _prepare(): void;
  35934. /**
  35935. * Execute the action and stop the sound.
  35936. */
  35937. execute(): void;
  35938. /**
  35939. * Serializes the actions and its related information.
  35940. * @param parent defines the object to serialize in
  35941. * @returns the serialized object
  35942. */
  35943. serialize(parent: any): any;
  35944. }
  35945. }
  35946. declare module "babylonjs/Actions/interpolateValueAction" {
  35947. import { Action } from "babylonjs/Actions/action";
  35948. import { Condition } from "babylonjs/Actions/condition";
  35949. import { Observable } from "babylonjs/Misc/observable";
  35950. /**
  35951. * This defines an action responsible to change the value of a property
  35952. * by interpolating between its current value and the newly set one once triggered.
  35953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35954. */
  35955. export class InterpolateValueAction extends Action {
  35956. /**
  35957. * Defines the path of the property where the value should be interpolated
  35958. */
  35959. propertyPath: string;
  35960. /**
  35961. * Defines the target value at the end of the interpolation.
  35962. */
  35963. value: any;
  35964. /**
  35965. * Defines the time it will take for the property to interpolate to the value.
  35966. */
  35967. duration: number;
  35968. /**
  35969. * Defines if the other scene animations should be stopped when the action has been triggered
  35970. */
  35971. stopOtherAnimations?: boolean;
  35972. /**
  35973. * Defines a callback raised once the interpolation animation has been done.
  35974. */
  35975. onInterpolationDone?: () => void;
  35976. /**
  35977. * Observable triggered once the interpolation animation has been done.
  35978. */
  35979. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35980. private _target;
  35981. private _effectiveTarget;
  35982. private _property;
  35983. /**
  35984. * Instantiate the action
  35985. * @param triggerOptions defines the trigger options
  35986. * @param target defines the object containing the value to interpolate
  35987. * @param propertyPath defines the path to the property in the target object
  35988. * @param value defines the target value at the end of the interpolation
  35989. * @param duration deines the time it will take for the property to interpolate to the value.
  35990. * @param condition defines the trigger related conditions
  35991. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35992. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35993. */
  35994. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35995. /** @hidden */
  35996. _prepare(): void;
  35997. /**
  35998. * Execute the action starts the value interpolation.
  35999. */
  36000. execute(): void;
  36001. /**
  36002. * Serializes the actions and its related information.
  36003. * @param parent defines the object to serialize in
  36004. * @returns the serialized object
  36005. */
  36006. serialize(parent: any): any;
  36007. }
  36008. }
  36009. declare module "babylonjs/Actions/index" {
  36010. export * from "babylonjs/Actions/action";
  36011. export * from "babylonjs/Actions/actionEvent";
  36012. export * from "babylonjs/Actions/actionManager";
  36013. export * from "babylonjs/Actions/condition";
  36014. export * from "babylonjs/Actions/directActions";
  36015. export * from "babylonjs/Actions/directAudioActions";
  36016. export * from "babylonjs/Actions/interpolateValueAction";
  36017. }
  36018. declare module "babylonjs/Animations/index" {
  36019. export * from "babylonjs/Animations/animatable";
  36020. export * from "babylonjs/Animations/animation";
  36021. export * from "babylonjs/Animations/animationGroup";
  36022. export * from "babylonjs/Animations/animationPropertiesOverride";
  36023. export * from "babylonjs/Animations/easing";
  36024. export * from "babylonjs/Animations/runtimeAnimation";
  36025. export * from "babylonjs/Animations/animationEvent";
  36026. export * from "babylonjs/Animations/animationGroup";
  36027. export * from "babylonjs/Animations/animationKey";
  36028. export * from "babylonjs/Animations/animationRange";
  36029. export * from "babylonjs/Animations/animatable.interface";
  36030. }
  36031. declare module "babylonjs/Audio/soundTrack" {
  36032. import { Sound } from "babylonjs/Audio/sound";
  36033. import { Analyser } from "babylonjs/Audio/analyser";
  36034. import { Scene } from "babylonjs/scene";
  36035. /**
  36036. * Options allowed during the creation of a sound track.
  36037. */
  36038. export interface ISoundTrackOptions {
  36039. /**
  36040. * The volume the sound track should take during creation
  36041. */
  36042. volume?: number;
  36043. /**
  36044. * Define if the sound track is the main sound track of the scene
  36045. */
  36046. mainTrack?: boolean;
  36047. }
  36048. /**
  36049. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36050. * It will be also used in a future release to apply effects on a specific track.
  36051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36052. */
  36053. export class SoundTrack {
  36054. /**
  36055. * The unique identifier of the sound track in the scene.
  36056. */
  36057. id: number;
  36058. /**
  36059. * The list of sounds included in the sound track.
  36060. */
  36061. soundCollection: Array<Sound>;
  36062. private _outputAudioNode;
  36063. private _scene;
  36064. private _isMainTrack;
  36065. private _connectedAnalyser;
  36066. private _options;
  36067. private _isInitialized;
  36068. /**
  36069. * Creates a new sound track.
  36070. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36071. * @param scene Define the scene the sound track belongs to
  36072. * @param options
  36073. */
  36074. constructor(scene: Scene, options?: ISoundTrackOptions);
  36075. private _initializeSoundTrackAudioGraph;
  36076. /**
  36077. * Release the sound track and its associated resources
  36078. */
  36079. dispose(): void;
  36080. /**
  36081. * Adds a sound to this sound track
  36082. * @param sound define the cound to add
  36083. * @ignoreNaming
  36084. */
  36085. AddSound(sound: Sound): void;
  36086. /**
  36087. * Removes a sound to this sound track
  36088. * @param sound define the cound to remove
  36089. * @ignoreNaming
  36090. */
  36091. RemoveSound(sound: Sound): void;
  36092. /**
  36093. * Set a global volume for the full sound track.
  36094. * @param newVolume Define the new volume of the sound track
  36095. */
  36096. setVolume(newVolume: number): void;
  36097. /**
  36098. * Switch the panning model to HRTF:
  36099. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36100. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36101. */
  36102. switchPanningModelToHRTF(): void;
  36103. /**
  36104. * Switch the panning model to Equal Power:
  36105. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36107. */
  36108. switchPanningModelToEqualPower(): void;
  36109. /**
  36110. * Connect the sound track to an audio analyser allowing some amazing
  36111. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36113. * @param analyser The analyser to connect to the engine
  36114. */
  36115. connectToAnalyser(analyser: Analyser): void;
  36116. }
  36117. }
  36118. declare module "babylonjs/Audio/audioSceneComponent" {
  36119. import { Sound } from "babylonjs/Audio/sound";
  36120. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36121. import { Nullable } from "babylonjs/types";
  36122. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36123. import { Scene } from "babylonjs/scene";
  36124. import { AbstractScene } from "babylonjs/abstractScene";
  36125. import "babylonjs/Audio/audioEngine";
  36126. module "babylonjs/abstractScene" {
  36127. interface AbstractScene {
  36128. /**
  36129. * The list of sounds used in the scene.
  36130. */
  36131. sounds: Nullable<Array<Sound>>;
  36132. }
  36133. }
  36134. module "babylonjs/scene" {
  36135. interface Scene {
  36136. /**
  36137. * @hidden
  36138. * Backing field
  36139. */
  36140. _mainSoundTrack: SoundTrack;
  36141. /**
  36142. * The main sound track played by the scene.
  36143. * It cotains your primary collection of sounds.
  36144. */
  36145. mainSoundTrack: SoundTrack;
  36146. /**
  36147. * The list of sound tracks added to the scene
  36148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36149. */
  36150. soundTracks: Nullable<Array<SoundTrack>>;
  36151. /**
  36152. * Gets a sound using a given name
  36153. * @param name defines the name to search for
  36154. * @return the found sound or null if not found at all.
  36155. */
  36156. getSoundByName(name: string): Nullable<Sound>;
  36157. /**
  36158. * Gets or sets if audio support is enabled
  36159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36160. */
  36161. audioEnabled: boolean;
  36162. /**
  36163. * Gets or sets if audio will be output to headphones
  36164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36165. */
  36166. headphone: boolean;
  36167. }
  36168. }
  36169. /**
  36170. * Defines the sound scene component responsible to manage any sounds
  36171. * in a given scene.
  36172. */
  36173. export class AudioSceneComponent implements ISceneSerializableComponent {
  36174. /**
  36175. * The component name helpfull to identify the component in the list of scene components.
  36176. */
  36177. readonly name: string;
  36178. /**
  36179. * The scene the component belongs to.
  36180. */
  36181. scene: Scene;
  36182. private _audioEnabled;
  36183. /**
  36184. * Gets whether audio is enabled or not.
  36185. * Please use related enable/disable method to switch state.
  36186. */
  36187. readonly audioEnabled: boolean;
  36188. private _headphone;
  36189. /**
  36190. * Gets whether audio is outputing to headphone or not.
  36191. * Please use the according Switch methods to change output.
  36192. */
  36193. readonly headphone: boolean;
  36194. /**
  36195. * Creates a new instance of the component for the given scene
  36196. * @param scene Defines the scene to register the component in
  36197. */
  36198. constructor(scene: Scene);
  36199. /**
  36200. * Registers the component in a given scene
  36201. */
  36202. register(): void;
  36203. /**
  36204. * Rebuilds the elements related to this component in case of
  36205. * context lost for instance.
  36206. */
  36207. rebuild(): void;
  36208. /**
  36209. * Serializes the component data to the specified json object
  36210. * @param serializationObject The object to serialize to
  36211. */
  36212. serialize(serializationObject: any): void;
  36213. /**
  36214. * Adds all the elements from the container to the scene
  36215. * @param container the container holding the elements
  36216. */
  36217. addFromContainer(container: AbstractScene): void;
  36218. /**
  36219. * Removes all the elements in the container from the scene
  36220. * @param container contains the elements to remove
  36221. * @param dispose if the removed element should be disposed (default: false)
  36222. */
  36223. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36224. /**
  36225. * Disposes the component and the associated ressources.
  36226. */
  36227. dispose(): void;
  36228. /**
  36229. * Disables audio in the associated scene.
  36230. */
  36231. disableAudio(): void;
  36232. /**
  36233. * Enables audio in the associated scene.
  36234. */
  36235. enableAudio(): void;
  36236. /**
  36237. * Switch audio to headphone output.
  36238. */
  36239. switchAudioModeForHeadphones(): void;
  36240. /**
  36241. * Switch audio to normal speakers.
  36242. */
  36243. switchAudioModeForNormalSpeakers(): void;
  36244. private _afterRender;
  36245. }
  36246. }
  36247. declare module "babylonjs/Audio/weightedsound" {
  36248. import { Sound } from "babylonjs/Audio/sound";
  36249. /**
  36250. * Wraps one or more Sound objects and selects one with random weight for playback.
  36251. */
  36252. export class WeightedSound {
  36253. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36254. loop: boolean;
  36255. private _coneInnerAngle;
  36256. private _coneOuterAngle;
  36257. private _volume;
  36258. /** A Sound is currently playing. */
  36259. isPlaying: boolean;
  36260. /** A Sound is currently paused. */
  36261. isPaused: boolean;
  36262. private _sounds;
  36263. private _weights;
  36264. private _currentIndex?;
  36265. /**
  36266. * Creates a new WeightedSound from the list of sounds given.
  36267. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36268. * @param sounds Array of Sounds that will be selected from.
  36269. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36270. */
  36271. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36272. /**
  36273. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36274. */
  36275. /**
  36276. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36277. */
  36278. directionalConeInnerAngle: number;
  36279. /**
  36280. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36281. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36282. */
  36283. /**
  36284. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36285. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36286. */
  36287. directionalConeOuterAngle: number;
  36288. /**
  36289. * Playback volume.
  36290. */
  36291. /**
  36292. * Playback volume.
  36293. */
  36294. volume: number;
  36295. private _onended;
  36296. /**
  36297. * Suspend playback
  36298. */
  36299. pause(): void;
  36300. /**
  36301. * Stop playback
  36302. */
  36303. stop(): void;
  36304. /**
  36305. * Start playback.
  36306. * @param startOffset Position the clip head at a specific time in seconds.
  36307. */
  36308. play(startOffset?: number): void;
  36309. }
  36310. }
  36311. declare module "babylonjs/Audio/index" {
  36312. export * from "babylonjs/Audio/analyser";
  36313. export * from "babylonjs/Audio/audioEngine";
  36314. export * from "babylonjs/Audio/audioSceneComponent";
  36315. export * from "babylonjs/Audio/sound";
  36316. export * from "babylonjs/Audio/soundTrack";
  36317. export * from "babylonjs/Audio/weightedsound";
  36318. }
  36319. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36320. import { Behavior } from "babylonjs/Behaviors/behavior";
  36321. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36322. import { BackEase } from "babylonjs/Animations/easing";
  36323. /**
  36324. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36326. */
  36327. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36328. /**
  36329. * Gets the name of the behavior.
  36330. */
  36331. readonly name: string;
  36332. /**
  36333. * The easing function used by animations
  36334. */
  36335. static EasingFunction: BackEase;
  36336. /**
  36337. * The easing mode used by animations
  36338. */
  36339. static EasingMode: number;
  36340. /**
  36341. * The duration of the animation, in milliseconds
  36342. */
  36343. transitionDuration: number;
  36344. /**
  36345. * Length of the distance animated by the transition when lower radius is reached
  36346. */
  36347. lowerRadiusTransitionRange: number;
  36348. /**
  36349. * Length of the distance animated by the transition when upper radius is reached
  36350. */
  36351. upperRadiusTransitionRange: number;
  36352. private _autoTransitionRange;
  36353. /**
  36354. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36355. */
  36356. /**
  36357. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36358. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36359. */
  36360. autoTransitionRange: boolean;
  36361. private _attachedCamera;
  36362. private _onAfterCheckInputsObserver;
  36363. private _onMeshTargetChangedObserver;
  36364. /**
  36365. * Initializes the behavior.
  36366. */
  36367. init(): void;
  36368. /**
  36369. * Attaches the behavior to its arc rotate camera.
  36370. * @param camera Defines the camera to attach the behavior to
  36371. */
  36372. attach(camera: ArcRotateCamera): void;
  36373. /**
  36374. * Detaches the behavior from its current arc rotate camera.
  36375. */
  36376. detach(): void;
  36377. private _radiusIsAnimating;
  36378. private _radiusBounceTransition;
  36379. private _animatables;
  36380. private _cachedWheelPrecision;
  36381. /**
  36382. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36383. * @param radiusLimit The limit to check against.
  36384. * @return Bool to indicate if at limit.
  36385. */
  36386. private _isRadiusAtLimit;
  36387. /**
  36388. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36389. * @param radiusDelta The delta by which to animate to. Can be negative.
  36390. */
  36391. private _applyBoundRadiusAnimation;
  36392. /**
  36393. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36394. */
  36395. protected _clearAnimationLocks(): void;
  36396. /**
  36397. * Stops and removes all animations that have been applied to the camera
  36398. */
  36399. stopAllAnimations(): void;
  36400. }
  36401. }
  36402. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36403. import { Behavior } from "babylonjs/Behaviors/behavior";
  36404. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36405. import { ExponentialEase } from "babylonjs/Animations/easing";
  36406. import { Nullable } from "babylonjs/types";
  36407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36408. import { Vector3 } from "babylonjs/Maths/math.vector";
  36409. /**
  36410. * 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.
  36411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36412. */
  36413. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36414. /**
  36415. * Gets the name of the behavior.
  36416. */
  36417. readonly name: string;
  36418. private _mode;
  36419. private _radiusScale;
  36420. private _positionScale;
  36421. private _defaultElevation;
  36422. private _elevationReturnTime;
  36423. private _elevationReturnWaitTime;
  36424. private _zoomStopsAnimation;
  36425. private _framingTime;
  36426. /**
  36427. * The easing function used by animations
  36428. */
  36429. static EasingFunction: ExponentialEase;
  36430. /**
  36431. * The easing mode used by animations
  36432. */
  36433. static EasingMode: number;
  36434. /**
  36435. * Sets the current mode used by the behavior
  36436. */
  36437. /**
  36438. * Gets current mode used by the behavior.
  36439. */
  36440. mode: number;
  36441. /**
  36442. * Sets the scale applied to the radius (1 by default)
  36443. */
  36444. /**
  36445. * Gets the scale applied to the radius
  36446. */
  36447. radiusScale: number;
  36448. /**
  36449. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36450. */
  36451. /**
  36452. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36453. */
  36454. positionScale: number;
  36455. /**
  36456. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36457. * behaviour is triggered, in radians.
  36458. */
  36459. /**
  36460. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36461. * behaviour is triggered, in radians.
  36462. */
  36463. defaultElevation: number;
  36464. /**
  36465. * Sets the time (in milliseconds) taken to return to the default beta position.
  36466. * Negative value indicates camera should not return to default.
  36467. */
  36468. /**
  36469. * Gets the time (in milliseconds) taken to return to the default beta position.
  36470. * Negative value indicates camera should not return to default.
  36471. */
  36472. elevationReturnTime: number;
  36473. /**
  36474. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36475. */
  36476. /**
  36477. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36478. */
  36479. elevationReturnWaitTime: number;
  36480. /**
  36481. * Sets the flag that indicates if user zooming should stop animation.
  36482. */
  36483. /**
  36484. * Gets the flag that indicates if user zooming should stop animation.
  36485. */
  36486. zoomStopsAnimation: boolean;
  36487. /**
  36488. * Sets the transition time when framing the mesh, in milliseconds
  36489. */
  36490. /**
  36491. * Gets the transition time when framing the mesh, in milliseconds
  36492. */
  36493. framingTime: number;
  36494. /**
  36495. * Define if the behavior should automatically change the configured
  36496. * camera limits and sensibilities.
  36497. */
  36498. autoCorrectCameraLimitsAndSensibility: boolean;
  36499. private _onPrePointerObservableObserver;
  36500. private _onAfterCheckInputsObserver;
  36501. private _onMeshTargetChangedObserver;
  36502. private _attachedCamera;
  36503. private _isPointerDown;
  36504. private _lastInteractionTime;
  36505. /**
  36506. * Initializes the behavior.
  36507. */
  36508. init(): void;
  36509. /**
  36510. * Attaches the behavior to its arc rotate camera.
  36511. * @param camera Defines the camera to attach the behavior to
  36512. */
  36513. attach(camera: ArcRotateCamera): void;
  36514. /**
  36515. * Detaches the behavior from its current arc rotate camera.
  36516. */
  36517. detach(): void;
  36518. private _animatables;
  36519. private _betaIsAnimating;
  36520. private _betaTransition;
  36521. private _radiusTransition;
  36522. private _vectorTransition;
  36523. /**
  36524. * Targets the given mesh and updates zoom level accordingly.
  36525. * @param mesh The mesh to target.
  36526. * @param radius Optional. If a cached radius position already exists, overrides default.
  36527. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36528. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36529. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36530. */
  36531. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36532. /**
  36533. * Targets the given mesh with its children and updates zoom level accordingly.
  36534. * @param mesh The mesh to target.
  36535. * @param radius Optional. If a cached radius position already exists, overrides default.
  36536. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36537. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36538. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36539. */
  36540. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36541. /**
  36542. * Targets the given meshes with their children and updates zoom level accordingly.
  36543. * @param meshes The mesh to target.
  36544. * @param radius Optional. If a cached radius position already exists, overrides default.
  36545. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36546. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36547. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36548. */
  36549. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36550. /**
  36551. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36552. * @param minimumWorld Determines the smaller position of the bounding box extend
  36553. * @param maximumWorld Determines the bigger position of the bounding box extend
  36554. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36555. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36556. */
  36557. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36558. /**
  36559. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36560. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36561. * frustum width.
  36562. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36563. * to fully enclose the mesh in the viewing frustum.
  36564. */
  36565. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36566. /**
  36567. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36568. * is automatically returned to its default position (expected to be above ground plane).
  36569. */
  36570. private _maintainCameraAboveGround;
  36571. /**
  36572. * Returns the frustum slope based on the canvas ratio and camera FOV
  36573. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36574. */
  36575. private _getFrustumSlope;
  36576. /**
  36577. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36578. */
  36579. private _clearAnimationLocks;
  36580. /**
  36581. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36582. */
  36583. private _applyUserInteraction;
  36584. /**
  36585. * Stops and removes all animations that have been applied to the camera
  36586. */
  36587. stopAllAnimations(): void;
  36588. /**
  36589. * Gets a value indicating if the user is moving the camera
  36590. */
  36591. readonly isUserIsMoving: boolean;
  36592. /**
  36593. * The camera can move all the way towards the mesh.
  36594. */
  36595. static IgnoreBoundsSizeMode: number;
  36596. /**
  36597. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36598. */
  36599. static FitFrustumSidesMode: number;
  36600. }
  36601. }
  36602. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36603. import { Nullable } from "babylonjs/types";
  36604. import { Camera } from "babylonjs/Cameras/camera";
  36605. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36606. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36607. /**
  36608. * Base class for Camera Pointer Inputs.
  36609. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36610. * for example usage.
  36611. */
  36612. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36613. /**
  36614. * Defines the camera the input is attached to.
  36615. */
  36616. abstract camera: Camera;
  36617. /**
  36618. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36619. */
  36620. protected _altKey: boolean;
  36621. protected _ctrlKey: boolean;
  36622. protected _metaKey: boolean;
  36623. protected _shiftKey: boolean;
  36624. /**
  36625. * Which mouse buttons were pressed at time of last mouse event.
  36626. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36627. */
  36628. protected _buttonsPressed: number;
  36629. /**
  36630. * Defines the buttons associated with the input to handle camera move.
  36631. */
  36632. buttons: number[];
  36633. /**
  36634. * Attach the input controls to a specific dom element to get the input from.
  36635. * @param element Defines the element the controls should be listened from
  36636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36637. */
  36638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36639. /**
  36640. * Detach the current controls from the specified dom element.
  36641. * @param element Defines the element to stop listening the inputs from
  36642. */
  36643. detachControl(element: Nullable<HTMLElement>): void;
  36644. /**
  36645. * Gets the class name of the current input.
  36646. * @returns the class name
  36647. */
  36648. getClassName(): string;
  36649. /**
  36650. * Get the friendly name associated with the input class.
  36651. * @returns the input friendly name
  36652. */
  36653. getSimpleName(): string;
  36654. /**
  36655. * Called on pointer POINTERDOUBLETAP event.
  36656. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36657. */
  36658. protected onDoubleTap(type: string): void;
  36659. /**
  36660. * Called on pointer POINTERMOVE event if only a single touch is active.
  36661. * Override this method to provide functionality.
  36662. */
  36663. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36664. /**
  36665. * Called on pointer POINTERMOVE event if multiple touches are active.
  36666. * Override this method to provide functionality.
  36667. */
  36668. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36669. /**
  36670. * Called on JS contextmenu event.
  36671. * Override this method to provide functionality.
  36672. */
  36673. protected onContextMenu(evt: PointerEvent): void;
  36674. /**
  36675. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36676. * press.
  36677. * Override this method to provide functionality.
  36678. */
  36679. protected onButtonDown(evt: PointerEvent): void;
  36680. /**
  36681. * Called each time a new POINTERUP event occurs. Ie, for each button
  36682. * release.
  36683. * Override this method to provide functionality.
  36684. */
  36685. protected onButtonUp(evt: PointerEvent): void;
  36686. /**
  36687. * Called when window becomes inactive.
  36688. * Override this method to provide functionality.
  36689. */
  36690. protected onLostFocus(): void;
  36691. private _pointerInput;
  36692. private _observer;
  36693. private _onLostFocus;
  36694. private pointA;
  36695. private pointB;
  36696. }
  36697. }
  36698. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36699. import { Nullable } from "babylonjs/types";
  36700. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36701. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36702. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36703. /**
  36704. * Manage the pointers inputs to control an arc rotate camera.
  36705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36706. */
  36707. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36708. /**
  36709. * Defines the camera the input is attached to.
  36710. */
  36711. camera: ArcRotateCamera;
  36712. /**
  36713. * Gets the class name of the current input.
  36714. * @returns the class name
  36715. */
  36716. getClassName(): string;
  36717. /**
  36718. * Defines the buttons associated with the input to handle camera move.
  36719. */
  36720. buttons: number[];
  36721. /**
  36722. * Defines the pointer angular sensibility along the X axis or how fast is
  36723. * the camera rotating.
  36724. */
  36725. angularSensibilityX: number;
  36726. /**
  36727. * Defines the pointer angular sensibility along the Y axis or how fast is
  36728. * the camera rotating.
  36729. */
  36730. angularSensibilityY: number;
  36731. /**
  36732. * Defines the pointer pinch precision or how fast is the camera zooming.
  36733. */
  36734. pinchPrecision: number;
  36735. /**
  36736. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36737. * from 0.
  36738. * It defines the percentage of current camera.radius to use as delta when
  36739. * pinch zoom is used.
  36740. */
  36741. pinchDeltaPercentage: number;
  36742. /**
  36743. * Defines the pointer panning sensibility or how fast is the camera moving.
  36744. */
  36745. panningSensibility: number;
  36746. /**
  36747. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36748. */
  36749. multiTouchPanning: boolean;
  36750. /**
  36751. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36752. * zoom (pinch) through multitouch.
  36753. */
  36754. multiTouchPanAndZoom: boolean;
  36755. /**
  36756. * Revers pinch action direction.
  36757. */
  36758. pinchInwards: boolean;
  36759. private _isPanClick;
  36760. private _twoFingerActivityCount;
  36761. private _isPinching;
  36762. /**
  36763. * Called on pointer POINTERMOVE event if only a single touch is active.
  36764. */
  36765. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36766. /**
  36767. * Called on pointer POINTERDOUBLETAP event.
  36768. */
  36769. protected onDoubleTap(type: string): void;
  36770. /**
  36771. * Called on pointer POINTERMOVE event if multiple touches are active.
  36772. */
  36773. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36774. /**
  36775. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36776. * press.
  36777. */
  36778. protected onButtonDown(evt: PointerEvent): void;
  36779. /**
  36780. * Called each time a new POINTERUP event occurs. Ie, for each button
  36781. * release.
  36782. */
  36783. protected onButtonUp(evt: PointerEvent): void;
  36784. /**
  36785. * Called when window becomes inactive.
  36786. */
  36787. protected onLostFocus(): void;
  36788. }
  36789. }
  36790. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36791. import { Nullable } from "babylonjs/types";
  36792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36794. /**
  36795. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36797. */
  36798. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36799. /**
  36800. * Defines the camera the input is attached to.
  36801. */
  36802. camera: ArcRotateCamera;
  36803. /**
  36804. * Defines the list of key codes associated with the up action (increase alpha)
  36805. */
  36806. keysUp: number[];
  36807. /**
  36808. * Defines the list of key codes associated with the down action (decrease alpha)
  36809. */
  36810. keysDown: number[];
  36811. /**
  36812. * Defines the list of key codes associated with the left action (increase beta)
  36813. */
  36814. keysLeft: number[];
  36815. /**
  36816. * Defines the list of key codes associated with the right action (decrease beta)
  36817. */
  36818. keysRight: number[];
  36819. /**
  36820. * Defines the list of key codes associated with the reset action.
  36821. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36822. */
  36823. keysReset: number[];
  36824. /**
  36825. * Defines the panning sensibility of the inputs.
  36826. * (How fast is the camera paning)
  36827. */
  36828. panningSensibility: number;
  36829. /**
  36830. * Defines the zooming sensibility of the inputs.
  36831. * (How fast is the camera zooming)
  36832. */
  36833. zoomingSensibility: number;
  36834. /**
  36835. * Defines wether maintaining the alt key down switch the movement mode from
  36836. * orientation to zoom.
  36837. */
  36838. useAltToZoom: boolean;
  36839. /**
  36840. * Rotation speed of the camera
  36841. */
  36842. angularSpeed: number;
  36843. private _keys;
  36844. private _ctrlPressed;
  36845. private _altPressed;
  36846. private _onCanvasBlurObserver;
  36847. private _onKeyboardObserver;
  36848. private _engine;
  36849. private _scene;
  36850. /**
  36851. * Attach the input controls to a specific dom element to get the input from.
  36852. * @param element Defines the element the controls should be listened from
  36853. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36854. */
  36855. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36856. /**
  36857. * Detach the current controls from the specified dom element.
  36858. * @param element Defines the element to stop listening the inputs from
  36859. */
  36860. detachControl(element: Nullable<HTMLElement>): void;
  36861. /**
  36862. * Update the current camera state depending on the inputs that have been used this frame.
  36863. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36864. */
  36865. checkInputs(): void;
  36866. /**
  36867. * Gets the class name of the current intput.
  36868. * @returns the class name
  36869. */
  36870. getClassName(): string;
  36871. /**
  36872. * Get the friendly name associated with the input class.
  36873. * @returns the input friendly name
  36874. */
  36875. getSimpleName(): string;
  36876. }
  36877. }
  36878. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36879. import { Nullable } from "babylonjs/types";
  36880. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36881. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36882. /**
  36883. * Manage the mouse wheel inputs to control an arc rotate camera.
  36884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36885. */
  36886. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36887. /**
  36888. * Defines the camera the input is attached to.
  36889. */
  36890. camera: ArcRotateCamera;
  36891. /**
  36892. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36893. */
  36894. wheelPrecision: number;
  36895. /**
  36896. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36897. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36898. */
  36899. wheelDeltaPercentage: number;
  36900. private _wheel;
  36901. private _observer;
  36902. private computeDeltaFromMouseWheelLegacyEvent;
  36903. /**
  36904. * Attach the input controls to a specific dom element to get the input from.
  36905. * @param element Defines the element the controls should be listened from
  36906. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36907. */
  36908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36909. /**
  36910. * Detach the current controls from the specified dom element.
  36911. * @param element Defines the element to stop listening the inputs from
  36912. */
  36913. detachControl(element: Nullable<HTMLElement>): void;
  36914. /**
  36915. * Gets the class name of the current intput.
  36916. * @returns the class name
  36917. */
  36918. getClassName(): string;
  36919. /**
  36920. * Get the friendly name associated with the input class.
  36921. * @returns the input friendly name
  36922. */
  36923. getSimpleName(): string;
  36924. }
  36925. }
  36926. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36927. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36928. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36929. /**
  36930. * Default Inputs manager for the ArcRotateCamera.
  36931. * It groups all the default supported inputs for ease of use.
  36932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36933. */
  36934. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36935. /**
  36936. * Instantiates a new ArcRotateCameraInputsManager.
  36937. * @param camera Defines the camera the inputs belong to
  36938. */
  36939. constructor(camera: ArcRotateCamera);
  36940. /**
  36941. * Add mouse wheel input support to the input manager.
  36942. * @returns the current input manager
  36943. */
  36944. addMouseWheel(): ArcRotateCameraInputsManager;
  36945. /**
  36946. * Add pointers input support to the input manager.
  36947. * @returns the current input manager
  36948. */
  36949. addPointers(): ArcRotateCameraInputsManager;
  36950. /**
  36951. * Add keyboard input support to the input manager.
  36952. * @returns the current input manager
  36953. */
  36954. addKeyboard(): ArcRotateCameraInputsManager;
  36955. }
  36956. }
  36957. declare module "babylonjs/Cameras/arcRotateCamera" {
  36958. import { Observable } from "babylonjs/Misc/observable";
  36959. import { Nullable } from "babylonjs/types";
  36960. import { Scene } from "babylonjs/scene";
  36961. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36963. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36964. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36965. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36966. import { Camera } from "babylonjs/Cameras/camera";
  36967. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36968. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36969. import { Collider } from "babylonjs/Collisions/collider";
  36970. /**
  36971. * This represents an orbital type of camera.
  36972. *
  36973. * 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.
  36974. * 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.
  36975. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36976. */
  36977. export class ArcRotateCamera extends TargetCamera {
  36978. /**
  36979. * Defines the rotation angle of the camera along the longitudinal axis.
  36980. */
  36981. alpha: number;
  36982. /**
  36983. * Defines the rotation angle of the camera along the latitudinal axis.
  36984. */
  36985. beta: number;
  36986. /**
  36987. * Defines the radius of the camera from it s target point.
  36988. */
  36989. radius: number;
  36990. protected _target: Vector3;
  36991. protected _targetHost: Nullable<AbstractMesh>;
  36992. /**
  36993. * Defines the target point of the camera.
  36994. * The camera looks towards it form the radius distance.
  36995. */
  36996. target: Vector3;
  36997. /**
  36998. * Define the current local position of the camera in the scene
  36999. */
  37000. position: Vector3;
  37001. protected _upVector: Vector3;
  37002. protected _upToYMatrix: Matrix;
  37003. protected _YToUpMatrix: Matrix;
  37004. /**
  37005. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37006. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37007. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37008. */
  37009. upVector: Vector3;
  37010. /**
  37011. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37012. */
  37013. setMatUp(): void;
  37014. /**
  37015. * Current inertia value on the longitudinal axis.
  37016. * The bigger this number the longer it will take for the camera to stop.
  37017. */
  37018. inertialAlphaOffset: number;
  37019. /**
  37020. * Current inertia value on the latitudinal axis.
  37021. * The bigger this number the longer it will take for the camera to stop.
  37022. */
  37023. inertialBetaOffset: number;
  37024. /**
  37025. * Current inertia value on the radius axis.
  37026. * The bigger this number the longer it will take for the camera to stop.
  37027. */
  37028. inertialRadiusOffset: number;
  37029. /**
  37030. * Minimum allowed angle on the longitudinal axis.
  37031. * This can help limiting how the Camera is able to move in the scene.
  37032. */
  37033. lowerAlphaLimit: Nullable<number>;
  37034. /**
  37035. * Maximum allowed angle on the longitudinal axis.
  37036. * This can help limiting how the Camera is able to move in the scene.
  37037. */
  37038. upperAlphaLimit: Nullable<number>;
  37039. /**
  37040. * Minimum allowed angle on the latitudinal axis.
  37041. * This can help limiting how the Camera is able to move in the scene.
  37042. */
  37043. lowerBetaLimit: number;
  37044. /**
  37045. * Maximum allowed angle on the latitudinal axis.
  37046. * This can help limiting how the Camera is able to move in the scene.
  37047. */
  37048. upperBetaLimit: number;
  37049. /**
  37050. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37051. * This can help limiting how the Camera is able to move in the scene.
  37052. */
  37053. lowerRadiusLimit: Nullable<number>;
  37054. /**
  37055. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37056. * This can help limiting how the Camera is able to move in the scene.
  37057. */
  37058. upperRadiusLimit: Nullable<number>;
  37059. /**
  37060. * Defines the current inertia value used during panning of the camera along the X axis.
  37061. */
  37062. inertialPanningX: number;
  37063. /**
  37064. * Defines the current inertia value used during panning of the camera along the Y axis.
  37065. */
  37066. inertialPanningY: number;
  37067. /**
  37068. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37069. * Basically if your fingers moves away from more than this distance you will be considered
  37070. * in pinch mode.
  37071. */
  37072. pinchToPanMaxDistance: number;
  37073. /**
  37074. * Defines the maximum distance the camera can pan.
  37075. * This could help keeping the cammera always in your scene.
  37076. */
  37077. panningDistanceLimit: Nullable<number>;
  37078. /**
  37079. * Defines the target of the camera before paning.
  37080. */
  37081. panningOriginTarget: Vector3;
  37082. /**
  37083. * Defines the value of the inertia used during panning.
  37084. * 0 would mean stop inertia and one would mean no decelleration at all.
  37085. */
  37086. panningInertia: number;
  37087. /**
  37088. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37089. */
  37090. angularSensibilityX: number;
  37091. /**
  37092. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37093. */
  37094. angularSensibilityY: number;
  37095. /**
  37096. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37097. */
  37098. pinchPrecision: number;
  37099. /**
  37100. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37101. * It will be used instead of pinchDeltaPrecision if different from 0.
  37102. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37103. */
  37104. pinchDeltaPercentage: number;
  37105. /**
  37106. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37107. */
  37108. panningSensibility: number;
  37109. /**
  37110. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37111. */
  37112. keysUp: number[];
  37113. /**
  37114. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37115. */
  37116. keysDown: number[];
  37117. /**
  37118. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37119. */
  37120. keysLeft: number[];
  37121. /**
  37122. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37123. */
  37124. keysRight: number[];
  37125. /**
  37126. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37127. */
  37128. wheelPrecision: number;
  37129. /**
  37130. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37131. * It will be used instead of pinchDeltaPrecision if different from 0.
  37132. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37133. */
  37134. wheelDeltaPercentage: number;
  37135. /**
  37136. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37137. */
  37138. zoomOnFactor: number;
  37139. /**
  37140. * Defines a screen offset for the camera position.
  37141. */
  37142. targetScreenOffset: Vector2;
  37143. /**
  37144. * Allows the camera to be completely reversed.
  37145. * If false the camera can not arrive upside down.
  37146. */
  37147. allowUpsideDown: boolean;
  37148. /**
  37149. * Define if double tap/click is used to restore the previously saved state of the camera.
  37150. */
  37151. useInputToRestoreState: boolean;
  37152. /** @hidden */
  37153. _viewMatrix: Matrix;
  37154. /** @hidden */
  37155. _useCtrlForPanning: boolean;
  37156. /** @hidden */
  37157. _panningMouseButton: number;
  37158. /**
  37159. * Defines the input associated to the camera.
  37160. */
  37161. inputs: ArcRotateCameraInputsManager;
  37162. /** @hidden */
  37163. _reset: () => void;
  37164. /**
  37165. * Defines the allowed panning axis.
  37166. */
  37167. panningAxis: Vector3;
  37168. protected _localDirection: Vector3;
  37169. protected _transformedDirection: Vector3;
  37170. private _bouncingBehavior;
  37171. /**
  37172. * Gets the bouncing behavior of the camera if it has been enabled.
  37173. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37174. */
  37175. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37176. /**
  37177. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37178. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37179. */
  37180. useBouncingBehavior: boolean;
  37181. private _framingBehavior;
  37182. /**
  37183. * Gets the framing behavior of the camera if it has been enabled.
  37184. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37185. */
  37186. readonly framingBehavior: Nullable<FramingBehavior>;
  37187. /**
  37188. * Defines if the framing behavior of the camera is enabled on the camera.
  37189. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37190. */
  37191. useFramingBehavior: boolean;
  37192. private _autoRotationBehavior;
  37193. /**
  37194. * Gets the auto rotation behavior of the camera if it has been enabled.
  37195. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37196. */
  37197. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37198. /**
  37199. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37200. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37201. */
  37202. useAutoRotationBehavior: boolean;
  37203. /**
  37204. * Observable triggered when the mesh target has been changed on the camera.
  37205. */
  37206. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37207. /**
  37208. * Event raised when the camera is colliding with a mesh.
  37209. */
  37210. onCollide: (collidedMesh: AbstractMesh) => void;
  37211. /**
  37212. * Defines whether the camera should check collision with the objects oh the scene.
  37213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37214. */
  37215. checkCollisions: boolean;
  37216. /**
  37217. * Defines the collision radius of the camera.
  37218. * This simulates a sphere around the camera.
  37219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37220. */
  37221. collisionRadius: Vector3;
  37222. protected _collider: Collider;
  37223. protected _previousPosition: Vector3;
  37224. protected _collisionVelocity: Vector3;
  37225. protected _newPosition: Vector3;
  37226. protected _previousAlpha: number;
  37227. protected _previousBeta: number;
  37228. protected _previousRadius: number;
  37229. protected _collisionTriggered: boolean;
  37230. protected _targetBoundingCenter: Nullable<Vector3>;
  37231. private _computationVector;
  37232. /**
  37233. * Instantiates a new ArcRotateCamera in a given scene
  37234. * @param name Defines the name of the camera
  37235. * @param alpha Defines the camera rotation along the logitudinal axis
  37236. * @param beta Defines the camera rotation along the latitudinal axis
  37237. * @param radius Defines the camera distance from its target
  37238. * @param target Defines the camera target
  37239. * @param scene Defines the scene the camera belongs to
  37240. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37241. */
  37242. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37243. /** @hidden */
  37244. _initCache(): void;
  37245. /** @hidden */
  37246. _updateCache(ignoreParentClass?: boolean): void;
  37247. protected _getTargetPosition(): Vector3;
  37248. private _storedAlpha;
  37249. private _storedBeta;
  37250. private _storedRadius;
  37251. private _storedTarget;
  37252. /**
  37253. * Stores the current state of the camera (alpha, beta, radius and target)
  37254. * @returns the camera itself
  37255. */
  37256. storeState(): Camera;
  37257. /**
  37258. * @hidden
  37259. * Restored camera state. You must call storeState() first
  37260. */
  37261. _restoreStateValues(): boolean;
  37262. /** @hidden */
  37263. _isSynchronizedViewMatrix(): boolean;
  37264. /**
  37265. * Attached controls to the current camera.
  37266. * @param element Defines the element the controls should be listened from
  37267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37268. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37269. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37270. */
  37271. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37272. /**
  37273. * Detach the current controls from the camera.
  37274. * The camera will stop reacting to inputs.
  37275. * @param element Defines the element to stop listening the inputs from
  37276. */
  37277. detachControl(element: HTMLElement): void;
  37278. /** @hidden */
  37279. _checkInputs(): void;
  37280. protected _checkLimits(): void;
  37281. /**
  37282. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37283. */
  37284. rebuildAnglesAndRadius(): void;
  37285. /**
  37286. * Use a position to define the current camera related information like aplha, beta and radius
  37287. * @param position Defines the position to set the camera at
  37288. */
  37289. setPosition(position: Vector3): void;
  37290. /**
  37291. * Defines the target the camera should look at.
  37292. * This will automatically adapt alpha beta and radius to fit within the new target.
  37293. * @param target Defines the new target as a Vector or a mesh
  37294. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37295. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37296. */
  37297. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37298. /** @hidden */
  37299. _getViewMatrix(): Matrix;
  37300. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37301. /**
  37302. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37303. * @param meshes Defines the mesh to zoom on
  37304. * @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)
  37305. */
  37306. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37307. /**
  37308. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37309. * The target will be changed but the radius
  37310. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37311. * @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)
  37312. */
  37313. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37314. min: Vector3;
  37315. max: Vector3;
  37316. distance: number;
  37317. }, doNotUpdateMaxZ?: boolean): void;
  37318. /**
  37319. * @override
  37320. * Override Camera.createRigCamera
  37321. */
  37322. createRigCamera(name: string, cameraIndex: number): Camera;
  37323. /**
  37324. * @hidden
  37325. * @override
  37326. * Override Camera._updateRigCameras
  37327. */
  37328. _updateRigCameras(): void;
  37329. /**
  37330. * Destroy the camera and release the current resources hold by it.
  37331. */
  37332. dispose(): void;
  37333. /**
  37334. * Gets the current object class name.
  37335. * @return the class name
  37336. */
  37337. getClassName(): string;
  37338. }
  37339. }
  37340. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37341. import { Behavior } from "babylonjs/Behaviors/behavior";
  37342. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37343. /**
  37344. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37346. */
  37347. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37348. /**
  37349. * Gets the name of the behavior.
  37350. */
  37351. readonly name: string;
  37352. private _zoomStopsAnimation;
  37353. private _idleRotationSpeed;
  37354. private _idleRotationWaitTime;
  37355. private _idleRotationSpinupTime;
  37356. /**
  37357. * Sets the flag that indicates if user zooming should stop animation.
  37358. */
  37359. /**
  37360. * Gets the flag that indicates if user zooming should stop animation.
  37361. */
  37362. zoomStopsAnimation: boolean;
  37363. /**
  37364. * Sets the default speed at which the camera rotates around the model.
  37365. */
  37366. /**
  37367. * Gets the default speed at which the camera rotates around the model.
  37368. */
  37369. idleRotationSpeed: number;
  37370. /**
  37371. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37372. */
  37373. /**
  37374. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37375. */
  37376. idleRotationWaitTime: number;
  37377. /**
  37378. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37379. */
  37380. /**
  37381. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37382. */
  37383. idleRotationSpinupTime: number;
  37384. /**
  37385. * Gets a value indicating if the camera is currently rotating because of this behavior
  37386. */
  37387. readonly rotationInProgress: boolean;
  37388. private _onPrePointerObservableObserver;
  37389. private _onAfterCheckInputsObserver;
  37390. private _attachedCamera;
  37391. private _isPointerDown;
  37392. private _lastFrameTime;
  37393. private _lastInteractionTime;
  37394. private _cameraRotationSpeed;
  37395. /**
  37396. * Initializes the behavior.
  37397. */
  37398. init(): void;
  37399. /**
  37400. * Attaches the behavior to its arc rotate camera.
  37401. * @param camera Defines the camera to attach the behavior to
  37402. */
  37403. attach(camera: ArcRotateCamera): void;
  37404. /**
  37405. * Detaches the behavior from its current arc rotate camera.
  37406. */
  37407. detach(): void;
  37408. /**
  37409. * Returns true if user is scrolling.
  37410. * @return true if user is scrolling.
  37411. */
  37412. private _userIsZooming;
  37413. private _lastFrameRadius;
  37414. private _shouldAnimationStopForInteraction;
  37415. /**
  37416. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37417. */
  37418. private _applyUserInteraction;
  37419. private _userIsMoving;
  37420. }
  37421. }
  37422. declare module "babylonjs/Behaviors/Cameras/index" {
  37423. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37424. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37425. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37426. }
  37427. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37428. import { Mesh } from "babylonjs/Meshes/mesh";
  37429. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37430. import { Behavior } from "babylonjs/Behaviors/behavior";
  37431. /**
  37432. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37433. */
  37434. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37435. private ui;
  37436. /**
  37437. * The name of the behavior
  37438. */
  37439. name: string;
  37440. /**
  37441. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37442. */
  37443. distanceAwayFromFace: number;
  37444. /**
  37445. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37446. */
  37447. distanceAwayFromBottomOfFace: number;
  37448. private _faceVectors;
  37449. private _target;
  37450. private _scene;
  37451. private _onRenderObserver;
  37452. private _tmpMatrix;
  37453. private _tmpVector;
  37454. /**
  37455. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37456. * @param ui The transform node that should be attched to the mesh
  37457. */
  37458. constructor(ui: TransformNode);
  37459. /**
  37460. * Initializes the behavior
  37461. */
  37462. init(): void;
  37463. private _closestFace;
  37464. private _zeroVector;
  37465. private _lookAtTmpMatrix;
  37466. private _lookAtToRef;
  37467. /**
  37468. * Attaches the AttachToBoxBehavior to the passed in mesh
  37469. * @param target The mesh that the specified node will be attached to
  37470. */
  37471. attach(target: Mesh): void;
  37472. /**
  37473. * Detaches the behavior from the mesh
  37474. */
  37475. detach(): void;
  37476. }
  37477. }
  37478. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37479. import { Behavior } from "babylonjs/Behaviors/behavior";
  37480. import { Mesh } from "babylonjs/Meshes/mesh";
  37481. /**
  37482. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37483. */
  37484. export class FadeInOutBehavior implements Behavior<Mesh> {
  37485. /**
  37486. * Time in milliseconds to delay before fading in (Default: 0)
  37487. */
  37488. delay: number;
  37489. /**
  37490. * Time in milliseconds for the mesh to fade in (Default: 300)
  37491. */
  37492. fadeInTime: number;
  37493. private _millisecondsPerFrame;
  37494. private _hovered;
  37495. private _hoverValue;
  37496. private _ownerNode;
  37497. /**
  37498. * Instatiates the FadeInOutBehavior
  37499. */
  37500. constructor();
  37501. /**
  37502. * The name of the behavior
  37503. */
  37504. readonly name: string;
  37505. /**
  37506. * Initializes the behavior
  37507. */
  37508. init(): void;
  37509. /**
  37510. * Attaches the fade behavior on the passed in mesh
  37511. * @param ownerNode The mesh that will be faded in/out once attached
  37512. */
  37513. attach(ownerNode: Mesh): void;
  37514. /**
  37515. * Detaches the behavior from the mesh
  37516. */
  37517. detach(): void;
  37518. /**
  37519. * Triggers the mesh to begin fading in or out
  37520. * @param value if the object should fade in or out (true to fade in)
  37521. */
  37522. fadeIn(value: boolean): void;
  37523. private _update;
  37524. private _setAllVisibility;
  37525. }
  37526. }
  37527. declare module "babylonjs/Misc/pivotTools" {
  37528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37529. /**
  37530. * Class containing a set of static utilities functions for managing Pivots
  37531. * @hidden
  37532. */
  37533. export class PivotTools {
  37534. private static _PivotCached;
  37535. private static _OldPivotPoint;
  37536. private static _PivotTranslation;
  37537. private static _PivotTmpVector;
  37538. /** @hidden */
  37539. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37540. /** @hidden */
  37541. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37542. }
  37543. }
  37544. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37545. import { Scene } from "babylonjs/scene";
  37546. import { Vector4 } from "babylonjs/Maths/math.vector";
  37547. import { Mesh } from "babylonjs/Meshes/mesh";
  37548. import { Nullable } from "babylonjs/types";
  37549. import { Plane } from "babylonjs/Maths/math.plane";
  37550. /**
  37551. * Class containing static functions to help procedurally build meshes
  37552. */
  37553. export class PlaneBuilder {
  37554. /**
  37555. * Creates a plane mesh
  37556. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37557. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37558. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37559. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37560. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37562. * @param name defines the name of the mesh
  37563. * @param options defines the options used to create the mesh
  37564. * @param scene defines the hosting scene
  37565. * @returns the plane mesh
  37566. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37567. */
  37568. static CreatePlane(name: string, options: {
  37569. size?: number;
  37570. width?: number;
  37571. height?: number;
  37572. sideOrientation?: number;
  37573. frontUVs?: Vector4;
  37574. backUVs?: Vector4;
  37575. updatable?: boolean;
  37576. sourcePlane?: Plane;
  37577. }, scene?: Nullable<Scene>): Mesh;
  37578. }
  37579. }
  37580. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37581. import { Behavior } from "babylonjs/Behaviors/behavior";
  37582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37583. import { Observable } from "babylonjs/Misc/observable";
  37584. import { Vector3 } from "babylonjs/Maths/math.vector";
  37585. import { Ray } from "babylonjs/Culling/ray";
  37586. import "babylonjs/Meshes/Builders/planeBuilder";
  37587. /**
  37588. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37589. */
  37590. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37591. private static _AnyMouseID;
  37592. /**
  37593. * Abstract mesh the behavior is set on
  37594. */
  37595. attachedNode: AbstractMesh;
  37596. private _dragPlane;
  37597. private _scene;
  37598. private _pointerObserver;
  37599. private _beforeRenderObserver;
  37600. private static _planeScene;
  37601. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37602. /**
  37603. * 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)
  37604. */
  37605. maxDragAngle: number;
  37606. /**
  37607. * @hidden
  37608. */
  37609. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37610. /**
  37611. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37612. */
  37613. currentDraggingPointerID: number;
  37614. /**
  37615. * The last position where the pointer hit the drag plane in world space
  37616. */
  37617. lastDragPosition: Vector3;
  37618. /**
  37619. * If the behavior is currently in a dragging state
  37620. */
  37621. dragging: boolean;
  37622. /**
  37623. * 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)
  37624. */
  37625. dragDeltaRatio: number;
  37626. /**
  37627. * If the drag plane orientation should be updated during the dragging (Default: true)
  37628. */
  37629. updateDragPlane: boolean;
  37630. private _debugMode;
  37631. private _moving;
  37632. /**
  37633. * Fires each time the attached mesh is dragged with the pointer
  37634. * * delta between last drag position and current drag position in world space
  37635. * * dragDistance along the drag axis
  37636. * * dragPlaneNormal normal of the current drag plane used during the drag
  37637. * * dragPlanePoint in world space where the drag intersects the drag plane
  37638. */
  37639. onDragObservable: Observable<{
  37640. delta: Vector3;
  37641. dragPlanePoint: Vector3;
  37642. dragPlaneNormal: Vector3;
  37643. dragDistance: number;
  37644. pointerId: number;
  37645. }>;
  37646. /**
  37647. * Fires each time a drag begins (eg. mouse down on mesh)
  37648. */
  37649. onDragStartObservable: Observable<{
  37650. dragPlanePoint: Vector3;
  37651. pointerId: number;
  37652. }>;
  37653. /**
  37654. * Fires each time a drag ends (eg. mouse release after drag)
  37655. */
  37656. onDragEndObservable: Observable<{
  37657. dragPlanePoint: Vector3;
  37658. pointerId: number;
  37659. }>;
  37660. /**
  37661. * If the attached mesh should be moved when dragged
  37662. */
  37663. moveAttached: boolean;
  37664. /**
  37665. * If the drag behavior will react to drag events (Default: true)
  37666. */
  37667. enabled: boolean;
  37668. /**
  37669. * If pointer events should start and release the drag (Default: true)
  37670. */
  37671. startAndReleaseDragOnPointerEvents: boolean;
  37672. /**
  37673. * If camera controls should be detached during the drag
  37674. */
  37675. detachCameraControls: boolean;
  37676. /**
  37677. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37678. */
  37679. useObjectOrienationForDragging: boolean;
  37680. private _options;
  37681. /**
  37682. * Creates a pointer drag behavior that can be attached to a mesh
  37683. * @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)
  37684. */
  37685. constructor(options?: {
  37686. dragAxis?: Vector3;
  37687. dragPlaneNormal?: Vector3;
  37688. });
  37689. /**
  37690. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37691. */
  37692. validateDrag: (targetPosition: Vector3) => boolean;
  37693. /**
  37694. * The name of the behavior
  37695. */
  37696. readonly name: string;
  37697. /**
  37698. * Initializes the behavior
  37699. */
  37700. init(): void;
  37701. private _tmpVector;
  37702. private _alternatePickedPoint;
  37703. private _worldDragAxis;
  37704. private _targetPosition;
  37705. private _attachedElement;
  37706. /**
  37707. * Attaches the drag behavior the passed in mesh
  37708. * @param ownerNode The mesh that will be dragged around once attached
  37709. */
  37710. attach(ownerNode: AbstractMesh): void;
  37711. /**
  37712. * Force relase the drag action by code.
  37713. */
  37714. releaseDrag(): void;
  37715. private _startDragRay;
  37716. private _lastPointerRay;
  37717. /**
  37718. * Simulates the start of a pointer drag event on the behavior
  37719. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37720. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37721. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37722. */
  37723. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37724. private _startDrag;
  37725. private _dragDelta;
  37726. private _moveDrag;
  37727. private _pickWithRayOnDragPlane;
  37728. private _pointA;
  37729. private _pointB;
  37730. private _pointC;
  37731. private _lineA;
  37732. private _lineB;
  37733. private _localAxis;
  37734. private _lookAt;
  37735. private _updateDragPlanePosition;
  37736. /**
  37737. * Detaches the behavior from the mesh
  37738. */
  37739. detach(): void;
  37740. }
  37741. }
  37742. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37743. import { Mesh } from "babylonjs/Meshes/mesh";
  37744. import { Behavior } from "babylonjs/Behaviors/behavior";
  37745. /**
  37746. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37747. */
  37748. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37749. private _dragBehaviorA;
  37750. private _dragBehaviorB;
  37751. private _startDistance;
  37752. private _initialScale;
  37753. private _targetScale;
  37754. private _ownerNode;
  37755. private _sceneRenderObserver;
  37756. /**
  37757. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37758. */
  37759. constructor();
  37760. /**
  37761. * The name of the behavior
  37762. */
  37763. readonly name: string;
  37764. /**
  37765. * Initializes the behavior
  37766. */
  37767. init(): void;
  37768. private _getCurrentDistance;
  37769. /**
  37770. * Attaches the scale behavior the passed in mesh
  37771. * @param ownerNode The mesh that will be scaled around once attached
  37772. */
  37773. attach(ownerNode: Mesh): void;
  37774. /**
  37775. * Detaches the behavior from the mesh
  37776. */
  37777. detach(): void;
  37778. }
  37779. }
  37780. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37781. import { Behavior } from "babylonjs/Behaviors/behavior";
  37782. import { Mesh } from "babylonjs/Meshes/mesh";
  37783. import { Observable } from "babylonjs/Misc/observable";
  37784. /**
  37785. * 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
  37786. */
  37787. export class SixDofDragBehavior implements Behavior<Mesh> {
  37788. private static _virtualScene;
  37789. private _ownerNode;
  37790. private _sceneRenderObserver;
  37791. private _scene;
  37792. private _targetPosition;
  37793. private _virtualOriginMesh;
  37794. private _virtualDragMesh;
  37795. private _pointerObserver;
  37796. private _moving;
  37797. private _startingOrientation;
  37798. /**
  37799. * 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)
  37800. */
  37801. private zDragFactor;
  37802. /**
  37803. * If the object should rotate to face the drag origin
  37804. */
  37805. rotateDraggedObject: boolean;
  37806. /**
  37807. * If the behavior is currently in a dragging state
  37808. */
  37809. dragging: boolean;
  37810. /**
  37811. * 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)
  37812. */
  37813. dragDeltaRatio: number;
  37814. /**
  37815. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37816. */
  37817. currentDraggingPointerID: number;
  37818. /**
  37819. * If camera controls should be detached during the drag
  37820. */
  37821. detachCameraControls: boolean;
  37822. /**
  37823. * Fires each time a drag starts
  37824. */
  37825. onDragStartObservable: Observable<{}>;
  37826. /**
  37827. * Fires each time a drag ends (eg. mouse release after drag)
  37828. */
  37829. onDragEndObservable: Observable<{}>;
  37830. /**
  37831. * 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
  37832. */
  37833. constructor();
  37834. /**
  37835. * The name of the behavior
  37836. */
  37837. readonly name: string;
  37838. /**
  37839. * Initializes the behavior
  37840. */
  37841. init(): void;
  37842. /**
  37843. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37844. */
  37845. private readonly _pointerCamera;
  37846. /**
  37847. * Attaches the scale behavior the passed in mesh
  37848. * @param ownerNode The mesh that will be scaled around once attached
  37849. */
  37850. attach(ownerNode: Mesh): void;
  37851. /**
  37852. * Detaches the behavior from the mesh
  37853. */
  37854. detach(): void;
  37855. }
  37856. }
  37857. declare module "babylonjs/Behaviors/Meshes/index" {
  37858. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37859. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37860. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37861. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37862. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37863. }
  37864. declare module "babylonjs/Behaviors/index" {
  37865. export * from "babylonjs/Behaviors/behavior";
  37866. export * from "babylonjs/Behaviors/Cameras/index";
  37867. export * from "babylonjs/Behaviors/Meshes/index";
  37868. }
  37869. declare module "babylonjs/Bones/boneIKController" {
  37870. import { Bone } from "babylonjs/Bones/bone";
  37871. import { Vector3 } from "babylonjs/Maths/math.vector";
  37872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37873. import { Nullable } from "babylonjs/types";
  37874. /**
  37875. * Class used to apply inverse kinematics to bones
  37876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37877. */
  37878. export class BoneIKController {
  37879. private static _tmpVecs;
  37880. private static _tmpQuat;
  37881. private static _tmpMats;
  37882. /**
  37883. * Gets or sets the target mesh
  37884. */
  37885. targetMesh: AbstractMesh;
  37886. /** Gets or sets the mesh used as pole */
  37887. poleTargetMesh: AbstractMesh;
  37888. /**
  37889. * Gets or sets the bone used as pole
  37890. */
  37891. poleTargetBone: Nullable<Bone>;
  37892. /**
  37893. * Gets or sets the target position
  37894. */
  37895. targetPosition: Vector3;
  37896. /**
  37897. * Gets or sets the pole target position
  37898. */
  37899. poleTargetPosition: Vector3;
  37900. /**
  37901. * Gets or sets the pole target local offset
  37902. */
  37903. poleTargetLocalOffset: Vector3;
  37904. /**
  37905. * Gets or sets the pole angle
  37906. */
  37907. poleAngle: number;
  37908. /**
  37909. * Gets or sets the mesh associated with the controller
  37910. */
  37911. mesh: AbstractMesh;
  37912. /**
  37913. * 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)
  37914. */
  37915. slerpAmount: number;
  37916. private _bone1Quat;
  37917. private _bone1Mat;
  37918. private _bone2Ang;
  37919. private _bone1;
  37920. private _bone2;
  37921. private _bone1Length;
  37922. private _bone2Length;
  37923. private _maxAngle;
  37924. private _maxReach;
  37925. private _rightHandedSystem;
  37926. private _bendAxis;
  37927. private _slerping;
  37928. private _adjustRoll;
  37929. /**
  37930. * Gets or sets maximum allowed angle
  37931. */
  37932. maxAngle: number;
  37933. /**
  37934. * Creates a new BoneIKController
  37935. * @param mesh defines the mesh to control
  37936. * @param bone defines the bone to control
  37937. * @param options defines options to set up the controller
  37938. */
  37939. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37940. targetMesh?: AbstractMesh;
  37941. poleTargetMesh?: AbstractMesh;
  37942. poleTargetBone?: Bone;
  37943. poleTargetLocalOffset?: Vector3;
  37944. poleAngle?: number;
  37945. bendAxis?: Vector3;
  37946. maxAngle?: number;
  37947. slerpAmount?: number;
  37948. });
  37949. private _setMaxAngle;
  37950. /**
  37951. * Force the controller to update the bones
  37952. */
  37953. update(): void;
  37954. }
  37955. }
  37956. declare module "babylonjs/Bones/boneLookController" {
  37957. import { Vector3 } from "babylonjs/Maths/math.vector";
  37958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37959. import { Bone } from "babylonjs/Bones/bone";
  37960. import { Space } from "babylonjs/Maths/math.axis";
  37961. /**
  37962. * Class used to make a bone look toward a point in space
  37963. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37964. */
  37965. export class BoneLookController {
  37966. private static _tmpVecs;
  37967. private static _tmpQuat;
  37968. private static _tmpMats;
  37969. /**
  37970. * The target Vector3 that the bone will look at
  37971. */
  37972. target: Vector3;
  37973. /**
  37974. * The mesh that the bone is attached to
  37975. */
  37976. mesh: AbstractMesh;
  37977. /**
  37978. * The bone that will be looking to the target
  37979. */
  37980. bone: Bone;
  37981. /**
  37982. * The up axis of the coordinate system that is used when the bone is rotated
  37983. */
  37984. upAxis: Vector3;
  37985. /**
  37986. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37987. */
  37988. upAxisSpace: Space;
  37989. /**
  37990. * Used to make an adjustment to the yaw of the bone
  37991. */
  37992. adjustYaw: number;
  37993. /**
  37994. * Used to make an adjustment to the pitch of the bone
  37995. */
  37996. adjustPitch: number;
  37997. /**
  37998. * Used to make an adjustment to the roll of the bone
  37999. */
  38000. adjustRoll: number;
  38001. /**
  38002. * 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)
  38003. */
  38004. slerpAmount: number;
  38005. private _minYaw;
  38006. private _maxYaw;
  38007. private _minPitch;
  38008. private _maxPitch;
  38009. private _minYawSin;
  38010. private _minYawCos;
  38011. private _maxYawSin;
  38012. private _maxYawCos;
  38013. private _midYawConstraint;
  38014. private _minPitchTan;
  38015. private _maxPitchTan;
  38016. private _boneQuat;
  38017. private _slerping;
  38018. private _transformYawPitch;
  38019. private _transformYawPitchInv;
  38020. private _firstFrameSkipped;
  38021. private _yawRange;
  38022. private _fowardAxis;
  38023. /**
  38024. * Gets or sets the minimum yaw angle that the bone can look to
  38025. */
  38026. minYaw: number;
  38027. /**
  38028. * Gets or sets the maximum yaw angle that the bone can look to
  38029. */
  38030. maxYaw: number;
  38031. /**
  38032. * Gets or sets the minimum pitch angle that the bone can look to
  38033. */
  38034. minPitch: number;
  38035. /**
  38036. * Gets or sets the maximum pitch angle that the bone can look to
  38037. */
  38038. maxPitch: number;
  38039. /**
  38040. * Create a BoneLookController
  38041. * @param mesh the mesh that the bone belongs to
  38042. * @param bone the bone that will be looking to the target
  38043. * @param target the target Vector3 to look at
  38044. * @param options optional settings:
  38045. * * maxYaw: the maximum angle the bone will yaw to
  38046. * * minYaw: the minimum angle the bone will yaw to
  38047. * * maxPitch: the maximum angle the bone will pitch to
  38048. * * minPitch: the minimum angle the bone will yaw to
  38049. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38050. * * upAxis: the up axis of the coordinate system
  38051. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38052. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38053. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38054. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38055. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38056. * * adjustRoll: used to make an adjustment to the roll of the bone
  38057. **/
  38058. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38059. maxYaw?: number;
  38060. minYaw?: number;
  38061. maxPitch?: number;
  38062. minPitch?: number;
  38063. slerpAmount?: number;
  38064. upAxis?: Vector3;
  38065. upAxisSpace?: Space;
  38066. yawAxis?: Vector3;
  38067. pitchAxis?: Vector3;
  38068. adjustYaw?: number;
  38069. adjustPitch?: number;
  38070. adjustRoll?: number;
  38071. });
  38072. /**
  38073. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38074. */
  38075. update(): void;
  38076. private _getAngleDiff;
  38077. private _getAngleBetween;
  38078. private _isAngleBetween;
  38079. }
  38080. }
  38081. declare module "babylonjs/Bones/index" {
  38082. export * from "babylonjs/Bones/bone";
  38083. export * from "babylonjs/Bones/boneIKController";
  38084. export * from "babylonjs/Bones/boneLookController";
  38085. export * from "babylonjs/Bones/skeleton";
  38086. }
  38087. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38088. import { Nullable } from "babylonjs/types";
  38089. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38090. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38091. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38092. /**
  38093. * Manage the gamepad inputs to control an arc rotate camera.
  38094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38095. */
  38096. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38097. /**
  38098. * Defines the camera the input is attached to.
  38099. */
  38100. camera: ArcRotateCamera;
  38101. /**
  38102. * Defines the gamepad the input is gathering event from.
  38103. */
  38104. gamepad: Nullable<Gamepad>;
  38105. /**
  38106. * Defines the gamepad rotation sensiblity.
  38107. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38108. */
  38109. gamepadRotationSensibility: number;
  38110. /**
  38111. * Defines the gamepad move sensiblity.
  38112. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38113. */
  38114. gamepadMoveSensibility: number;
  38115. private _onGamepadConnectedObserver;
  38116. private _onGamepadDisconnectedObserver;
  38117. /**
  38118. * Attach the input controls to a specific dom element to get the input from.
  38119. * @param element Defines the element the controls should be listened from
  38120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38121. */
  38122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38123. /**
  38124. * Detach the current controls from the specified dom element.
  38125. * @param element Defines the element to stop listening the inputs from
  38126. */
  38127. detachControl(element: Nullable<HTMLElement>): void;
  38128. /**
  38129. * Update the current camera state depending on the inputs that have been used this frame.
  38130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38131. */
  38132. checkInputs(): void;
  38133. /**
  38134. * Gets the class name of the current intput.
  38135. * @returns the class name
  38136. */
  38137. getClassName(): string;
  38138. /**
  38139. * Get the friendly name associated with the input class.
  38140. * @returns the input friendly name
  38141. */
  38142. getSimpleName(): string;
  38143. }
  38144. }
  38145. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38146. import { Nullable } from "babylonjs/types";
  38147. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38148. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38149. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38150. interface ArcRotateCameraInputsManager {
  38151. /**
  38152. * Add orientation input support to the input manager.
  38153. * @returns the current input manager
  38154. */
  38155. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38156. }
  38157. }
  38158. /**
  38159. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38160. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38161. */
  38162. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38163. /**
  38164. * Defines the camera the input is attached to.
  38165. */
  38166. camera: ArcRotateCamera;
  38167. /**
  38168. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38169. */
  38170. alphaCorrection: number;
  38171. /**
  38172. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38173. */
  38174. gammaCorrection: number;
  38175. private _alpha;
  38176. private _gamma;
  38177. private _dirty;
  38178. private _deviceOrientationHandler;
  38179. /**
  38180. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38181. */
  38182. constructor();
  38183. /**
  38184. * Attach the input controls to a specific dom element to get the input from.
  38185. * @param element Defines the element the controls should be listened from
  38186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38187. */
  38188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38189. /** @hidden */
  38190. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38191. /**
  38192. * Update the current camera state depending on the inputs that have been used this frame.
  38193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38194. */
  38195. checkInputs(): void;
  38196. /**
  38197. * Detach the current controls from the specified dom element.
  38198. * @param element Defines the element to stop listening the inputs from
  38199. */
  38200. detachControl(element: Nullable<HTMLElement>): void;
  38201. /**
  38202. * Gets the class name of the current intput.
  38203. * @returns the class name
  38204. */
  38205. getClassName(): string;
  38206. /**
  38207. * Get the friendly name associated with the input class.
  38208. * @returns the input friendly name
  38209. */
  38210. getSimpleName(): string;
  38211. }
  38212. }
  38213. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38214. import { Nullable } from "babylonjs/types";
  38215. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38216. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38217. /**
  38218. * Listen to mouse events to control the camera.
  38219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38220. */
  38221. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38222. /**
  38223. * Defines the camera the input is attached to.
  38224. */
  38225. camera: FlyCamera;
  38226. /**
  38227. * Defines if touch is enabled. (Default is true.)
  38228. */
  38229. touchEnabled: boolean;
  38230. /**
  38231. * Defines the buttons associated with the input to handle camera rotation.
  38232. */
  38233. buttons: number[];
  38234. /**
  38235. * Assign buttons for Yaw control.
  38236. */
  38237. buttonsYaw: number[];
  38238. /**
  38239. * Assign buttons for Pitch control.
  38240. */
  38241. buttonsPitch: number[];
  38242. /**
  38243. * Assign buttons for Roll control.
  38244. */
  38245. buttonsRoll: number[];
  38246. /**
  38247. * Detect if any button is being pressed while mouse is moved.
  38248. * -1 = Mouse locked.
  38249. * 0 = Left button.
  38250. * 1 = Middle Button.
  38251. * 2 = Right Button.
  38252. */
  38253. activeButton: number;
  38254. /**
  38255. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38256. * Higher values reduce its sensitivity.
  38257. */
  38258. angularSensibility: number;
  38259. private _mousemoveCallback;
  38260. private _observer;
  38261. private _rollObserver;
  38262. private previousPosition;
  38263. private noPreventDefault;
  38264. private element;
  38265. /**
  38266. * Listen to mouse events to control the camera.
  38267. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38269. */
  38270. constructor(touchEnabled?: boolean);
  38271. /**
  38272. * Attach the mouse control to the HTML DOM element.
  38273. * @param element Defines the element that listens to the input events.
  38274. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38275. */
  38276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38277. /**
  38278. * Detach the current controls from the specified dom element.
  38279. * @param element Defines the element to stop listening the inputs from
  38280. */
  38281. detachControl(element: Nullable<HTMLElement>): void;
  38282. /**
  38283. * Gets the class name of the current input.
  38284. * @returns the class name.
  38285. */
  38286. getClassName(): string;
  38287. /**
  38288. * Get the friendly name associated with the input class.
  38289. * @returns the input's friendly name.
  38290. */
  38291. getSimpleName(): string;
  38292. private _pointerInput;
  38293. private _onMouseMove;
  38294. /**
  38295. * Rotate camera by mouse offset.
  38296. */
  38297. private rotateCamera;
  38298. }
  38299. }
  38300. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38301. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38302. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38303. /**
  38304. * Default Inputs manager for the FlyCamera.
  38305. * It groups all the default supported inputs for ease of use.
  38306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38307. */
  38308. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38309. /**
  38310. * Instantiates a new FlyCameraInputsManager.
  38311. * @param camera Defines the camera the inputs belong to.
  38312. */
  38313. constructor(camera: FlyCamera);
  38314. /**
  38315. * Add keyboard input support to the input manager.
  38316. * @returns the new FlyCameraKeyboardMoveInput().
  38317. */
  38318. addKeyboard(): FlyCameraInputsManager;
  38319. /**
  38320. * Add mouse input support to the input manager.
  38321. * @param touchEnabled Enable touch screen support.
  38322. * @returns the new FlyCameraMouseInput().
  38323. */
  38324. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38325. }
  38326. }
  38327. declare module "babylonjs/Cameras/flyCamera" {
  38328. import { Scene } from "babylonjs/scene";
  38329. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38331. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38332. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38333. /**
  38334. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38335. * such as in a 3D Space Shooter or a Flight Simulator.
  38336. */
  38337. export class FlyCamera extends TargetCamera {
  38338. /**
  38339. * Define the collision ellipsoid of the camera.
  38340. * This is helpful for simulating a camera body, like a player's body.
  38341. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38342. */
  38343. ellipsoid: Vector3;
  38344. /**
  38345. * Define an offset for the position of the ellipsoid around the camera.
  38346. * This can be helpful if the camera is attached away from the player's body center,
  38347. * such as at its head.
  38348. */
  38349. ellipsoidOffset: Vector3;
  38350. /**
  38351. * Enable or disable collisions of the camera with the rest of the scene objects.
  38352. */
  38353. checkCollisions: boolean;
  38354. /**
  38355. * Enable or disable gravity on the camera.
  38356. */
  38357. applyGravity: boolean;
  38358. /**
  38359. * Define the current direction the camera is moving to.
  38360. */
  38361. cameraDirection: Vector3;
  38362. /**
  38363. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38364. * This overrides and empties cameraRotation.
  38365. */
  38366. rotationQuaternion: Quaternion;
  38367. /**
  38368. * Track Roll to maintain the wanted Rolling when looking around.
  38369. */
  38370. _trackRoll: number;
  38371. /**
  38372. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38373. */
  38374. rollCorrect: number;
  38375. /**
  38376. * Mimic a banked turn, Rolling the camera when Yawing.
  38377. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38378. */
  38379. bankedTurn: boolean;
  38380. /**
  38381. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38382. */
  38383. bankedTurnLimit: number;
  38384. /**
  38385. * Value of 0 disables the banked Roll.
  38386. * Value of 1 is equal to the Yaw angle in radians.
  38387. */
  38388. bankedTurnMultiplier: number;
  38389. /**
  38390. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38391. */
  38392. inputs: FlyCameraInputsManager;
  38393. /**
  38394. * Gets the input sensibility for mouse input.
  38395. * Higher values reduce sensitivity.
  38396. */
  38397. /**
  38398. * Sets the input sensibility for a mouse input.
  38399. * Higher values reduce sensitivity.
  38400. */
  38401. angularSensibility: number;
  38402. /**
  38403. * Get the keys for camera movement forward.
  38404. */
  38405. /**
  38406. * Set the keys for camera movement forward.
  38407. */
  38408. keysForward: number[];
  38409. /**
  38410. * Get the keys for camera movement backward.
  38411. */
  38412. keysBackward: number[];
  38413. /**
  38414. * Get the keys for camera movement up.
  38415. */
  38416. /**
  38417. * Set the keys for camera movement up.
  38418. */
  38419. keysUp: number[];
  38420. /**
  38421. * Get the keys for camera movement down.
  38422. */
  38423. /**
  38424. * Set the keys for camera movement down.
  38425. */
  38426. keysDown: number[];
  38427. /**
  38428. * Get the keys for camera movement left.
  38429. */
  38430. /**
  38431. * Set the keys for camera movement left.
  38432. */
  38433. keysLeft: number[];
  38434. /**
  38435. * Set the keys for camera movement right.
  38436. */
  38437. /**
  38438. * Set the keys for camera movement right.
  38439. */
  38440. keysRight: number[];
  38441. /**
  38442. * Event raised when the camera collides with a mesh in the scene.
  38443. */
  38444. onCollide: (collidedMesh: AbstractMesh) => void;
  38445. private _collider;
  38446. private _needMoveForGravity;
  38447. private _oldPosition;
  38448. private _diffPosition;
  38449. private _newPosition;
  38450. /** @hidden */
  38451. _localDirection: Vector3;
  38452. /** @hidden */
  38453. _transformedDirection: Vector3;
  38454. /**
  38455. * Instantiates a FlyCamera.
  38456. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38457. * such as in a 3D Space Shooter or a Flight Simulator.
  38458. * @param name Define the name of the camera in the scene.
  38459. * @param position Define the starting position of the camera in the scene.
  38460. * @param scene Define the scene the camera belongs to.
  38461. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38462. */
  38463. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38464. /**
  38465. * Attach a control to the HTML DOM element.
  38466. * @param element Defines the element that listens to the input events.
  38467. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38468. */
  38469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38470. /**
  38471. * Detach a control from the HTML DOM element.
  38472. * The camera will stop reacting to that input.
  38473. * @param element Defines the element that listens to the input events.
  38474. */
  38475. detachControl(element: HTMLElement): void;
  38476. private _collisionMask;
  38477. /**
  38478. * Get the mask that the camera ignores in collision events.
  38479. */
  38480. /**
  38481. * Set the mask that the camera ignores in collision events.
  38482. */
  38483. collisionMask: number;
  38484. /** @hidden */
  38485. _collideWithWorld(displacement: Vector3): void;
  38486. /** @hidden */
  38487. private _onCollisionPositionChange;
  38488. /** @hidden */
  38489. _checkInputs(): void;
  38490. /** @hidden */
  38491. _decideIfNeedsToMove(): boolean;
  38492. /** @hidden */
  38493. _updatePosition(): void;
  38494. /**
  38495. * Restore the Roll to its target value at the rate specified.
  38496. * @param rate - Higher means slower restoring.
  38497. * @hidden
  38498. */
  38499. restoreRoll(rate: number): void;
  38500. /**
  38501. * Destroy the camera and release the current resources held by it.
  38502. */
  38503. dispose(): void;
  38504. /**
  38505. * Get the current object class name.
  38506. * @returns the class name.
  38507. */
  38508. getClassName(): string;
  38509. }
  38510. }
  38511. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38512. import { Nullable } from "babylonjs/types";
  38513. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38514. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38515. /**
  38516. * Listen to keyboard events to control the camera.
  38517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38518. */
  38519. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38520. /**
  38521. * Defines the camera the input is attached to.
  38522. */
  38523. camera: FlyCamera;
  38524. /**
  38525. * The list of keyboard keys used to control the forward move of the camera.
  38526. */
  38527. keysForward: number[];
  38528. /**
  38529. * The list of keyboard keys used to control the backward move of the camera.
  38530. */
  38531. keysBackward: number[];
  38532. /**
  38533. * The list of keyboard keys used to control the forward move of the camera.
  38534. */
  38535. keysUp: number[];
  38536. /**
  38537. * The list of keyboard keys used to control the backward move of the camera.
  38538. */
  38539. keysDown: number[];
  38540. /**
  38541. * The list of keyboard keys used to control the right strafe move of the camera.
  38542. */
  38543. keysRight: number[];
  38544. /**
  38545. * The list of keyboard keys used to control the left strafe move of the camera.
  38546. */
  38547. keysLeft: number[];
  38548. private _keys;
  38549. private _onCanvasBlurObserver;
  38550. private _onKeyboardObserver;
  38551. private _engine;
  38552. private _scene;
  38553. /**
  38554. * Attach the input controls to a specific dom element to get the input from.
  38555. * @param element Defines the element the controls should be listened from
  38556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38557. */
  38558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38559. /**
  38560. * Detach the current controls from the specified dom element.
  38561. * @param element Defines the element to stop listening the inputs from
  38562. */
  38563. detachControl(element: Nullable<HTMLElement>): void;
  38564. /**
  38565. * Gets the class name of the current intput.
  38566. * @returns the class name
  38567. */
  38568. getClassName(): string;
  38569. /** @hidden */
  38570. _onLostFocus(e: FocusEvent): void;
  38571. /**
  38572. * Get the friendly name associated with the input class.
  38573. * @returns the input friendly name
  38574. */
  38575. getSimpleName(): string;
  38576. /**
  38577. * Update the current camera state depending on the inputs that have been used this frame.
  38578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38579. */
  38580. checkInputs(): void;
  38581. }
  38582. }
  38583. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38584. import { Nullable } from "babylonjs/types";
  38585. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38587. /**
  38588. * Manage the mouse wheel inputs to control a follow camera.
  38589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38590. */
  38591. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38592. /**
  38593. * Defines the camera the input is attached to.
  38594. */
  38595. camera: FollowCamera;
  38596. /**
  38597. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38598. */
  38599. axisControlRadius: boolean;
  38600. /**
  38601. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38602. */
  38603. axisControlHeight: boolean;
  38604. /**
  38605. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38606. */
  38607. axisControlRotation: boolean;
  38608. /**
  38609. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38610. * relation to mouseWheel events.
  38611. */
  38612. wheelPrecision: number;
  38613. /**
  38614. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38615. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38616. */
  38617. wheelDeltaPercentage: number;
  38618. private _wheel;
  38619. private _observer;
  38620. /**
  38621. * Attach the input controls to a specific dom element to get the input from.
  38622. * @param element Defines the element the controls should be listened from
  38623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38624. */
  38625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38626. /**
  38627. * Detach the current controls from the specified dom element.
  38628. * @param element Defines the element to stop listening the inputs from
  38629. */
  38630. detachControl(element: Nullable<HTMLElement>): void;
  38631. /**
  38632. * Gets the class name of the current intput.
  38633. * @returns the class name
  38634. */
  38635. getClassName(): string;
  38636. /**
  38637. * Get the friendly name associated with the input class.
  38638. * @returns the input friendly name
  38639. */
  38640. getSimpleName(): string;
  38641. }
  38642. }
  38643. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38644. import { Nullable } from "babylonjs/types";
  38645. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38646. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38647. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38648. /**
  38649. * Manage the pointers inputs to control an follow camera.
  38650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38651. */
  38652. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38653. /**
  38654. * Defines the camera the input is attached to.
  38655. */
  38656. camera: FollowCamera;
  38657. /**
  38658. * Gets the class name of the current input.
  38659. * @returns the class name
  38660. */
  38661. getClassName(): string;
  38662. /**
  38663. * Defines the pointer angular sensibility along the X axis or how fast is
  38664. * the camera rotating.
  38665. * A negative number will reverse the axis direction.
  38666. */
  38667. angularSensibilityX: number;
  38668. /**
  38669. * Defines the pointer angular sensibility along the Y axis or how fast is
  38670. * the camera rotating.
  38671. * A negative number will reverse the axis direction.
  38672. */
  38673. angularSensibilityY: number;
  38674. /**
  38675. * Defines the pointer pinch precision or how fast is the camera zooming.
  38676. * A negative number will reverse the axis direction.
  38677. */
  38678. pinchPrecision: number;
  38679. /**
  38680. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38681. * from 0.
  38682. * It defines the percentage of current camera.radius to use as delta when
  38683. * pinch zoom is used.
  38684. */
  38685. pinchDeltaPercentage: number;
  38686. /**
  38687. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38688. */
  38689. axisXControlRadius: boolean;
  38690. /**
  38691. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38692. */
  38693. axisXControlHeight: boolean;
  38694. /**
  38695. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38696. */
  38697. axisXControlRotation: boolean;
  38698. /**
  38699. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38700. */
  38701. axisYControlRadius: boolean;
  38702. /**
  38703. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38704. */
  38705. axisYControlHeight: boolean;
  38706. /**
  38707. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38708. */
  38709. axisYControlRotation: boolean;
  38710. /**
  38711. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38712. */
  38713. axisPinchControlRadius: boolean;
  38714. /**
  38715. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38716. */
  38717. axisPinchControlHeight: boolean;
  38718. /**
  38719. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38720. */
  38721. axisPinchControlRotation: boolean;
  38722. /**
  38723. * Log error messages if basic misconfiguration has occurred.
  38724. */
  38725. warningEnable: boolean;
  38726. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38727. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38728. private _warningCounter;
  38729. private _warning;
  38730. }
  38731. }
  38732. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38733. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38734. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38735. /**
  38736. * Default Inputs manager for the FollowCamera.
  38737. * It groups all the default supported inputs for ease of use.
  38738. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38739. */
  38740. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38741. /**
  38742. * Instantiates a new FollowCameraInputsManager.
  38743. * @param camera Defines the camera the inputs belong to
  38744. */
  38745. constructor(camera: FollowCamera);
  38746. /**
  38747. * Add keyboard input support to the input manager.
  38748. * @returns the current input manager
  38749. */
  38750. addKeyboard(): FollowCameraInputsManager;
  38751. /**
  38752. * Add mouse wheel input support to the input manager.
  38753. * @returns the current input manager
  38754. */
  38755. addMouseWheel(): FollowCameraInputsManager;
  38756. /**
  38757. * Add pointers input support to the input manager.
  38758. * @returns the current input manager
  38759. */
  38760. addPointers(): FollowCameraInputsManager;
  38761. /**
  38762. * Add orientation input support to the input manager.
  38763. * @returns the current input manager
  38764. */
  38765. addVRDeviceOrientation(): FollowCameraInputsManager;
  38766. }
  38767. }
  38768. declare module "babylonjs/Cameras/followCamera" {
  38769. import { Nullable } from "babylonjs/types";
  38770. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38771. import { Scene } from "babylonjs/scene";
  38772. import { Vector3 } from "babylonjs/Maths/math.vector";
  38773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38774. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38775. /**
  38776. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38777. * an arc rotate version arcFollowCamera are available.
  38778. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38779. */
  38780. export class FollowCamera extends TargetCamera {
  38781. /**
  38782. * Distance the follow camera should follow an object at
  38783. */
  38784. radius: number;
  38785. /**
  38786. * Minimum allowed distance of the camera to the axis of rotation
  38787. * (The camera can not get closer).
  38788. * This can help limiting how the Camera is able to move in the scene.
  38789. */
  38790. lowerRadiusLimit: Nullable<number>;
  38791. /**
  38792. * Maximum allowed distance of the camera to the axis of rotation
  38793. * (The camera can not get further).
  38794. * This can help limiting how the Camera is able to move in the scene.
  38795. */
  38796. upperRadiusLimit: Nullable<number>;
  38797. /**
  38798. * Define a rotation offset between the camera and the object it follows
  38799. */
  38800. rotationOffset: number;
  38801. /**
  38802. * Minimum allowed angle to camera position relative to target object.
  38803. * This can help limiting how the Camera is able to move in the scene.
  38804. */
  38805. lowerRotationOffsetLimit: Nullable<number>;
  38806. /**
  38807. * Maximum allowed angle to camera position relative to target object.
  38808. * This can help limiting how the Camera is able to move in the scene.
  38809. */
  38810. upperRotationOffsetLimit: Nullable<number>;
  38811. /**
  38812. * Define a height offset between the camera and the object it follows.
  38813. * It can help following an object from the top (like a car chaing a plane)
  38814. */
  38815. heightOffset: number;
  38816. /**
  38817. * Minimum allowed height of camera position relative to target object.
  38818. * This can help limiting how the Camera is able to move in the scene.
  38819. */
  38820. lowerHeightOffsetLimit: Nullable<number>;
  38821. /**
  38822. * Maximum allowed height of camera position relative to target object.
  38823. * This can help limiting how the Camera is able to move in the scene.
  38824. */
  38825. upperHeightOffsetLimit: Nullable<number>;
  38826. /**
  38827. * Define how fast the camera can accelerate to follow it s target.
  38828. */
  38829. cameraAcceleration: number;
  38830. /**
  38831. * Define the speed limit of the camera following an object.
  38832. */
  38833. maxCameraSpeed: number;
  38834. /**
  38835. * Define the target of the camera.
  38836. */
  38837. lockedTarget: Nullable<AbstractMesh>;
  38838. /**
  38839. * Defines the input associated with the camera.
  38840. */
  38841. inputs: FollowCameraInputsManager;
  38842. /**
  38843. * Instantiates the follow camera.
  38844. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38845. * @param name Define the name of the camera in the scene
  38846. * @param position Define the position of the camera
  38847. * @param scene Define the scene the camera belong to
  38848. * @param lockedTarget Define the target of the camera
  38849. */
  38850. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38851. private _follow;
  38852. /**
  38853. * Attached controls to the current camera.
  38854. * @param element Defines the element the controls should be listened from
  38855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38856. */
  38857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38858. /**
  38859. * Detach the current controls from the camera.
  38860. * The camera will stop reacting to inputs.
  38861. * @param element Defines the element to stop listening the inputs from
  38862. */
  38863. detachControl(element: HTMLElement): void;
  38864. /** @hidden */
  38865. _checkInputs(): void;
  38866. private _checkLimits;
  38867. /**
  38868. * Gets the camera class name.
  38869. * @returns the class name
  38870. */
  38871. getClassName(): string;
  38872. }
  38873. /**
  38874. * Arc Rotate version of the follow camera.
  38875. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38876. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38877. */
  38878. export class ArcFollowCamera extends TargetCamera {
  38879. /** The longitudinal angle of the camera */
  38880. alpha: number;
  38881. /** The latitudinal angle of the camera */
  38882. beta: number;
  38883. /** The radius of the camera from its target */
  38884. radius: number;
  38885. /** Define the camera target (the messh it should follow) */
  38886. target: Nullable<AbstractMesh>;
  38887. private _cartesianCoordinates;
  38888. /**
  38889. * Instantiates a new ArcFollowCamera
  38890. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38891. * @param name Define the name of the camera
  38892. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38893. * @param beta Define the rotation angle of the camera around the elevation axis
  38894. * @param radius Define the radius of the camera from its target point
  38895. * @param target Define the target of the camera
  38896. * @param scene Define the scene the camera belongs to
  38897. */
  38898. constructor(name: string,
  38899. /** The longitudinal angle of the camera */
  38900. alpha: number,
  38901. /** The latitudinal angle of the camera */
  38902. beta: number,
  38903. /** The radius of the camera from its target */
  38904. radius: number,
  38905. /** Define the camera target (the messh it should follow) */
  38906. target: Nullable<AbstractMesh>, scene: Scene);
  38907. private _follow;
  38908. /** @hidden */
  38909. _checkInputs(): void;
  38910. /**
  38911. * Returns the class name of the object.
  38912. * It is mostly used internally for serialization purposes.
  38913. */
  38914. getClassName(): string;
  38915. }
  38916. }
  38917. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38918. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38919. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38920. import { Nullable } from "babylonjs/types";
  38921. /**
  38922. * Manage the keyboard inputs to control the movement of a follow camera.
  38923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38924. */
  38925. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38926. /**
  38927. * Defines the camera the input is attached to.
  38928. */
  38929. camera: FollowCamera;
  38930. /**
  38931. * Defines the list of key codes associated with the up action (increase heightOffset)
  38932. */
  38933. keysHeightOffsetIncr: number[];
  38934. /**
  38935. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38936. */
  38937. keysHeightOffsetDecr: number[];
  38938. /**
  38939. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38940. */
  38941. keysHeightOffsetModifierAlt: boolean;
  38942. /**
  38943. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38944. */
  38945. keysHeightOffsetModifierCtrl: boolean;
  38946. /**
  38947. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38948. */
  38949. keysHeightOffsetModifierShift: boolean;
  38950. /**
  38951. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38952. */
  38953. keysRotationOffsetIncr: number[];
  38954. /**
  38955. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38956. */
  38957. keysRotationOffsetDecr: number[];
  38958. /**
  38959. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38960. */
  38961. keysRotationOffsetModifierAlt: boolean;
  38962. /**
  38963. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38964. */
  38965. keysRotationOffsetModifierCtrl: boolean;
  38966. /**
  38967. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38968. */
  38969. keysRotationOffsetModifierShift: boolean;
  38970. /**
  38971. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38972. */
  38973. keysRadiusIncr: number[];
  38974. /**
  38975. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38976. */
  38977. keysRadiusDecr: number[];
  38978. /**
  38979. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38980. */
  38981. keysRadiusModifierAlt: boolean;
  38982. /**
  38983. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38984. */
  38985. keysRadiusModifierCtrl: boolean;
  38986. /**
  38987. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38988. */
  38989. keysRadiusModifierShift: boolean;
  38990. /**
  38991. * Defines the rate of change of heightOffset.
  38992. */
  38993. heightSensibility: number;
  38994. /**
  38995. * Defines the rate of change of rotationOffset.
  38996. */
  38997. rotationSensibility: number;
  38998. /**
  38999. * Defines the rate of change of radius.
  39000. */
  39001. radiusSensibility: number;
  39002. private _keys;
  39003. private _ctrlPressed;
  39004. private _altPressed;
  39005. private _shiftPressed;
  39006. private _onCanvasBlurObserver;
  39007. private _onKeyboardObserver;
  39008. private _engine;
  39009. private _scene;
  39010. /**
  39011. * Attach the input controls to a specific dom element to get the input from.
  39012. * @param element Defines the element the controls should be listened from
  39013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39014. */
  39015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39016. /**
  39017. * Detach the current controls from the specified dom element.
  39018. * @param element Defines the element to stop listening the inputs from
  39019. */
  39020. detachControl(element: Nullable<HTMLElement>): void;
  39021. /**
  39022. * Update the current camera state depending on the inputs that have been used this frame.
  39023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39024. */
  39025. checkInputs(): void;
  39026. /**
  39027. * Gets the class name of the current input.
  39028. * @returns the class name
  39029. */
  39030. getClassName(): string;
  39031. /**
  39032. * Get the friendly name associated with the input class.
  39033. * @returns the input friendly name
  39034. */
  39035. getSimpleName(): string;
  39036. /**
  39037. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39038. * allow modification of the heightOffset value.
  39039. */
  39040. private _modifierHeightOffset;
  39041. /**
  39042. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39043. * allow modification of the rotationOffset value.
  39044. */
  39045. private _modifierRotationOffset;
  39046. /**
  39047. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39048. * allow modification of the radius value.
  39049. */
  39050. private _modifierRadius;
  39051. }
  39052. }
  39053. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39054. import { Nullable } from "babylonjs/types";
  39055. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39057. import { Observable } from "babylonjs/Misc/observable";
  39058. module "babylonjs/Cameras/freeCameraInputsManager" {
  39059. interface FreeCameraInputsManager {
  39060. /**
  39061. * @hidden
  39062. */
  39063. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39064. /**
  39065. * Add orientation input support to the input manager.
  39066. * @returns the current input manager
  39067. */
  39068. addDeviceOrientation(): FreeCameraInputsManager;
  39069. }
  39070. }
  39071. /**
  39072. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39073. * Screen rotation is taken into account.
  39074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39075. */
  39076. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39077. private _camera;
  39078. private _screenOrientationAngle;
  39079. private _constantTranform;
  39080. private _screenQuaternion;
  39081. private _alpha;
  39082. private _beta;
  39083. private _gamma;
  39084. /**
  39085. * Can be used to detect if a device orientation sensor is availible on a device
  39086. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39087. * @returns a promise that will resolve on orientation change
  39088. */
  39089. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39090. /**
  39091. * @hidden
  39092. */
  39093. _onDeviceOrientationChangedObservable: Observable<void>;
  39094. /**
  39095. * Instantiates a new input
  39096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39097. */
  39098. constructor();
  39099. /**
  39100. * Define the camera controlled by the input.
  39101. */
  39102. camera: FreeCamera;
  39103. /**
  39104. * Attach the input controls to a specific dom element to get the input from.
  39105. * @param element Defines the element the controls should be listened from
  39106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39107. */
  39108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39109. private _orientationChanged;
  39110. private _deviceOrientation;
  39111. /**
  39112. * Detach the current controls from the specified dom element.
  39113. * @param element Defines the element to stop listening the inputs from
  39114. */
  39115. detachControl(element: Nullable<HTMLElement>): void;
  39116. /**
  39117. * Update the current camera state depending on the inputs that have been used this frame.
  39118. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39119. */
  39120. checkInputs(): void;
  39121. /**
  39122. * Gets the class name of the current intput.
  39123. * @returns the class name
  39124. */
  39125. getClassName(): string;
  39126. /**
  39127. * Get the friendly name associated with the input class.
  39128. * @returns the input friendly name
  39129. */
  39130. getSimpleName(): string;
  39131. }
  39132. }
  39133. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39134. import { Nullable } from "babylonjs/types";
  39135. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39137. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39138. /**
  39139. * Manage the gamepad inputs to control a free camera.
  39140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39141. */
  39142. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39143. /**
  39144. * Define the camera the input is attached to.
  39145. */
  39146. camera: FreeCamera;
  39147. /**
  39148. * Define the Gamepad controlling the input
  39149. */
  39150. gamepad: Nullable<Gamepad>;
  39151. /**
  39152. * Defines the gamepad rotation sensiblity.
  39153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39154. */
  39155. gamepadAngularSensibility: number;
  39156. /**
  39157. * Defines the gamepad move sensiblity.
  39158. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39159. */
  39160. gamepadMoveSensibility: number;
  39161. private _onGamepadConnectedObserver;
  39162. private _onGamepadDisconnectedObserver;
  39163. private _cameraTransform;
  39164. private _deltaTransform;
  39165. private _vector3;
  39166. private _vector2;
  39167. /**
  39168. * Attach the input controls to a specific dom element to get the input from.
  39169. * @param element Defines the element the controls should be listened from
  39170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39171. */
  39172. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39173. /**
  39174. * Detach the current controls from the specified dom element.
  39175. * @param element Defines the element to stop listening the inputs from
  39176. */
  39177. detachControl(element: Nullable<HTMLElement>): void;
  39178. /**
  39179. * Update the current camera state depending on the inputs that have been used this frame.
  39180. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39181. */
  39182. checkInputs(): void;
  39183. /**
  39184. * Gets the class name of the current intput.
  39185. * @returns the class name
  39186. */
  39187. getClassName(): string;
  39188. /**
  39189. * Get the friendly name associated with the input class.
  39190. * @returns the input friendly name
  39191. */
  39192. getSimpleName(): string;
  39193. }
  39194. }
  39195. declare module "babylonjs/Misc/virtualJoystick" {
  39196. import { Nullable } from "babylonjs/types";
  39197. import { Vector3 } from "babylonjs/Maths/math.vector";
  39198. /**
  39199. * Defines the potential axis of a Joystick
  39200. */
  39201. export enum JoystickAxis {
  39202. /** X axis */
  39203. X = 0,
  39204. /** Y axis */
  39205. Y = 1,
  39206. /** Z axis */
  39207. Z = 2
  39208. }
  39209. /**
  39210. * Class used to define virtual joystick (used in touch mode)
  39211. */
  39212. export class VirtualJoystick {
  39213. /**
  39214. * Gets or sets a boolean indicating that left and right values must be inverted
  39215. */
  39216. reverseLeftRight: boolean;
  39217. /**
  39218. * Gets or sets a boolean indicating that up and down values must be inverted
  39219. */
  39220. reverseUpDown: boolean;
  39221. /**
  39222. * Gets the offset value for the position (ie. the change of the position value)
  39223. */
  39224. deltaPosition: Vector3;
  39225. /**
  39226. * Gets a boolean indicating if the virtual joystick was pressed
  39227. */
  39228. pressed: boolean;
  39229. /**
  39230. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39231. */
  39232. static Canvas: Nullable<HTMLCanvasElement>;
  39233. private static _globalJoystickIndex;
  39234. private static vjCanvasContext;
  39235. private static vjCanvasWidth;
  39236. private static vjCanvasHeight;
  39237. private static halfWidth;
  39238. private _action;
  39239. private _axisTargetedByLeftAndRight;
  39240. private _axisTargetedByUpAndDown;
  39241. private _joystickSensibility;
  39242. private _inversedSensibility;
  39243. private _joystickPointerID;
  39244. private _joystickColor;
  39245. private _joystickPointerPos;
  39246. private _joystickPreviousPointerPos;
  39247. private _joystickPointerStartPos;
  39248. private _deltaJoystickVector;
  39249. private _leftJoystick;
  39250. private _touches;
  39251. private _onPointerDownHandlerRef;
  39252. private _onPointerMoveHandlerRef;
  39253. private _onPointerUpHandlerRef;
  39254. private _onResize;
  39255. /**
  39256. * Creates a new virtual joystick
  39257. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39258. */
  39259. constructor(leftJoystick?: boolean);
  39260. /**
  39261. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39262. * @param newJoystickSensibility defines the new sensibility
  39263. */
  39264. setJoystickSensibility(newJoystickSensibility: number): void;
  39265. private _onPointerDown;
  39266. private _onPointerMove;
  39267. private _onPointerUp;
  39268. /**
  39269. * Change the color of the virtual joystick
  39270. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39271. */
  39272. setJoystickColor(newColor: string): void;
  39273. /**
  39274. * Defines a callback to call when the joystick is touched
  39275. * @param action defines the callback
  39276. */
  39277. setActionOnTouch(action: () => any): void;
  39278. /**
  39279. * Defines which axis you'd like to control for left & right
  39280. * @param axis defines the axis to use
  39281. */
  39282. setAxisForLeftRight(axis: JoystickAxis): void;
  39283. /**
  39284. * Defines which axis you'd like to control for up & down
  39285. * @param axis defines the axis to use
  39286. */
  39287. setAxisForUpDown(axis: JoystickAxis): void;
  39288. private _drawVirtualJoystick;
  39289. /**
  39290. * Release internal HTML canvas
  39291. */
  39292. releaseCanvas(): void;
  39293. }
  39294. }
  39295. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39296. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39297. import { Nullable } from "babylonjs/types";
  39298. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39299. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39300. module "babylonjs/Cameras/freeCameraInputsManager" {
  39301. interface FreeCameraInputsManager {
  39302. /**
  39303. * Add virtual joystick input support to the input manager.
  39304. * @returns the current input manager
  39305. */
  39306. addVirtualJoystick(): FreeCameraInputsManager;
  39307. }
  39308. }
  39309. /**
  39310. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39312. */
  39313. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39314. /**
  39315. * Defines the camera the input is attached to.
  39316. */
  39317. camera: FreeCamera;
  39318. private _leftjoystick;
  39319. private _rightjoystick;
  39320. /**
  39321. * Gets the left stick of the virtual joystick.
  39322. * @returns The virtual Joystick
  39323. */
  39324. getLeftJoystick(): VirtualJoystick;
  39325. /**
  39326. * Gets the right stick of the virtual joystick.
  39327. * @returns The virtual Joystick
  39328. */
  39329. getRightJoystick(): VirtualJoystick;
  39330. /**
  39331. * Update the current camera state depending on the inputs that have been used this frame.
  39332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39333. */
  39334. checkInputs(): void;
  39335. /**
  39336. * Attach the input controls to a specific dom element to get the input from.
  39337. * @param element Defines the element the controls should be listened from
  39338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39339. */
  39340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39341. /**
  39342. * Detach the current controls from the specified dom element.
  39343. * @param element Defines the element to stop listening the inputs from
  39344. */
  39345. detachControl(element: Nullable<HTMLElement>): void;
  39346. /**
  39347. * Gets the class name of the current intput.
  39348. * @returns the class name
  39349. */
  39350. getClassName(): string;
  39351. /**
  39352. * Get the friendly name associated with the input class.
  39353. * @returns the input friendly name
  39354. */
  39355. getSimpleName(): string;
  39356. }
  39357. }
  39358. declare module "babylonjs/Cameras/Inputs/index" {
  39359. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39360. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39361. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39362. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39363. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39364. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39365. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39366. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39367. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39368. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39369. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39370. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39371. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39372. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39373. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39374. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39375. }
  39376. declare module "babylonjs/Cameras/touchCamera" {
  39377. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39378. import { Scene } from "babylonjs/scene";
  39379. import { Vector3 } from "babylonjs/Maths/math.vector";
  39380. /**
  39381. * This represents a FPS type of camera controlled by touch.
  39382. * This is like a universal camera minus the Gamepad controls.
  39383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39384. */
  39385. export class TouchCamera extends FreeCamera {
  39386. /**
  39387. * Defines the touch sensibility for rotation.
  39388. * The higher the faster.
  39389. */
  39390. touchAngularSensibility: number;
  39391. /**
  39392. * Defines the touch sensibility for move.
  39393. * The higher the faster.
  39394. */
  39395. touchMoveSensibility: number;
  39396. /**
  39397. * Instantiates a new touch camera.
  39398. * This represents a FPS type of camera controlled by touch.
  39399. * This is like a universal camera minus the Gamepad controls.
  39400. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39401. * @param name Define the name of the camera in the scene
  39402. * @param position Define the start position of the camera in the scene
  39403. * @param scene Define the scene the camera belongs to
  39404. */
  39405. constructor(name: string, position: Vector3, scene: Scene);
  39406. /**
  39407. * Gets the current object class name.
  39408. * @return the class name
  39409. */
  39410. getClassName(): string;
  39411. /** @hidden */
  39412. _setupInputs(): void;
  39413. }
  39414. }
  39415. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39416. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39417. import { Scene } from "babylonjs/scene";
  39418. import { Vector3 } from "babylonjs/Maths/math.vector";
  39419. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39420. import { Axis } from "babylonjs/Maths/math.axis";
  39421. /**
  39422. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39423. * being tilted forward or back and left or right.
  39424. */
  39425. export class DeviceOrientationCamera extends FreeCamera {
  39426. private _initialQuaternion;
  39427. private _quaternionCache;
  39428. private _tmpDragQuaternion;
  39429. /**
  39430. * Creates a new device orientation camera
  39431. * @param name The name of the camera
  39432. * @param position The start position camera
  39433. * @param scene The scene the camera belongs to
  39434. */
  39435. constructor(name: string, position: Vector3, scene: Scene);
  39436. /**
  39437. * @hidden
  39438. * Disabled pointer input on first orientation sensor update (Default: true)
  39439. */
  39440. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39441. private _dragFactor;
  39442. /**
  39443. * Enabled turning on the y axis when the orientation sensor is active
  39444. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39445. */
  39446. enableHorizontalDragging(dragFactor?: number): void;
  39447. /**
  39448. * Gets the current instance class name ("DeviceOrientationCamera").
  39449. * This helps avoiding instanceof at run time.
  39450. * @returns the class name
  39451. */
  39452. getClassName(): string;
  39453. /**
  39454. * @hidden
  39455. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39456. */
  39457. _checkInputs(): void;
  39458. /**
  39459. * Reset the camera to its default orientation on the specified axis only.
  39460. * @param axis The axis to reset
  39461. */
  39462. resetToCurrentRotation(axis?: Axis): void;
  39463. }
  39464. }
  39465. declare module "babylonjs/Gamepads/xboxGamepad" {
  39466. import { Observable } from "babylonjs/Misc/observable";
  39467. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39468. /**
  39469. * Defines supported buttons for XBox360 compatible gamepads
  39470. */
  39471. export enum Xbox360Button {
  39472. /** A */
  39473. A = 0,
  39474. /** B */
  39475. B = 1,
  39476. /** X */
  39477. X = 2,
  39478. /** Y */
  39479. Y = 3,
  39480. /** Start */
  39481. Start = 4,
  39482. /** Back */
  39483. Back = 5,
  39484. /** Left button */
  39485. LB = 6,
  39486. /** Right button */
  39487. RB = 7,
  39488. /** Left stick */
  39489. LeftStick = 8,
  39490. /** Right stick */
  39491. RightStick = 9
  39492. }
  39493. /** Defines values for XBox360 DPad */
  39494. export enum Xbox360Dpad {
  39495. /** Up */
  39496. Up = 0,
  39497. /** Down */
  39498. Down = 1,
  39499. /** Left */
  39500. Left = 2,
  39501. /** Right */
  39502. Right = 3
  39503. }
  39504. /**
  39505. * Defines a XBox360 gamepad
  39506. */
  39507. export class Xbox360Pad extends Gamepad {
  39508. private _leftTrigger;
  39509. private _rightTrigger;
  39510. private _onlefttriggerchanged;
  39511. private _onrighttriggerchanged;
  39512. private _onbuttondown;
  39513. private _onbuttonup;
  39514. private _ondpaddown;
  39515. private _ondpadup;
  39516. /** Observable raised when a button is pressed */
  39517. onButtonDownObservable: Observable<Xbox360Button>;
  39518. /** Observable raised when a button is released */
  39519. onButtonUpObservable: Observable<Xbox360Button>;
  39520. /** Observable raised when a pad is pressed */
  39521. onPadDownObservable: Observable<Xbox360Dpad>;
  39522. /** Observable raised when a pad is released */
  39523. onPadUpObservable: Observable<Xbox360Dpad>;
  39524. private _buttonA;
  39525. private _buttonB;
  39526. private _buttonX;
  39527. private _buttonY;
  39528. private _buttonBack;
  39529. private _buttonStart;
  39530. private _buttonLB;
  39531. private _buttonRB;
  39532. private _buttonLeftStick;
  39533. private _buttonRightStick;
  39534. private _dPadUp;
  39535. private _dPadDown;
  39536. private _dPadLeft;
  39537. private _dPadRight;
  39538. private _isXboxOnePad;
  39539. /**
  39540. * Creates a new XBox360 gamepad object
  39541. * @param id defines the id of this gamepad
  39542. * @param index defines its index
  39543. * @param gamepad defines the internal HTML gamepad object
  39544. * @param xboxOne defines if it is a XBox One gamepad
  39545. */
  39546. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39547. /**
  39548. * Defines the callback to call when left trigger is pressed
  39549. * @param callback defines the callback to use
  39550. */
  39551. onlefttriggerchanged(callback: (value: number) => void): void;
  39552. /**
  39553. * Defines the callback to call when right trigger is pressed
  39554. * @param callback defines the callback to use
  39555. */
  39556. onrighttriggerchanged(callback: (value: number) => void): void;
  39557. /**
  39558. * Gets the left trigger value
  39559. */
  39560. /**
  39561. * Sets the left trigger value
  39562. */
  39563. leftTrigger: number;
  39564. /**
  39565. * Gets the right trigger value
  39566. */
  39567. /**
  39568. * Sets the right trigger value
  39569. */
  39570. rightTrigger: number;
  39571. /**
  39572. * Defines the callback to call when a button is pressed
  39573. * @param callback defines the callback to use
  39574. */
  39575. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39576. /**
  39577. * Defines the callback to call when a button is released
  39578. * @param callback defines the callback to use
  39579. */
  39580. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39581. /**
  39582. * Defines the callback to call when a pad is pressed
  39583. * @param callback defines the callback to use
  39584. */
  39585. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39586. /**
  39587. * Defines the callback to call when a pad is released
  39588. * @param callback defines the callback to use
  39589. */
  39590. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39591. private _setButtonValue;
  39592. private _setDPadValue;
  39593. /**
  39594. * Gets the value of the `A` button
  39595. */
  39596. /**
  39597. * Sets the value of the `A` button
  39598. */
  39599. buttonA: number;
  39600. /**
  39601. * Gets the value of the `B` button
  39602. */
  39603. /**
  39604. * Sets the value of the `B` button
  39605. */
  39606. buttonB: number;
  39607. /**
  39608. * Gets the value of the `X` button
  39609. */
  39610. /**
  39611. * Sets the value of the `X` button
  39612. */
  39613. buttonX: number;
  39614. /**
  39615. * Gets the value of the `Y` button
  39616. */
  39617. /**
  39618. * Sets the value of the `Y` button
  39619. */
  39620. buttonY: number;
  39621. /**
  39622. * Gets the value of the `Start` button
  39623. */
  39624. /**
  39625. * Sets the value of the `Start` button
  39626. */
  39627. buttonStart: number;
  39628. /**
  39629. * Gets the value of the `Back` button
  39630. */
  39631. /**
  39632. * Sets the value of the `Back` button
  39633. */
  39634. buttonBack: number;
  39635. /**
  39636. * Gets the value of the `Left` button
  39637. */
  39638. /**
  39639. * Sets the value of the `Left` button
  39640. */
  39641. buttonLB: number;
  39642. /**
  39643. * Gets the value of the `Right` button
  39644. */
  39645. /**
  39646. * Sets the value of the `Right` button
  39647. */
  39648. buttonRB: number;
  39649. /**
  39650. * Gets the value of the Left joystick
  39651. */
  39652. /**
  39653. * Sets the value of the Left joystick
  39654. */
  39655. buttonLeftStick: number;
  39656. /**
  39657. * Gets the value of the Right joystick
  39658. */
  39659. /**
  39660. * Sets the value of the Right joystick
  39661. */
  39662. buttonRightStick: number;
  39663. /**
  39664. * Gets the value of D-pad up
  39665. */
  39666. /**
  39667. * Sets the value of D-pad up
  39668. */
  39669. dPadUp: number;
  39670. /**
  39671. * Gets the value of D-pad down
  39672. */
  39673. /**
  39674. * Sets the value of D-pad down
  39675. */
  39676. dPadDown: number;
  39677. /**
  39678. * Gets the value of D-pad left
  39679. */
  39680. /**
  39681. * Sets the value of D-pad left
  39682. */
  39683. dPadLeft: number;
  39684. /**
  39685. * Gets the value of D-pad right
  39686. */
  39687. /**
  39688. * Sets the value of D-pad right
  39689. */
  39690. dPadRight: number;
  39691. /**
  39692. * Force the gamepad to synchronize with device values
  39693. */
  39694. update(): void;
  39695. /**
  39696. * Disposes the gamepad
  39697. */
  39698. dispose(): void;
  39699. }
  39700. }
  39701. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39702. import { Observable } from "babylonjs/Misc/observable";
  39703. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39704. /**
  39705. * Defines supported buttons for DualShock compatible gamepads
  39706. */
  39707. export enum DualShockButton {
  39708. /** Cross */
  39709. Cross = 0,
  39710. /** Circle */
  39711. Circle = 1,
  39712. /** Square */
  39713. Square = 2,
  39714. /** Triangle */
  39715. Triangle = 3,
  39716. /** Options */
  39717. Options = 4,
  39718. /** Share */
  39719. Share = 5,
  39720. /** L1 */
  39721. L1 = 6,
  39722. /** R1 */
  39723. R1 = 7,
  39724. /** Left stick */
  39725. LeftStick = 8,
  39726. /** Right stick */
  39727. RightStick = 9
  39728. }
  39729. /** Defines values for DualShock DPad */
  39730. export enum DualShockDpad {
  39731. /** Up */
  39732. Up = 0,
  39733. /** Down */
  39734. Down = 1,
  39735. /** Left */
  39736. Left = 2,
  39737. /** Right */
  39738. Right = 3
  39739. }
  39740. /**
  39741. * Defines a DualShock gamepad
  39742. */
  39743. export class DualShockPad extends Gamepad {
  39744. private _leftTrigger;
  39745. private _rightTrigger;
  39746. private _onlefttriggerchanged;
  39747. private _onrighttriggerchanged;
  39748. private _onbuttondown;
  39749. private _onbuttonup;
  39750. private _ondpaddown;
  39751. private _ondpadup;
  39752. /** Observable raised when a button is pressed */
  39753. onButtonDownObservable: Observable<DualShockButton>;
  39754. /** Observable raised when a button is released */
  39755. onButtonUpObservable: Observable<DualShockButton>;
  39756. /** Observable raised when a pad is pressed */
  39757. onPadDownObservable: Observable<DualShockDpad>;
  39758. /** Observable raised when a pad is released */
  39759. onPadUpObservable: Observable<DualShockDpad>;
  39760. private _buttonCross;
  39761. private _buttonCircle;
  39762. private _buttonSquare;
  39763. private _buttonTriangle;
  39764. private _buttonShare;
  39765. private _buttonOptions;
  39766. private _buttonL1;
  39767. private _buttonR1;
  39768. private _buttonLeftStick;
  39769. private _buttonRightStick;
  39770. private _dPadUp;
  39771. private _dPadDown;
  39772. private _dPadLeft;
  39773. private _dPadRight;
  39774. /**
  39775. * Creates a new DualShock gamepad object
  39776. * @param id defines the id of this gamepad
  39777. * @param index defines its index
  39778. * @param gamepad defines the internal HTML gamepad object
  39779. */
  39780. constructor(id: string, index: number, gamepad: any);
  39781. /**
  39782. * Defines the callback to call when left trigger is pressed
  39783. * @param callback defines the callback to use
  39784. */
  39785. onlefttriggerchanged(callback: (value: number) => void): void;
  39786. /**
  39787. * Defines the callback to call when right trigger is pressed
  39788. * @param callback defines the callback to use
  39789. */
  39790. onrighttriggerchanged(callback: (value: number) => void): void;
  39791. /**
  39792. * Gets the left trigger value
  39793. */
  39794. /**
  39795. * Sets the left trigger value
  39796. */
  39797. leftTrigger: number;
  39798. /**
  39799. * Gets the right trigger value
  39800. */
  39801. /**
  39802. * Sets the right trigger value
  39803. */
  39804. rightTrigger: number;
  39805. /**
  39806. * Defines the callback to call when a button is pressed
  39807. * @param callback defines the callback to use
  39808. */
  39809. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  39810. /**
  39811. * Defines the callback to call when a button is released
  39812. * @param callback defines the callback to use
  39813. */
  39814. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39815. /**
  39816. * Defines the callback to call when a pad is pressed
  39817. * @param callback defines the callback to use
  39818. */
  39819. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39820. /**
  39821. * Defines the callback to call when a pad is released
  39822. * @param callback defines the callback to use
  39823. */
  39824. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39825. private _setButtonValue;
  39826. private _setDPadValue;
  39827. /**
  39828. * Gets the value of the `Cross` button
  39829. */
  39830. /**
  39831. * Sets the value of the `Cross` button
  39832. */
  39833. buttonCross: number;
  39834. /**
  39835. * Gets the value of the `Circle` button
  39836. */
  39837. /**
  39838. * Sets the value of the `Circle` button
  39839. */
  39840. buttonCircle: number;
  39841. /**
  39842. * Gets the value of the `Square` button
  39843. */
  39844. /**
  39845. * Sets the value of the `Square` button
  39846. */
  39847. buttonSquare: number;
  39848. /**
  39849. * Gets the value of the `Triangle` button
  39850. */
  39851. /**
  39852. * Sets the value of the `Triangle` button
  39853. */
  39854. buttonTriangle: number;
  39855. /**
  39856. * Gets the value of the `Options` button
  39857. */
  39858. /**
  39859. * Sets the value of the `Options` button
  39860. */
  39861. buttonOptions: number;
  39862. /**
  39863. * Gets the value of the `Share` button
  39864. */
  39865. /**
  39866. * Sets the value of the `Share` button
  39867. */
  39868. buttonShare: number;
  39869. /**
  39870. * Gets the value of the `L1` button
  39871. */
  39872. /**
  39873. * Sets the value of the `L1` button
  39874. */
  39875. buttonL1: number;
  39876. /**
  39877. * Gets the value of the `R1` button
  39878. */
  39879. /**
  39880. * Sets the value of the `R1` button
  39881. */
  39882. buttonR1: number;
  39883. /**
  39884. * Gets the value of the Left joystick
  39885. */
  39886. /**
  39887. * Sets the value of the Left joystick
  39888. */
  39889. buttonLeftStick: number;
  39890. /**
  39891. * Gets the value of the Right joystick
  39892. */
  39893. /**
  39894. * Sets the value of the Right joystick
  39895. */
  39896. buttonRightStick: number;
  39897. /**
  39898. * Gets the value of D-pad up
  39899. */
  39900. /**
  39901. * Sets the value of D-pad up
  39902. */
  39903. dPadUp: number;
  39904. /**
  39905. * Gets the value of D-pad down
  39906. */
  39907. /**
  39908. * Sets the value of D-pad down
  39909. */
  39910. dPadDown: number;
  39911. /**
  39912. * Gets the value of D-pad left
  39913. */
  39914. /**
  39915. * Sets the value of D-pad left
  39916. */
  39917. dPadLeft: number;
  39918. /**
  39919. * Gets the value of D-pad right
  39920. */
  39921. /**
  39922. * Sets the value of D-pad right
  39923. */
  39924. dPadRight: number;
  39925. /**
  39926. * Force the gamepad to synchronize with device values
  39927. */
  39928. update(): void;
  39929. /**
  39930. * Disposes the gamepad
  39931. */
  39932. dispose(): void;
  39933. }
  39934. }
  39935. declare module "babylonjs/Gamepads/gamepadManager" {
  39936. import { Observable } from "babylonjs/Misc/observable";
  39937. import { Nullable } from "babylonjs/types";
  39938. import { Scene } from "babylonjs/scene";
  39939. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39940. /**
  39941. * Manager for handling gamepads
  39942. */
  39943. export class GamepadManager {
  39944. private _scene?;
  39945. private _babylonGamepads;
  39946. private _oneGamepadConnected;
  39947. /** @hidden */
  39948. _isMonitoring: boolean;
  39949. private _gamepadEventSupported;
  39950. private _gamepadSupport;
  39951. /**
  39952. * observable to be triggered when the gamepad controller has been connected
  39953. */
  39954. onGamepadConnectedObservable: Observable<Gamepad>;
  39955. /**
  39956. * observable to be triggered when the gamepad controller has been disconnected
  39957. */
  39958. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39959. private _onGamepadConnectedEvent;
  39960. private _onGamepadDisconnectedEvent;
  39961. /**
  39962. * Initializes the gamepad manager
  39963. * @param _scene BabylonJS scene
  39964. */
  39965. constructor(_scene?: Scene | undefined);
  39966. /**
  39967. * The gamepads in the game pad manager
  39968. */
  39969. readonly gamepads: Gamepad[];
  39970. /**
  39971. * Get the gamepad controllers based on type
  39972. * @param type The type of gamepad controller
  39973. * @returns Nullable gamepad
  39974. */
  39975. getGamepadByType(type?: number): Nullable<Gamepad>;
  39976. /**
  39977. * Disposes the gamepad manager
  39978. */
  39979. dispose(): void;
  39980. private _addNewGamepad;
  39981. private _startMonitoringGamepads;
  39982. private _stopMonitoringGamepads;
  39983. /** @hidden */
  39984. _checkGamepadsStatus(): void;
  39985. private _updateGamepadObjects;
  39986. }
  39987. }
  39988. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39989. import { Nullable } from "babylonjs/types";
  39990. import { Scene } from "babylonjs/scene";
  39991. import { ISceneComponent } from "babylonjs/sceneComponent";
  39992. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39993. module "babylonjs/scene" {
  39994. interface Scene {
  39995. /** @hidden */
  39996. _gamepadManager: Nullable<GamepadManager>;
  39997. /**
  39998. * Gets the gamepad manager associated with the scene
  39999. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40000. */
  40001. gamepadManager: GamepadManager;
  40002. }
  40003. }
  40004. module "babylonjs/Cameras/freeCameraInputsManager" {
  40005. /**
  40006. * Interface representing a free camera inputs manager
  40007. */
  40008. interface FreeCameraInputsManager {
  40009. /**
  40010. * Adds gamepad input support to the FreeCameraInputsManager.
  40011. * @returns the FreeCameraInputsManager
  40012. */
  40013. addGamepad(): FreeCameraInputsManager;
  40014. }
  40015. }
  40016. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40017. /**
  40018. * Interface representing an arc rotate camera inputs manager
  40019. */
  40020. interface ArcRotateCameraInputsManager {
  40021. /**
  40022. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40023. * @returns the camera inputs manager
  40024. */
  40025. addGamepad(): ArcRotateCameraInputsManager;
  40026. }
  40027. }
  40028. /**
  40029. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40030. */
  40031. export class GamepadSystemSceneComponent implements ISceneComponent {
  40032. /**
  40033. * The component name helpfull to identify the component in the list of scene components.
  40034. */
  40035. readonly name: string;
  40036. /**
  40037. * The scene the component belongs to.
  40038. */
  40039. scene: Scene;
  40040. /**
  40041. * Creates a new instance of the component for the given scene
  40042. * @param scene Defines the scene to register the component in
  40043. */
  40044. constructor(scene: Scene);
  40045. /**
  40046. * Registers the component in a given scene
  40047. */
  40048. register(): void;
  40049. /**
  40050. * Rebuilds the elements related to this component in case of
  40051. * context lost for instance.
  40052. */
  40053. rebuild(): void;
  40054. /**
  40055. * Disposes the component and the associated ressources
  40056. */
  40057. dispose(): void;
  40058. private _beforeCameraUpdate;
  40059. }
  40060. }
  40061. declare module "babylonjs/Cameras/universalCamera" {
  40062. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40063. import { Scene } from "babylonjs/scene";
  40064. import { Vector3 } from "babylonjs/Maths/math.vector";
  40065. import "babylonjs/Gamepads/gamepadSceneComponent";
  40066. /**
  40067. * 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,
  40068. * which still works and will still be found in many Playgrounds.
  40069. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40070. */
  40071. export class UniversalCamera extends TouchCamera {
  40072. /**
  40073. * Defines the gamepad rotation sensiblity.
  40074. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40075. */
  40076. gamepadAngularSensibility: number;
  40077. /**
  40078. * Defines the gamepad move sensiblity.
  40079. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40080. */
  40081. gamepadMoveSensibility: number;
  40082. /**
  40083. * 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,
  40084. * which still works and will still be found in many Playgrounds.
  40085. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40086. * @param name Define the name of the camera in the scene
  40087. * @param position Define the start position of the camera in the scene
  40088. * @param scene Define the scene the camera belongs to
  40089. */
  40090. constructor(name: string, position: Vector3, scene: Scene);
  40091. /**
  40092. * Gets the current object class name.
  40093. * @return the class name
  40094. */
  40095. getClassName(): string;
  40096. }
  40097. }
  40098. declare module "babylonjs/Cameras/gamepadCamera" {
  40099. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40100. import { Scene } from "babylonjs/scene";
  40101. import { Vector3 } from "babylonjs/Maths/math.vector";
  40102. /**
  40103. * This represents a FPS type of camera. This is only here for back compat purpose.
  40104. * Please use the UniversalCamera instead as both are identical.
  40105. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40106. */
  40107. export class GamepadCamera extends UniversalCamera {
  40108. /**
  40109. * Instantiates a new Gamepad Camera
  40110. * This represents a FPS type of camera. This is only here for back compat purpose.
  40111. * Please use the UniversalCamera instead as both are identical.
  40112. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40113. * @param name Define the name of the camera in the scene
  40114. * @param position Define the start position of the camera in the scene
  40115. * @param scene Define the scene the camera belongs to
  40116. */
  40117. constructor(name: string, position: Vector3, scene: Scene);
  40118. /**
  40119. * Gets the current object class name.
  40120. * @return the class name
  40121. */
  40122. getClassName(): string;
  40123. }
  40124. }
  40125. declare module "babylonjs/Shaders/pass.fragment" {
  40126. /** @hidden */
  40127. export var passPixelShader: {
  40128. name: string;
  40129. shader: string;
  40130. };
  40131. }
  40132. declare module "babylonjs/Shaders/passCube.fragment" {
  40133. /** @hidden */
  40134. export var passCubePixelShader: {
  40135. name: string;
  40136. shader: string;
  40137. };
  40138. }
  40139. declare module "babylonjs/PostProcesses/passPostProcess" {
  40140. import { Nullable } from "babylonjs/types";
  40141. import { Camera } from "babylonjs/Cameras/camera";
  40142. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40143. import { Engine } from "babylonjs/Engines/engine";
  40144. import "babylonjs/Shaders/pass.fragment";
  40145. import "babylonjs/Shaders/passCube.fragment";
  40146. /**
  40147. * PassPostProcess which produces an output the same as it's input
  40148. */
  40149. export class PassPostProcess extends PostProcess {
  40150. /**
  40151. * Creates the PassPostProcess
  40152. * @param name The name of the effect.
  40153. * @param options The required width/height ratio to downsize to before computing the render pass.
  40154. * @param camera The camera to apply the render pass to.
  40155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40156. * @param engine The engine which the post process will be applied. (default: current engine)
  40157. * @param reusable If the post process can be reused on the same frame. (default: false)
  40158. * @param textureType The type of texture to be used when performing the post processing.
  40159. * @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)
  40160. */
  40161. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40162. }
  40163. /**
  40164. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40165. */
  40166. export class PassCubePostProcess extends PostProcess {
  40167. private _face;
  40168. /**
  40169. * Gets or sets the cube face to display.
  40170. * * 0 is +X
  40171. * * 1 is -X
  40172. * * 2 is +Y
  40173. * * 3 is -Y
  40174. * * 4 is +Z
  40175. * * 5 is -Z
  40176. */
  40177. face: number;
  40178. /**
  40179. * Creates the PassCubePostProcess
  40180. * @param name The name of the effect.
  40181. * @param options The required width/height ratio to downsize to before computing the render pass.
  40182. * @param camera The camera to apply the render pass to.
  40183. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40184. * @param engine The engine which the post process will be applied. (default: current engine)
  40185. * @param reusable If the post process can be reused on the same frame. (default: false)
  40186. * @param textureType The type of texture to be used when performing the post processing.
  40187. * @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)
  40188. */
  40189. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40190. }
  40191. }
  40192. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40193. /** @hidden */
  40194. export var anaglyphPixelShader: {
  40195. name: string;
  40196. shader: string;
  40197. };
  40198. }
  40199. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40200. import { Engine } from "babylonjs/Engines/engine";
  40201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40202. import { Camera } from "babylonjs/Cameras/camera";
  40203. import "babylonjs/Shaders/anaglyph.fragment";
  40204. /**
  40205. * Postprocess used to generate anaglyphic rendering
  40206. */
  40207. export class AnaglyphPostProcess extends PostProcess {
  40208. private _passedProcess;
  40209. /**
  40210. * Creates a new AnaglyphPostProcess
  40211. * @param name defines postprocess name
  40212. * @param options defines creation options or target ratio scale
  40213. * @param rigCameras defines cameras using this postprocess
  40214. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40215. * @param engine defines hosting engine
  40216. * @param reusable defines if the postprocess will be reused multiple times per frame
  40217. */
  40218. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40219. }
  40220. }
  40221. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40222. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40223. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40224. import { Scene } from "babylonjs/scene";
  40225. import { Vector3 } from "babylonjs/Maths/math.vector";
  40226. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40227. /**
  40228. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40229. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40230. */
  40231. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40232. /**
  40233. * Creates a new AnaglyphArcRotateCamera
  40234. * @param name defines camera name
  40235. * @param alpha defines alpha angle (in radians)
  40236. * @param beta defines beta angle (in radians)
  40237. * @param radius defines radius
  40238. * @param target defines camera target
  40239. * @param interaxialDistance defines distance between each color axis
  40240. * @param scene defines the hosting scene
  40241. */
  40242. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40243. /**
  40244. * Gets camera class name
  40245. * @returns AnaglyphArcRotateCamera
  40246. */
  40247. getClassName(): string;
  40248. }
  40249. }
  40250. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40251. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40252. import { Scene } from "babylonjs/scene";
  40253. import { Vector3 } from "babylonjs/Maths/math.vector";
  40254. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40255. /**
  40256. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40257. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40258. */
  40259. export class AnaglyphFreeCamera extends FreeCamera {
  40260. /**
  40261. * Creates a new AnaglyphFreeCamera
  40262. * @param name defines camera name
  40263. * @param position defines initial position
  40264. * @param interaxialDistance defines distance between each color axis
  40265. * @param scene defines the hosting scene
  40266. */
  40267. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40268. /**
  40269. * Gets camera class name
  40270. * @returns AnaglyphFreeCamera
  40271. */
  40272. getClassName(): string;
  40273. }
  40274. }
  40275. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40276. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40277. import { Scene } from "babylonjs/scene";
  40278. import { Vector3 } from "babylonjs/Maths/math.vector";
  40279. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40280. /**
  40281. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40282. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40283. */
  40284. export class AnaglyphGamepadCamera extends GamepadCamera {
  40285. /**
  40286. * Creates a new AnaglyphGamepadCamera
  40287. * @param name defines camera name
  40288. * @param position defines initial position
  40289. * @param interaxialDistance defines distance between each color axis
  40290. * @param scene defines the hosting scene
  40291. */
  40292. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40293. /**
  40294. * Gets camera class name
  40295. * @returns AnaglyphGamepadCamera
  40296. */
  40297. getClassName(): string;
  40298. }
  40299. }
  40300. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40301. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40302. import { Scene } from "babylonjs/scene";
  40303. import { Vector3 } from "babylonjs/Maths/math.vector";
  40304. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40305. /**
  40306. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40307. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40308. */
  40309. export class AnaglyphUniversalCamera extends UniversalCamera {
  40310. /**
  40311. * Creates a new AnaglyphUniversalCamera
  40312. * @param name defines camera name
  40313. * @param position defines initial position
  40314. * @param interaxialDistance defines distance between each color axis
  40315. * @param scene defines the hosting scene
  40316. */
  40317. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40318. /**
  40319. * Gets camera class name
  40320. * @returns AnaglyphUniversalCamera
  40321. */
  40322. getClassName(): string;
  40323. }
  40324. }
  40325. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40326. /** @hidden */
  40327. export var stereoscopicInterlacePixelShader: {
  40328. name: string;
  40329. shader: string;
  40330. };
  40331. }
  40332. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40333. import { Camera } from "babylonjs/Cameras/camera";
  40334. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40335. import { Engine } from "babylonjs/Engines/engine";
  40336. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40337. /**
  40338. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40339. */
  40340. export class StereoscopicInterlacePostProcess extends PostProcess {
  40341. private _stepSize;
  40342. private _passedProcess;
  40343. /**
  40344. * Initializes a StereoscopicInterlacePostProcess
  40345. * @param name The name of the effect.
  40346. * @param rigCameras The rig cameras to be appled to the post process
  40347. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40349. * @param engine The engine which the post process will be applied. (default: current engine)
  40350. * @param reusable If the post process can be reused on the same frame. (default: false)
  40351. */
  40352. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40353. }
  40354. }
  40355. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40356. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40357. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40358. import { Scene } from "babylonjs/scene";
  40359. import { Vector3 } from "babylonjs/Maths/math.vector";
  40360. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40361. /**
  40362. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40363. * @see http://doc.babylonjs.com/features/cameras
  40364. */
  40365. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40366. /**
  40367. * Creates a new StereoscopicArcRotateCamera
  40368. * @param name defines camera name
  40369. * @param alpha defines alpha angle (in radians)
  40370. * @param beta defines beta angle (in radians)
  40371. * @param radius defines radius
  40372. * @param target defines camera target
  40373. * @param interaxialDistance defines distance between each color axis
  40374. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40375. * @param scene defines the hosting scene
  40376. */
  40377. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40378. /**
  40379. * Gets camera class name
  40380. * @returns StereoscopicArcRotateCamera
  40381. */
  40382. getClassName(): string;
  40383. }
  40384. }
  40385. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40386. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40387. import { Scene } from "babylonjs/scene";
  40388. import { Vector3 } from "babylonjs/Maths/math.vector";
  40389. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40390. /**
  40391. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40392. * @see http://doc.babylonjs.com/features/cameras
  40393. */
  40394. export class StereoscopicFreeCamera extends FreeCamera {
  40395. /**
  40396. * Creates a new StereoscopicFreeCamera
  40397. * @param name defines camera name
  40398. * @param position defines initial position
  40399. * @param interaxialDistance defines distance between each color axis
  40400. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40401. * @param scene defines the hosting scene
  40402. */
  40403. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40404. /**
  40405. * Gets camera class name
  40406. * @returns StereoscopicFreeCamera
  40407. */
  40408. getClassName(): string;
  40409. }
  40410. }
  40411. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40412. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40413. import { Scene } from "babylonjs/scene";
  40414. import { Vector3 } from "babylonjs/Maths/math.vector";
  40415. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40416. /**
  40417. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40418. * @see http://doc.babylonjs.com/features/cameras
  40419. */
  40420. export class StereoscopicGamepadCamera extends GamepadCamera {
  40421. /**
  40422. * Creates a new StereoscopicGamepadCamera
  40423. * @param name defines camera name
  40424. * @param position defines initial position
  40425. * @param interaxialDistance defines distance between each color axis
  40426. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40427. * @param scene defines the hosting scene
  40428. */
  40429. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40430. /**
  40431. * Gets camera class name
  40432. * @returns StereoscopicGamepadCamera
  40433. */
  40434. getClassName(): string;
  40435. }
  40436. }
  40437. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40438. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40439. import { Scene } from "babylonjs/scene";
  40440. import { Vector3 } from "babylonjs/Maths/math.vector";
  40441. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40442. /**
  40443. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40444. * @see http://doc.babylonjs.com/features/cameras
  40445. */
  40446. export class StereoscopicUniversalCamera extends UniversalCamera {
  40447. /**
  40448. * Creates a new StereoscopicUniversalCamera
  40449. * @param name defines camera name
  40450. * @param position defines initial position
  40451. * @param interaxialDistance defines distance between each color axis
  40452. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40453. * @param scene defines the hosting scene
  40454. */
  40455. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40456. /**
  40457. * Gets camera class name
  40458. * @returns StereoscopicUniversalCamera
  40459. */
  40460. getClassName(): string;
  40461. }
  40462. }
  40463. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40464. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40465. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40466. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40467. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40468. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40469. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40470. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40471. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40472. }
  40473. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40475. import { Scene } from "babylonjs/scene";
  40476. import { Vector3 } from "babylonjs/Maths/math.vector";
  40477. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40478. /**
  40479. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40480. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40481. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40482. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40483. */
  40484. export class VirtualJoysticksCamera extends FreeCamera {
  40485. /**
  40486. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40487. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40488. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40489. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40490. * @param name Define the name of the camera in the scene
  40491. * @param position Define the start position of the camera in the scene
  40492. * @param scene Define the scene the camera belongs to
  40493. */
  40494. constructor(name: string, position: Vector3, scene: Scene);
  40495. /**
  40496. * Gets the current object class name.
  40497. * @return the class name
  40498. */
  40499. getClassName(): string;
  40500. }
  40501. }
  40502. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40503. import { Matrix } from "babylonjs/Maths/math.vector";
  40504. /**
  40505. * This represents all the required metrics to create a VR camera.
  40506. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40507. */
  40508. export class VRCameraMetrics {
  40509. /**
  40510. * Define the horizontal resolution off the screen.
  40511. */
  40512. hResolution: number;
  40513. /**
  40514. * Define the vertical resolution off the screen.
  40515. */
  40516. vResolution: number;
  40517. /**
  40518. * Define the horizontal screen size.
  40519. */
  40520. hScreenSize: number;
  40521. /**
  40522. * Define the vertical screen size.
  40523. */
  40524. vScreenSize: number;
  40525. /**
  40526. * Define the vertical screen center position.
  40527. */
  40528. vScreenCenter: number;
  40529. /**
  40530. * Define the distance of the eyes to the screen.
  40531. */
  40532. eyeToScreenDistance: number;
  40533. /**
  40534. * Define the distance between both lenses
  40535. */
  40536. lensSeparationDistance: number;
  40537. /**
  40538. * Define the distance between both viewer's eyes.
  40539. */
  40540. interpupillaryDistance: number;
  40541. /**
  40542. * Define the distortion factor of the VR postprocess.
  40543. * Please, touch with care.
  40544. */
  40545. distortionK: number[];
  40546. /**
  40547. * Define the chromatic aberration correction factors for the VR post process.
  40548. */
  40549. chromaAbCorrection: number[];
  40550. /**
  40551. * Define the scale factor of the post process.
  40552. * The smaller the better but the slower.
  40553. */
  40554. postProcessScaleFactor: number;
  40555. /**
  40556. * Define an offset for the lens center.
  40557. */
  40558. lensCenterOffset: number;
  40559. /**
  40560. * Define if the current vr camera should compensate the distortion of the lense or not.
  40561. */
  40562. compensateDistortion: boolean;
  40563. /**
  40564. * Defines if multiview should be enabled when rendering (Default: false)
  40565. */
  40566. multiviewEnabled: boolean;
  40567. /**
  40568. * Gets the rendering aspect ratio based on the provided resolutions.
  40569. */
  40570. readonly aspectRatio: number;
  40571. /**
  40572. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40573. */
  40574. readonly aspectRatioFov: number;
  40575. /**
  40576. * @hidden
  40577. */
  40578. readonly leftHMatrix: Matrix;
  40579. /**
  40580. * @hidden
  40581. */
  40582. readonly rightHMatrix: Matrix;
  40583. /**
  40584. * @hidden
  40585. */
  40586. readonly leftPreViewMatrix: Matrix;
  40587. /**
  40588. * @hidden
  40589. */
  40590. readonly rightPreViewMatrix: Matrix;
  40591. /**
  40592. * Get the default VRMetrics based on the most generic setup.
  40593. * @returns the default vr metrics
  40594. */
  40595. static GetDefault(): VRCameraMetrics;
  40596. }
  40597. }
  40598. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40599. /** @hidden */
  40600. export var vrDistortionCorrectionPixelShader: {
  40601. name: string;
  40602. shader: string;
  40603. };
  40604. }
  40605. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40606. import { Camera } from "babylonjs/Cameras/camera";
  40607. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40608. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40609. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40610. /**
  40611. * VRDistortionCorrectionPostProcess used for mobile VR
  40612. */
  40613. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40614. private _isRightEye;
  40615. private _distortionFactors;
  40616. private _postProcessScaleFactor;
  40617. private _lensCenterOffset;
  40618. private _scaleIn;
  40619. private _scaleFactor;
  40620. private _lensCenter;
  40621. /**
  40622. * Initializes the VRDistortionCorrectionPostProcess
  40623. * @param name The name of the effect.
  40624. * @param camera The camera to apply the render pass to.
  40625. * @param isRightEye If this is for the right eye distortion
  40626. * @param vrMetrics All the required metrics for the VR camera
  40627. */
  40628. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40629. }
  40630. }
  40631. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40632. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40634. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40635. import { Scene } from "babylonjs/scene";
  40636. import { Vector3 } from "babylonjs/Maths/math.vector";
  40637. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40638. import "babylonjs/Cameras/RigModes/vrRigMode";
  40639. /**
  40640. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40641. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40642. */
  40643. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40644. /**
  40645. * Creates a new VRDeviceOrientationArcRotateCamera
  40646. * @param name defines camera name
  40647. * @param alpha defines the camera rotation along the logitudinal axis
  40648. * @param beta defines the camera rotation along the latitudinal axis
  40649. * @param radius defines the camera distance from its target
  40650. * @param target defines the camera target
  40651. * @param scene defines the scene the camera belongs to
  40652. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40653. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40654. */
  40655. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns VRDeviceOrientationArcRotateCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40664. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40665. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40666. import { Scene } from "babylonjs/scene";
  40667. import { Vector3 } from "babylonjs/Maths/math.vector";
  40668. import "babylonjs/Cameras/RigModes/vrRigMode";
  40669. /**
  40670. * Camera used to simulate VR rendering (based on FreeCamera)
  40671. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40672. */
  40673. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40674. /**
  40675. * Creates a new VRDeviceOrientationFreeCamera
  40676. * @param name defines camera name
  40677. * @param position defines the start position of the camera
  40678. * @param scene defines the scene the camera belongs to
  40679. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40680. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40681. */
  40682. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40683. /**
  40684. * Gets camera class name
  40685. * @returns VRDeviceOrientationFreeCamera
  40686. */
  40687. getClassName(): string;
  40688. }
  40689. }
  40690. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40691. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40692. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40693. import { Scene } from "babylonjs/scene";
  40694. import { Vector3 } from "babylonjs/Maths/math.vector";
  40695. import "babylonjs/Gamepads/gamepadSceneComponent";
  40696. /**
  40697. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40698. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40699. */
  40700. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40701. /**
  40702. * Creates a new VRDeviceOrientationGamepadCamera
  40703. * @param name defines camera name
  40704. * @param position defines the start position of the camera
  40705. * @param scene defines the scene the camera belongs to
  40706. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40707. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40708. */
  40709. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40710. /**
  40711. * Gets camera class name
  40712. * @returns VRDeviceOrientationGamepadCamera
  40713. */
  40714. getClassName(): string;
  40715. }
  40716. }
  40717. declare module "babylonjs/Materials/pushMaterial" {
  40718. import { Nullable } from "babylonjs/types";
  40719. import { Scene } from "babylonjs/scene";
  40720. import { Matrix } from "babylonjs/Maths/math.vector";
  40721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40722. import { Mesh } from "babylonjs/Meshes/mesh";
  40723. import { Material } from "babylonjs/Materials/material";
  40724. import { Effect } from "babylonjs/Materials/effect";
  40725. /**
  40726. * Base class of materials working in push mode in babylon JS
  40727. * @hidden
  40728. */
  40729. export class PushMaterial extends Material {
  40730. protected _activeEffect: Effect;
  40731. protected _normalMatrix: Matrix;
  40732. /**
  40733. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40734. * This means that the material can keep using a previous shader while a new one is being compiled.
  40735. * This is mostly used when shader parallel compilation is supported (true by default)
  40736. */
  40737. allowShaderHotSwapping: boolean;
  40738. constructor(name: string, scene: Scene);
  40739. getEffect(): Effect;
  40740. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40741. /**
  40742. * Binds the given world matrix to the active effect
  40743. *
  40744. * @param world the matrix to bind
  40745. */
  40746. bindOnlyWorldMatrix(world: Matrix): void;
  40747. /**
  40748. * Binds the given normal matrix to the active effect
  40749. *
  40750. * @param normalMatrix the matrix to bind
  40751. */
  40752. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40753. bind(world: Matrix, mesh?: Mesh): void;
  40754. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40755. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40756. }
  40757. }
  40758. declare module "babylonjs/Materials/materialFlags" {
  40759. /**
  40760. * This groups all the flags used to control the materials channel.
  40761. */
  40762. export class MaterialFlags {
  40763. private static _DiffuseTextureEnabled;
  40764. /**
  40765. * Are diffuse textures enabled in the application.
  40766. */
  40767. static DiffuseTextureEnabled: boolean;
  40768. private static _AmbientTextureEnabled;
  40769. /**
  40770. * Are ambient textures enabled in the application.
  40771. */
  40772. static AmbientTextureEnabled: boolean;
  40773. private static _OpacityTextureEnabled;
  40774. /**
  40775. * Are opacity textures enabled in the application.
  40776. */
  40777. static OpacityTextureEnabled: boolean;
  40778. private static _ReflectionTextureEnabled;
  40779. /**
  40780. * Are reflection textures enabled in the application.
  40781. */
  40782. static ReflectionTextureEnabled: boolean;
  40783. private static _EmissiveTextureEnabled;
  40784. /**
  40785. * Are emissive textures enabled in the application.
  40786. */
  40787. static EmissiveTextureEnabled: boolean;
  40788. private static _SpecularTextureEnabled;
  40789. /**
  40790. * Are specular textures enabled in the application.
  40791. */
  40792. static SpecularTextureEnabled: boolean;
  40793. private static _BumpTextureEnabled;
  40794. /**
  40795. * Are bump textures enabled in the application.
  40796. */
  40797. static BumpTextureEnabled: boolean;
  40798. private static _LightmapTextureEnabled;
  40799. /**
  40800. * Are lightmap textures enabled in the application.
  40801. */
  40802. static LightmapTextureEnabled: boolean;
  40803. private static _RefractionTextureEnabled;
  40804. /**
  40805. * Are refraction textures enabled in the application.
  40806. */
  40807. static RefractionTextureEnabled: boolean;
  40808. private static _ColorGradingTextureEnabled;
  40809. /**
  40810. * Are color grading textures enabled in the application.
  40811. */
  40812. static ColorGradingTextureEnabled: boolean;
  40813. private static _FresnelEnabled;
  40814. /**
  40815. * Are fresnels enabled in the application.
  40816. */
  40817. static FresnelEnabled: boolean;
  40818. private static _ClearCoatTextureEnabled;
  40819. /**
  40820. * Are clear coat textures enabled in the application.
  40821. */
  40822. static ClearCoatTextureEnabled: boolean;
  40823. private static _ClearCoatBumpTextureEnabled;
  40824. /**
  40825. * Are clear coat bump textures enabled in the application.
  40826. */
  40827. static ClearCoatBumpTextureEnabled: boolean;
  40828. private static _ClearCoatTintTextureEnabled;
  40829. /**
  40830. * Are clear coat tint textures enabled in the application.
  40831. */
  40832. static ClearCoatTintTextureEnabled: boolean;
  40833. private static _SheenTextureEnabled;
  40834. /**
  40835. * Are sheen textures enabled in the application.
  40836. */
  40837. static SheenTextureEnabled: boolean;
  40838. private static _AnisotropicTextureEnabled;
  40839. /**
  40840. * Are anisotropic textures enabled in the application.
  40841. */
  40842. static AnisotropicTextureEnabled: boolean;
  40843. private static _ThicknessTextureEnabled;
  40844. /**
  40845. * Are thickness textures enabled in the application.
  40846. */
  40847. static ThicknessTextureEnabled: boolean;
  40848. }
  40849. }
  40850. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40851. /** @hidden */
  40852. export var defaultFragmentDeclaration: {
  40853. name: string;
  40854. shader: string;
  40855. };
  40856. }
  40857. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40858. /** @hidden */
  40859. export var defaultUboDeclaration: {
  40860. name: string;
  40861. shader: string;
  40862. };
  40863. }
  40864. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40865. /** @hidden */
  40866. export var lightFragmentDeclaration: {
  40867. name: string;
  40868. shader: string;
  40869. };
  40870. }
  40871. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40872. /** @hidden */
  40873. export var lightUboDeclaration: {
  40874. name: string;
  40875. shader: string;
  40876. };
  40877. }
  40878. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40879. /** @hidden */
  40880. export var lightsFragmentFunctions: {
  40881. name: string;
  40882. shader: string;
  40883. };
  40884. }
  40885. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40886. /** @hidden */
  40887. export var shadowsFragmentFunctions: {
  40888. name: string;
  40889. shader: string;
  40890. };
  40891. }
  40892. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40893. /** @hidden */
  40894. export var fresnelFunction: {
  40895. name: string;
  40896. shader: string;
  40897. };
  40898. }
  40899. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40900. /** @hidden */
  40901. export var reflectionFunction: {
  40902. name: string;
  40903. shader: string;
  40904. };
  40905. }
  40906. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40907. /** @hidden */
  40908. export var bumpFragmentFunctions: {
  40909. name: string;
  40910. shader: string;
  40911. };
  40912. }
  40913. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40914. /** @hidden */
  40915. export var logDepthDeclaration: {
  40916. name: string;
  40917. shader: string;
  40918. };
  40919. }
  40920. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40921. /** @hidden */
  40922. export var bumpFragment: {
  40923. name: string;
  40924. shader: string;
  40925. };
  40926. }
  40927. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40928. /** @hidden */
  40929. export var depthPrePass: {
  40930. name: string;
  40931. shader: string;
  40932. };
  40933. }
  40934. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40935. /** @hidden */
  40936. export var lightFragment: {
  40937. name: string;
  40938. shader: string;
  40939. };
  40940. }
  40941. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40942. /** @hidden */
  40943. export var logDepthFragment: {
  40944. name: string;
  40945. shader: string;
  40946. };
  40947. }
  40948. declare module "babylonjs/Shaders/default.fragment" {
  40949. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40950. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40951. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40952. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40953. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40954. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40955. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40956. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40957. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40958. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40959. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40960. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40961. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40962. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40963. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40964. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40965. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40966. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40967. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40968. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40969. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40970. /** @hidden */
  40971. export var defaultPixelShader: {
  40972. name: string;
  40973. shader: string;
  40974. };
  40975. }
  40976. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40977. /** @hidden */
  40978. export var defaultVertexDeclaration: {
  40979. name: string;
  40980. shader: string;
  40981. };
  40982. }
  40983. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40984. /** @hidden */
  40985. export var bumpVertexDeclaration: {
  40986. name: string;
  40987. shader: string;
  40988. };
  40989. }
  40990. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40991. /** @hidden */
  40992. export var bumpVertex: {
  40993. name: string;
  40994. shader: string;
  40995. };
  40996. }
  40997. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40998. /** @hidden */
  40999. export var fogVertex: {
  41000. name: string;
  41001. shader: string;
  41002. };
  41003. }
  41004. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41005. /** @hidden */
  41006. export var shadowsVertex: {
  41007. name: string;
  41008. shader: string;
  41009. };
  41010. }
  41011. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41012. /** @hidden */
  41013. export var pointCloudVertex: {
  41014. name: string;
  41015. shader: string;
  41016. };
  41017. }
  41018. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41019. /** @hidden */
  41020. export var logDepthVertex: {
  41021. name: string;
  41022. shader: string;
  41023. };
  41024. }
  41025. declare module "babylonjs/Shaders/default.vertex" {
  41026. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41027. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41028. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41029. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41030. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41031. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41032. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41033. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41034. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41035. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41036. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41037. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41038. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41039. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41040. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41041. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41042. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41043. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41044. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41045. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41046. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41047. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41048. /** @hidden */
  41049. export var defaultVertexShader: {
  41050. name: string;
  41051. shader: string;
  41052. };
  41053. }
  41054. declare module "babylonjs/Materials/standardMaterial" {
  41055. import { SmartArray } from "babylonjs/Misc/smartArray";
  41056. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41057. import { Nullable } from "babylonjs/types";
  41058. import { Scene } from "babylonjs/scene";
  41059. import { Matrix } from "babylonjs/Maths/math.vector";
  41060. import { Color3 } from "babylonjs/Maths/math.color";
  41061. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41063. import { Mesh } from "babylonjs/Meshes/mesh";
  41064. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41065. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41066. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41067. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41068. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41069. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41071. import "babylonjs/Shaders/default.fragment";
  41072. import "babylonjs/Shaders/default.vertex";
  41073. /** @hidden */
  41074. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41075. MAINUV1: boolean;
  41076. MAINUV2: boolean;
  41077. DIFFUSE: boolean;
  41078. DIFFUSEDIRECTUV: number;
  41079. AMBIENT: boolean;
  41080. AMBIENTDIRECTUV: number;
  41081. OPACITY: boolean;
  41082. OPACITYDIRECTUV: number;
  41083. OPACITYRGB: boolean;
  41084. REFLECTION: boolean;
  41085. EMISSIVE: boolean;
  41086. EMISSIVEDIRECTUV: number;
  41087. SPECULAR: boolean;
  41088. SPECULARDIRECTUV: number;
  41089. BUMP: boolean;
  41090. BUMPDIRECTUV: number;
  41091. PARALLAX: boolean;
  41092. PARALLAXOCCLUSION: boolean;
  41093. SPECULAROVERALPHA: boolean;
  41094. CLIPPLANE: boolean;
  41095. CLIPPLANE2: boolean;
  41096. CLIPPLANE3: boolean;
  41097. CLIPPLANE4: boolean;
  41098. ALPHATEST: boolean;
  41099. DEPTHPREPASS: boolean;
  41100. ALPHAFROMDIFFUSE: boolean;
  41101. POINTSIZE: boolean;
  41102. FOG: boolean;
  41103. SPECULARTERM: boolean;
  41104. DIFFUSEFRESNEL: boolean;
  41105. OPACITYFRESNEL: boolean;
  41106. REFLECTIONFRESNEL: boolean;
  41107. REFRACTIONFRESNEL: boolean;
  41108. EMISSIVEFRESNEL: boolean;
  41109. FRESNEL: boolean;
  41110. NORMAL: boolean;
  41111. UV1: boolean;
  41112. UV2: boolean;
  41113. VERTEXCOLOR: boolean;
  41114. VERTEXALPHA: boolean;
  41115. NUM_BONE_INFLUENCERS: number;
  41116. BonesPerMesh: number;
  41117. BONETEXTURE: boolean;
  41118. INSTANCES: boolean;
  41119. GLOSSINESS: boolean;
  41120. ROUGHNESS: boolean;
  41121. EMISSIVEASILLUMINATION: boolean;
  41122. LINKEMISSIVEWITHDIFFUSE: boolean;
  41123. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41124. LIGHTMAP: boolean;
  41125. LIGHTMAPDIRECTUV: number;
  41126. OBJECTSPACE_NORMALMAP: boolean;
  41127. USELIGHTMAPASSHADOWMAP: boolean;
  41128. REFLECTIONMAP_3D: boolean;
  41129. REFLECTIONMAP_SPHERICAL: boolean;
  41130. REFLECTIONMAP_PLANAR: boolean;
  41131. REFLECTIONMAP_CUBIC: boolean;
  41132. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41133. REFLECTIONMAP_PROJECTION: boolean;
  41134. REFLECTIONMAP_SKYBOX: boolean;
  41135. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41136. REFLECTIONMAP_EXPLICIT: boolean;
  41137. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41138. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41139. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41140. INVERTCUBICMAP: boolean;
  41141. LOGARITHMICDEPTH: boolean;
  41142. REFRACTION: boolean;
  41143. REFRACTIONMAP_3D: boolean;
  41144. REFLECTIONOVERALPHA: boolean;
  41145. TWOSIDEDLIGHTING: boolean;
  41146. SHADOWFLOAT: boolean;
  41147. MORPHTARGETS: boolean;
  41148. MORPHTARGETS_NORMAL: boolean;
  41149. MORPHTARGETS_TANGENT: boolean;
  41150. MORPHTARGETS_UV: boolean;
  41151. NUM_MORPH_INFLUENCERS: number;
  41152. NONUNIFORMSCALING: boolean;
  41153. PREMULTIPLYALPHA: boolean;
  41154. IMAGEPROCESSING: boolean;
  41155. VIGNETTE: boolean;
  41156. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41157. VIGNETTEBLENDMODEOPAQUE: boolean;
  41158. TONEMAPPING: boolean;
  41159. TONEMAPPING_ACES: boolean;
  41160. CONTRAST: boolean;
  41161. COLORCURVES: boolean;
  41162. COLORGRADING: boolean;
  41163. COLORGRADING3D: boolean;
  41164. SAMPLER3DGREENDEPTH: boolean;
  41165. SAMPLER3DBGRMAP: boolean;
  41166. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41167. MULTIVIEW: boolean;
  41168. /**
  41169. * If the reflection texture on this material is in linear color space
  41170. * @hidden
  41171. */
  41172. IS_REFLECTION_LINEAR: boolean;
  41173. /**
  41174. * If the refraction texture on this material is in linear color space
  41175. * @hidden
  41176. */
  41177. IS_REFRACTION_LINEAR: boolean;
  41178. EXPOSURE: boolean;
  41179. constructor();
  41180. setReflectionMode(modeToEnable: string): void;
  41181. }
  41182. /**
  41183. * This is the default material used in Babylon. It is the best trade off between quality
  41184. * and performances.
  41185. * @see http://doc.babylonjs.com/babylon101/materials
  41186. */
  41187. export class StandardMaterial extends PushMaterial {
  41188. private _diffuseTexture;
  41189. /**
  41190. * The basic texture of the material as viewed under a light.
  41191. */
  41192. diffuseTexture: Nullable<BaseTexture>;
  41193. private _ambientTexture;
  41194. /**
  41195. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41196. */
  41197. ambientTexture: Nullable<BaseTexture>;
  41198. private _opacityTexture;
  41199. /**
  41200. * Define the transparency of the material from a texture.
  41201. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41202. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41203. */
  41204. opacityTexture: Nullable<BaseTexture>;
  41205. private _reflectionTexture;
  41206. /**
  41207. * Define the texture used to display the reflection.
  41208. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41209. */
  41210. reflectionTexture: Nullable<BaseTexture>;
  41211. private _emissiveTexture;
  41212. /**
  41213. * Define texture of the material as if self lit.
  41214. * This will be mixed in the final result even in the absence of light.
  41215. */
  41216. emissiveTexture: Nullable<BaseTexture>;
  41217. private _specularTexture;
  41218. /**
  41219. * Define how the color and intensity of the highlight given by the light in the material.
  41220. */
  41221. specularTexture: Nullable<BaseTexture>;
  41222. private _bumpTexture;
  41223. /**
  41224. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41225. * 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.
  41226. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41227. */
  41228. bumpTexture: Nullable<BaseTexture>;
  41229. private _lightmapTexture;
  41230. /**
  41231. * Complex lighting can be computationally expensive to compute at runtime.
  41232. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41233. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41234. */
  41235. lightmapTexture: Nullable<BaseTexture>;
  41236. private _refractionTexture;
  41237. /**
  41238. * Define the texture used to display the refraction.
  41239. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41240. */
  41241. refractionTexture: Nullable<BaseTexture>;
  41242. /**
  41243. * The color of the material lit by the environmental background lighting.
  41244. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41245. */
  41246. ambientColor: Color3;
  41247. /**
  41248. * The basic color of the material as viewed under a light.
  41249. */
  41250. diffuseColor: Color3;
  41251. /**
  41252. * Define how the color and intensity of the highlight given by the light in the material.
  41253. */
  41254. specularColor: Color3;
  41255. /**
  41256. * Define the color of the material as if self lit.
  41257. * This will be mixed in the final result even in the absence of light.
  41258. */
  41259. emissiveColor: Color3;
  41260. /**
  41261. * Defines how sharp are the highlights in the material.
  41262. * The bigger the value the sharper giving a more glossy feeling to the result.
  41263. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41264. */
  41265. specularPower: number;
  41266. private _useAlphaFromDiffuseTexture;
  41267. /**
  41268. * Does the transparency come from the diffuse texture alpha channel.
  41269. */
  41270. useAlphaFromDiffuseTexture: boolean;
  41271. private _useEmissiveAsIllumination;
  41272. /**
  41273. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41274. */
  41275. useEmissiveAsIllumination: boolean;
  41276. private _linkEmissiveWithDiffuse;
  41277. /**
  41278. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41279. * the emissive level when the final color is close to one.
  41280. */
  41281. linkEmissiveWithDiffuse: boolean;
  41282. private _useSpecularOverAlpha;
  41283. /**
  41284. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41285. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41286. */
  41287. useSpecularOverAlpha: boolean;
  41288. private _useReflectionOverAlpha;
  41289. /**
  41290. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41291. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41292. */
  41293. useReflectionOverAlpha: boolean;
  41294. private _disableLighting;
  41295. /**
  41296. * Does lights from the scene impacts this material.
  41297. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41298. */
  41299. disableLighting: boolean;
  41300. private _useObjectSpaceNormalMap;
  41301. /**
  41302. * Allows using an object space normal map (instead of tangent space).
  41303. */
  41304. useObjectSpaceNormalMap: boolean;
  41305. private _useParallax;
  41306. /**
  41307. * Is parallax enabled or not.
  41308. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41309. */
  41310. useParallax: boolean;
  41311. private _useParallaxOcclusion;
  41312. /**
  41313. * Is parallax occlusion enabled or not.
  41314. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41315. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41316. */
  41317. useParallaxOcclusion: boolean;
  41318. /**
  41319. * 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.
  41320. */
  41321. parallaxScaleBias: number;
  41322. private _roughness;
  41323. /**
  41324. * Helps to define how blurry the reflections should appears in the material.
  41325. */
  41326. roughness: number;
  41327. /**
  41328. * In case of refraction, define the value of the index of refraction.
  41329. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41330. */
  41331. indexOfRefraction: number;
  41332. /**
  41333. * Invert the refraction texture alongside the y axis.
  41334. * It can be useful with procedural textures or probe for instance.
  41335. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41336. */
  41337. invertRefractionY: boolean;
  41338. /**
  41339. * Defines the alpha limits in alpha test mode.
  41340. */
  41341. alphaCutOff: number;
  41342. private _useLightmapAsShadowmap;
  41343. /**
  41344. * In case of light mapping, define whether the map contains light or shadow informations.
  41345. */
  41346. useLightmapAsShadowmap: boolean;
  41347. private _diffuseFresnelParameters;
  41348. /**
  41349. * Define the diffuse fresnel parameters of the material.
  41350. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41351. */
  41352. diffuseFresnelParameters: FresnelParameters;
  41353. private _opacityFresnelParameters;
  41354. /**
  41355. * Define the opacity fresnel parameters of the material.
  41356. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41357. */
  41358. opacityFresnelParameters: FresnelParameters;
  41359. private _reflectionFresnelParameters;
  41360. /**
  41361. * Define the reflection fresnel parameters of the material.
  41362. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41363. */
  41364. reflectionFresnelParameters: FresnelParameters;
  41365. private _refractionFresnelParameters;
  41366. /**
  41367. * Define the refraction fresnel parameters of the material.
  41368. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41369. */
  41370. refractionFresnelParameters: FresnelParameters;
  41371. private _emissiveFresnelParameters;
  41372. /**
  41373. * Define the emissive fresnel parameters of the material.
  41374. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41375. */
  41376. emissiveFresnelParameters: FresnelParameters;
  41377. private _useReflectionFresnelFromSpecular;
  41378. /**
  41379. * If true automatically deducts the fresnels values from the material specularity.
  41380. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41381. */
  41382. useReflectionFresnelFromSpecular: boolean;
  41383. private _useGlossinessFromSpecularMapAlpha;
  41384. /**
  41385. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41386. */
  41387. useGlossinessFromSpecularMapAlpha: boolean;
  41388. private _maxSimultaneousLights;
  41389. /**
  41390. * Defines the maximum number of lights that can be used in the material
  41391. */
  41392. maxSimultaneousLights: number;
  41393. private _invertNormalMapX;
  41394. /**
  41395. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41396. */
  41397. invertNormalMapX: boolean;
  41398. private _invertNormalMapY;
  41399. /**
  41400. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41401. */
  41402. invertNormalMapY: boolean;
  41403. private _twoSidedLighting;
  41404. /**
  41405. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41406. */
  41407. twoSidedLighting: boolean;
  41408. /**
  41409. * Default configuration related to image processing available in the standard Material.
  41410. */
  41411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41412. /**
  41413. * Gets the image processing configuration used either in this material.
  41414. */
  41415. /**
  41416. * Sets the Default image processing configuration used either in the this material.
  41417. *
  41418. * If sets to null, the scene one is in use.
  41419. */
  41420. imageProcessingConfiguration: ImageProcessingConfiguration;
  41421. /**
  41422. * Keep track of the image processing observer to allow dispose and replace.
  41423. */
  41424. private _imageProcessingObserver;
  41425. /**
  41426. * Attaches a new image processing configuration to the Standard Material.
  41427. * @param configuration
  41428. */
  41429. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41430. /**
  41431. * Gets wether the color curves effect is enabled.
  41432. */
  41433. /**
  41434. * Sets wether the color curves effect is enabled.
  41435. */
  41436. cameraColorCurvesEnabled: boolean;
  41437. /**
  41438. * Gets wether the color grading effect is enabled.
  41439. */
  41440. /**
  41441. * Gets wether the color grading effect is enabled.
  41442. */
  41443. cameraColorGradingEnabled: boolean;
  41444. /**
  41445. * Gets wether tonemapping is enabled or not.
  41446. */
  41447. /**
  41448. * Sets wether tonemapping is enabled or not
  41449. */
  41450. cameraToneMappingEnabled: boolean;
  41451. /**
  41452. * The camera exposure used on this material.
  41453. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41454. * This corresponds to a photographic exposure.
  41455. */
  41456. /**
  41457. * The camera exposure used on this material.
  41458. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41459. * This corresponds to a photographic exposure.
  41460. */
  41461. cameraExposure: number;
  41462. /**
  41463. * Gets The camera contrast used on this material.
  41464. */
  41465. /**
  41466. * Sets The camera contrast used on this material.
  41467. */
  41468. cameraContrast: number;
  41469. /**
  41470. * Gets the Color Grading 2D Lookup Texture.
  41471. */
  41472. /**
  41473. * Sets the Color Grading 2D Lookup Texture.
  41474. */
  41475. cameraColorGradingTexture: Nullable<BaseTexture>;
  41476. /**
  41477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41479. * 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;
  41480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41481. */
  41482. /**
  41483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41485. * 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;
  41486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41487. */
  41488. cameraColorCurves: Nullable<ColorCurves>;
  41489. /**
  41490. * Custom callback helping to override the default shader used in the material.
  41491. */
  41492. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41493. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41494. protected _worldViewProjectionMatrix: Matrix;
  41495. protected _globalAmbientColor: Color3;
  41496. protected _useLogarithmicDepth: boolean;
  41497. /**
  41498. * Instantiates a new standard material.
  41499. * This is the default material used in Babylon. It is the best trade off between quality
  41500. * and performances.
  41501. * @see http://doc.babylonjs.com/babylon101/materials
  41502. * @param name Define the name of the material in the scene
  41503. * @param scene Define the scene the material belong to
  41504. */
  41505. constructor(name: string, scene: Scene);
  41506. /**
  41507. * Gets a boolean indicating that current material needs to register RTT
  41508. */
  41509. readonly hasRenderTargetTextures: boolean;
  41510. /**
  41511. * Gets the current class name of the material e.g. "StandardMaterial"
  41512. * Mainly use in serialization.
  41513. * @returns the class name
  41514. */
  41515. getClassName(): string;
  41516. /**
  41517. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41518. * You can try switching to logarithmic depth.
  41519. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41520. */
  41521. useLogarithmicDepth: boolean;
  41522. /**
  41523. * Specifies if the material will require alpha blending
  41524. * @returns a boolean specifying if alpha blending is needed
  41525. */
  41526. needAlphaBlending(): boolean;
  41527. /**
  41528. * Specifies if this material should be rendered in alpha test mode
  41529. * @returns a boolean specifying if an alpha test is needed.
  41530. */
  41531. needAlphaTesting(): boolean;
  41532. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41533. /**
  41534. * Get the texture used for alpha test purpose.
  41535. * @returns the diffuse texture in case of the standard material.
  41536. */
  41537. getAlphaTestTexture(): Nullable<BaseTexture>;
  41538. /**
  41539. * Get if the submesh is ready to be used and all its information available.
  41540. * Child classes can use it to update shaders
  41541. * @param mesh defines the mesh to check
  41542. * @param subMesh defines which submesh to check
  41543. * @param useInstances specifies that instances should be used
  41544. * @returns a boolean indicating that the submesh is ready or not
  41545. */
  41546. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41547. /**
  41548. * Builds the material UBO layouts.
  41549. * Used internally during the effect preparation.
  41550. */
  41551. buildUniformLayout(): void;
  41552. /**
  41553. * Unbinds the material from the mesh
  41554. */
  41555. unbind(): void;
  41556. /**
  41557. * Binds the submesh to this material by preparing the effect and shader to draw
  41558. * @param world defines the world transformation matrix
  41559. * @param mesh defines the mesh containing the submesh
  41560. * @param subMesh defines the submesh to bind the material to
  41561. */
  41562. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41563. /**
  41564. * Get the list of animatables in the material.
  41565. * @returns the list of animatables object used in the material
  41566. */
  41567. getAnimatables(): IAnimatable[];
  41568. /**
  41569. * Gets the active textures from the material
  41570. * @returns an array of textures
  41571. */
  41572. getActiveTextures(): BaseTexture[];
  41573. /**
  41574. * Specifies if the material uses a texture
  41575. * @param texture defines the texture to check against the material
  41576. * @returns a boolean specifying if the material uses the texture
  41577. */
  41578. hasTexture(texture: BaseTexture): boolean;
  41579. /**
  41580. * Disposes the material
  41581. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41582. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41583. */
  41584. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41585. /**
  41586. * Makes a duplicate of the material, and gives it a new name
  41587. * @param name defines the new name for the duplicated material
  41588. * @returns the cloned material
  41589. */
  41590. clone(name: string): StandardMaterial;
  41591. /**
  41592. * Serializes this material in a JSON representation
  41593. * @returns the serialized material object
  41594. */
  41595. serialize(): any;
  41596. /**
  41597. * Creates a standard material from parsed material data
  41598. * @param source defines the JSON representation of the material
  41599. * @param scene defines the hosting scene
  41600. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41601. * @returns a new standard material
  41602. */
  41603. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41604. /**
  41605. * Are diffuse textures enabled in the application.
  41606. */
  41607. static DiffuseTextureEnabled: boolean;
  41608. /**
  41609. * Are ambient textures enabled in the application.
  41610. */
  41611. static AmbientTextureEnabled: boolean;
  41612. /**
  41613. * Are opacity textures enabled in the application.
  41614. */
  41615. static OpacityTextureEnabled: boolean;
  41616. /**
  41617. * Are reflection textures enabled in the application.
  41618. */
  41619. static ReflectionTextureEnabled: boolean;
  41620. /**
  41621. * Are emissive textures enabled in the application.
  41622. */
  41623. static EmissiveTextureEnabled: boolean;
  41624. /**
  41625. * Are specular textures enabled in the application.
  41626. */
  41627. static SpecularTextureEnabled: boolean;
  41628. /**
  41629. * Are bump textures enabled in the application.
  41630. */
  41631. static BumpTextureEnabled: boolean;
  41632. /**
  41633. * Are lightmap textures enabled in the application.
  41634. */
  41635. static LightmapTextureEnabled: boolean;
  41636. /**
  41637. * Are refraction textures enabled in the application.
  41638. */
  41639. static RefractionTextureEnabled: boolean;
  41640. /**
  41641. * Are color grading textures enabled in the application.
  41642. */
  41643. static ColorGradingTextureEnabled: boolean;
  41644. /**
  41645. * Are fresnels enabled in the application.
  41646. */
  41647. static FresnelEnabled: boolean;
  41648. }
  41649. }
  41650. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41651. import { Scene } from "babylonjs/scene";
  41652. import { Texture } from "babylonjs/Materials/Textures/texture";
  41653. /**
  41654. * A class extending Texture allowing drawing on a texture
  41655. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41656. */
  41657. export class DynamicTexture extends Texture {
  41658. private _generateMipMaps;
  41659. private _canvas;
  41660. private _context;
  41661. private _engine;
  41662. /**
  41663. * Creates a DynamicTexture
  41664. * @param name defines the name of the texture
  41665. * @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
  41666. * @param scene defines the scene where you want the texture
  41667. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41668. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41669. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41670. */
  41671. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41672. /**
  41673. * Get the current class name of the texture useful for serialization or dynamic coding.
  41674. * @returns "DynamicTexture"
  41675. */
  41676. getClassName(): string;
  41677. /**
  41678. * Gets the current state of canRescale
  41679. */
  41680. readonly canRescale: boolean;
  41681. private _recreate;
  41682. /**
  41683. * Scales the texture
  41684. * @param ratio the scale factor to apply to both width and height
  41685. */
  41686. scale(ratio: number): void;
  41687. /**
  41688. * Resizes the texture
  41689. * @param width the new width
  41690. * @param height the new height
  41691. */
  41692. scaleTo(width: number, height: number): void;
  41693. /**
  41694. * Gets the context of the canvas used by the texture
  41695. * @returns the canvas context of the dynamic texture
  41696. */
  41697. getContext(): CanvasRenderingContext2D;
  41698. /**
  41699. * Clears the texture
  41700. */
  41701. clear(): void;
  41702. /**
  41703. * Updates the texture
  41704. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41705. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41706. */
  41707. update(invertY?: boolean, premulAlpha?: boolean): void;
  41708. /**
  41709. * Draws text onto the texture
  41710. * @param text defines the text to be drawn
  41711. * @param x defines the placement of the text from the left
  41712. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41713. * @param font defines the font to be used with font-style, font-size, font-name
  41714. * @param color defines the color used for the text
  41715. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41716. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41717. * @param update defines whether texture is immediately update (default is true)
  41718. */
  41719. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41720. /**
  41721. * Clones the texture
  41722. * @returns the clone of the texture.
  41723. */
  41724. clone(): DynamicTexture;
  41725. /**
  41726. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41727. * @returns a serialized dynamic texture object
  41728. */
  41729. serialize(): any;
  41730. /** @hidden */
  41731. _rebuild(): void;
  41732. }
  41733. }
  41734. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41735. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41736. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41737. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41738. /** @hidden */
  41739. export var imageProcessingPixelShader: {
  41740. name: string;
  41741. shader: string;
  41742. };
  41743. }
  41744. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41745. import { Nullable } from "babylonjs/types";
  41746. import { Color4 } from "babylonjs/Maths/math.color";
  41747. import { Camera } from "babylonjs/Cameras/camera";
  41748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41749. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41750. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41752. import { Engine } from "babylonjs/Engines/engine";
  41753. import "babylonjs/Shaders/imageProcessing.fragment";
  41754. import "babylonjs/Shaders/postprocess.vertex";
  41755. /**
  41756. * ImageProcessingPostProcess
  41757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41758. */
  41759. export class ImageProcessingPostProcess extends PostProcess {
  41760. /**
  41761. * Default configuration related to image processing available in the PBR Material.
  41762. */
  41763. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41764. /**
  41765. * Gets the image processing configuration used either in this material.
  41766. */
  41767. /**
  41768. * Sets the Default image processing configuration used either in the this material.
  41769. *
  41770. * If sets to null, the scene one is in use.
  41771. */
  41772. imageProcessingConfiguration: ImageProcessingConfiguration;
  41773. /**
  41774. * Keep track of the image processing observer to allow dispose and replace.
  41775. */
  41776. private _imageProcessingObserver;
  41777. /**
  41778. * Attaches a new image processing configuration to the PBR Material.
  41779. * @param configuration
  41780. */
  41781. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41782. /**
  41783. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41784. */
  41785. /**
  41786. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41787. */
  41788. colorCurves: Nullable<ColorCurves>;
  41789. /**
  41790. * Gets wether the color curves effect is enabled.
  41791. */
  41792. /**
  41793. * Sets wether the color curves effect is enabled.
  41794. */
  41795. colorCurvesEnabled: boolean;
  41796. /**
  41797. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41798. */
  41799. /**
  41800. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41801. */
  41802. colorGradingTexture: Nullable<BaseTexture>;
  41803. /**
  41804. * Gets wether the color grading effect is enabled.
  41805. */
  41806. /**
  41807. * Gets wether the color grading effect is enabled.
  41808. */
  41809. colorGradingEnabled: boolean;
  41810. /**
  41811. * Gets exposure used in the effect.
  41812. */
  41813. /**
  41814. * Sets exposure used in the effect.
  41815. */
  41816. exposure: number;
  41817. /**
  41818. * Gets wether tonemapping is enabled or not.
  41819. */
  41820. /**
  41821. * Sets wether tonemapping is enabled or not
  41822. */
  41823. toneMappingEnabled: boolean;
  41824. /**
  41825. * Gets the type of tone mapping effect.
  41826. */
  41827. /**
  41828. * Sets the type of tone mapping effect.
  41829. */
  41830. toneMappingType: number;
  41831. /**
  41832. * Gets contrast used in the effect.
  41833. */
  41834. /**
  41835. * Sets contrast used in the effect.
  41836. */
  41837. contrast: number;
  41838. /**
  41839. * Gets Vignette stretch size.
  41840. */
  41841. /**
  41842. * Sets Vignette stretch size.
  41843. */
  41844. vignetteStretch: number;
  41845. /**
  41846. * Gets Vignette centre X Offset.
  41847. */
  41848. /**
  41849. * Sets Vignette centre X Offset.
  41850. */
  41851. vignetteCentreX: number;
  41852. /**
  41853. * Gets Vignette centre Y Offset.
  41854. */
  41855. /**
  41856. * Sets Vignette centre Y Offset.
  41857. */
  41858. vignetteCentreY: number;
  41859. /**
  41860. * Gets Vignette weight or intensity of the vignette effect.
  41861. */
  41862. /**
  41863. * Sets Vignette weight or intensity of the vignette effect.
  41864. */
  41865. vignetteWeight: number;
  41866. /**
  41867. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41868. * if vignetteEnabled is set to true.
  41869. */
  41870. /**
  41871. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41872. * if vignetteEnabled is set to true.
  41873. */
  41874. vignetteColor: Color4;
  41875. /**
  41876. * Gets Camera field of view used by the Vignette effect.
  41877. */
  41878. /**
  41879. * Sets Camera field of view used by the Vignette effect.
  41880. */
  41881. vignetteCameraFov: number;
  41882. /**
  41883. * Gets the vignette blend mode allowing different kind of effect.
  41884. */
  41885. /**
  41886. * Sets the vignette blend mode allowing different kind of effect.
  41887. */
  41888. vignetteBlendMode: number;
  41889. /**
  41890. * Gets wether the vignette effect is enabled.
  41891. */
  41892. /**
  41893. * Sets wether the vignette effect is enabled.
  41894. */
  41895. vignetteEnabled: boolean;
  41896. private _fromLinearSpace;
  41897. /**
  41898. * Gets wether the input of the processing is in Gamma or Linear Space.
  41899. */
  41900. /**
  41901. * Sets wether the input of the processing is in Gamma or Linear Space.
  41902. */
  41903. fromLinearSpace: boolean;
  41904. /**
  41905. * Defines cache preventing GC.
  41906. */
  41907. private _defines;
  41908. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41909. /**
  41910. * "ImageProcessingPostProcess"
  41911. * @returns "ImageProcessingPostProcess"
  41912. */
  41913. getClassName(): string;
  41914. protected _updateParameters(): void;
  41915. dispose(camera?: Camera): void;
  41916. }
  41917. }
  41918. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41919. import { Scene } from "babylonjs/scene";
  41920. import { Color3 } from "babylonjs/Maths/math.color";
  41921. import { Mesh } from "babylonjs/Meshes/mesh";
  41922. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41923. import { Nullable } from "babylonjs/types";
  41924. /**
  41925. * Class containing static functions to help procedurally build meshes
  41926. */
  41927. export class GroundBuilder {
  41928. /**
  41929. * Creates a ground mesh
  41930. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41931. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41933. * @param name defines the name of the mesh
  41934. * @param options defines the options used to create the mesh
  41935. * @param scene defines the hosting scene
  41936. * @returns the ground mesh
  41937. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41938. */
  41939. static CreateGround(name: string, options: {
  41940. width?: number;
  41941. height?: number;
  41942. subdivisions?: number;
  41943. subdivisionsX?: number;
  41944. subdivisionsY?: number;
  41945. updatable?: boolean;
  41946. }, scene: any): Mesh;
  41947. /**
  41948. * Creates a tiled ground mesh
  41949. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41950. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41951. * * 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
  41952. * * 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
  41953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41954. * @param name defines the name of the mesh
  41955. * @param options defines the options used to create the mesh
  41956. * @param scene defines the hosting scene
  41957. * @returns the tiled ground mesh
  41958. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41959. */
  41960. static CreateTiledGround(name: string, options: {
  41961. xmin: number;
  41962. zmin: number;
  41963. xmax: number;
  41964. zmax: number;
  41965. subdivisions?: {
  41966. w: number;
  41967. h: number;
  41968. };
  41969. precision?: {
  41970. w: number;
  41971. h: number;
  41972. };
  41973. updatable?: boolean;
  41974. }, scene?: Nullable<Scene>): Mesh;
  41975. /**
  41976. * Creates a ground mesh from a height map
  41977. * * The parameter `url` sets the URL of the height map image resource.
  41978. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41979. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41980. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41981. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41982. * * 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.
  41983. * * 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).
  41984. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41986. * @param name defines the name of the mesh
  41987. * @param url defines the url to the height map
  41988. * @param options defines the options used to create the mesh
  41989. * @param scene defines the hosting scene
  41990. * @returns the ground mesh
  41991. * @see https://doc.babylonjs.com/babylon101/height_map
  41992. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41993. */
  41994. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41995. width?: number;
  41996. height?: number;
  41997. subdivisions?: number;
  41998. minHeight?: number;
  41999. maxHeight?: number;
  42000. colorFilter?: Color3;
  42001. alphaFilter?: number;
  42002. updatable?: boolean;
  42003. onReady?: (mesh: GroundMesh) => void;
  42004. }, scene?: Nullable<Scene>): GroundMesh;
  42005. }
  42006. }
  42007. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42008. import { Vector4 } from "babylonjs/Maths/math.vector";
  42009. import { Mesh } from "babylonjs/Meshes/mesh";
  42010. /**
  42011. * Class containing static functions to help procedurally build meshes
  42012. */
  42013. export class TorusBuilder {
  42014. /**
  42015. * Creates a torus mesh
  42016. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42017. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42018. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42022. * @param name defines the name of the mesh
  42023. * @param options defines the options used to create the mesh
  42024. * @param scene defines the hosting scene
  42025. * @returns the torus mesh
  42026. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42027. */
  42028. static CreateTorus(name: string, options: {
  42029. diameter?: number;
  42030. thickness?: number;
  42031. tessellation?: number;
  42032. updatable?: boolean;
  42033. sideOrientation?: number;
  42034. frontUVs?: Vector4;
  42035. backUVs?: Vector4;
  42036. }, scene: any): Mesh;
  42037. }
  42038. }
  42039. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42040. import { Vector4 } from "babylonjs/Maths/math.vector";
  42041. import { Color4 } from "babylonjs/Maths/math.color";
  42042. import { Mesh } from "babylonjs/Meshes/mesh";
  42043. /**
  42044. * Class containing static functions to help procedurally build meshes
  42045. */
  42046. export class CylinderBuilder {
  42047. /**
  42048. * Creates a cylinder or a cone mesh
  42049. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42050. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42051. * * 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.
  42052. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42053. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42054. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42055. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42056. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  42057. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42058. * * 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).
  42059. * * 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
  42060. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42061. * * 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
  42062. * * 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.
  42063. * * If `enclose` is false, a ring surface is one element.
  42064. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42065. * * 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
  42066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42069. * @param name defines the name of the mesh
  42070. * @param options defines the options used to create the mesh
  42071. * @param scene defines the hosting scene
  42072. * @returns the cylinder mesh
  42073. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42074. */
  42075. static CreateCylinder(name: string, options: {
  42076. height?: number;
  42077. diameterTop?: number;
  42078. diameterBottom?: number;
  42079. diameter?: number;
  42080. tessellation?: number;
  42081. subdivisions?: number;
  42082. arc?: number;
  42083. faceColors?: Color4[];
  42084. faceUV?: Vector4[];
  42085. updatable?: boolean;
  42086. hasRings?: boolean;
  42087. enclose?: boolean;
  42088. cap?: number;
  42089. sideOrientation?: number;
  42090. frontUVs?: Vector4;
  42091. backUVs?: Vector4;
  42092. }, scene: any): Mesh;
  42093. }
  42094. }
  42095. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42096. import { Observable } from "babylonjs/Misc/observable";
  42097. import { Nullable } from "babylonjs/types";
  42098. import { Camera } from "babylonjs/Cameras/camera";
  42099. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42100. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42101. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42102. import { Scene } from "babylonjs/scene";
  42103. import { Vector3 } from "babylonjs/Maths/math.vector";
  42104. import { Color3 } from "babylonjs/Maths/math.color";
  42105. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42107. import { Mesh } from "babylonjs/Meshes/mesh";
  42108. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42109. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42110. import "babylonjs/Meshes/Builders/groundBuilder";
  42111. import "babylonjs/Meshes/Builders/torusBuilder";
  42112. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42113. import "babylonjs/Gamepads/gamepadSceneComponent";
  42114. import "babylonjs/Animations/animatable";
  42115. /**
  42116. * Options to modify the vr teleportation behavior.
  42117. */
  42118. export interface VRTeleportationOptions {
  42119. /**
  42120. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42121. */
  42122. floorMeshName?: string;
  42123. /**
  42124. * A list of meshes to be used as the teleportation floor. (default: empty)
  42125. */
  42126. floorMeshes?: Mesh[];
  42127. }
  42128. /**
  42129. * Options to modify the vr experience helper's behavior.
  42130. */
  42131. export interface VRExperienceHelperOptions extends WebVROptions {
  42132. /**
  42133. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42134. */
  42135. createDeviceOrientationCamera?: boolean;
  42136. /**
  42137. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42138. */
  42139. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42140. /**
  42141. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42142. */
  42143. laserToggle?: boolean;
  42144. /**
  42145. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42146. */
  42147. floorMeshes?: Mesh[];
  42148. /**
  42149. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42150. */
  42151. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42152. }
  42153. /**
  42154. * Event containing information after VR has been entered
  42155. */
  42156. export class OnAfterEnteringVRObservableEvent {
  42157. /**
  42158. * If entering vr was successful
  42159. */
  42160. success: boolean;
  42161. }
  42162. /**
  42163. * Helps to quickly add VR support to an existing scene.
  42164. * See http://doc.babylonjs.com/how_to/webvr_helper
  42165. */
  42166. export class VRExperienceHelper {
  42167. /** Options to modify the vr experience helper's behavior. */
  42168. webVROptions: VRExperienceHelperOptions;
  42169. private _scene;
  42170. private _position;
  42171. private _btnVR;
  42172. private _btnVRDisplayed;
  42173. private _webVRsupported;
  42174. private _webVRready;
  42175. private _webVRrequesting;
  42176. private _webVRpresenting;
  42177. private _hasEnteredVR;
  42178. private _fullscreenVRpresenting;
  42179. private _canvas;
  42180. private _webVRCamera;
  42181. private _vrDeviceOrientationCamera;
  42182. private _deviceOrientationCamera;
  42183. private _existingCamera;
  42184. private _onKeyDown;
  42185. private _onVrDisplayPresentChange;
  42186. private _onVRDisplayChanged;
  42187. private _onVRRequestPresentStart;
  42188. private _onVRRequestPresentComplete;
  42189. /**
  42190. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42191. */
  42192. enableGazeEvenWhenNoPointerLock: boolean;
  42193. /**
  42194. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42195. */
  42196. exitVROnDoubleTap: boolean;
  42197. /**
  42198. * Observable raised right before entering VR.
  42199. */
  42200. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42201. /**
  42202. * Observable raised when entering VR has completed.
  42203. */
  42204. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42205. /**
  42206. * Observable raised when exiting VR.
  42207. */
  42208. onExitingVRObservable: Observable<VRExperienceHelper>;
  42209. /**
  42210. * Observable raised when controller mesh is loaded.
  42211. */
  42212. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42213. /** Return this.onEnteringVRObservable
  42214. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42215. */
  42216. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42217. /** Return this.onExitingVRObservable
  42218. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42219. */
  42220. readonly onExitingVR: Observable<VRExperienceHelper>;
  42221. /** Return this.onControllerMeshLoadedObservable
  42222. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42223. */
  42224. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42225. private _rayLength;
  42226. private _useCustomVRButton;
  42227. private _teleportationRequested;
  42228. private _teleportActive;
  42229. private _floorMeshName;
  42230. private _floorMeshesCollection;
  42231. private _rotationAllowed;
  42232. private _teleportBackwardsVector;
  42233. private _teleportationTarget;
  42234. private _isDefaultTeleportationTarget;
  42235. private _postProcessMove;
  42236. private _teleportationFillColor;
  42237. private _teleportationBorderColor;
  42238. private _rotationAngle;
  42239. private _haloCenter;
  42240. private _cameraGazer;
  42241. private _padSensibilityUp;
  42242. private _padSensibilityDown;
  42243. private _leftController;
  42244. private _rightController;
  42245. /**
  42246. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42247. */
  42248. onNewMeshSelected: Observable<AbstractMesh>;
  42249. /**
  42250. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42251. */
  42252. onNewMeshPicked: Observable<PickingInfo>;
  42253. private _circleEase;
  42254. /**
  42255. * Observable raised before camera teleportation
  42256. */
  42257. onBeforeCameraTeleport: Observable<Vector3>;
  42258. /**
  42259. * Observable raised after camera teleportation
  42260. */
  42261. onAfterCameraTeleport: Observable<Vector3>;
  42262. /**
  42263. * Observable raised when current selected mesh gets unselected
  42264. */
  42265. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42266. private _raySelectionPredicate;
  42267. /**
  42268. * To be optionaly changed by user to define custom ray selection
  42269. */
  42270. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42271. /**
  42272. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42273. */
  42274. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42275. /**
  42276. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42277. */
  42278. teleportationEnabled: boolean;
  42279. private _defaultHeight;
  42280. private _teleportationInitialized;
  42281. private _interactionsEnabled;
  42282. private _interactionsRequested;
  42283. private _displayGaze;
  42284. private _displayLaserPointer;
  42285. /**
  42286. * The mesh used to display where the user is going to teleport.
  42287. */
  42288. /**
  42289. * Sets the mesh to be used to display where the user is going to teleport.
  42290. */
  42291. teleportationTarget: Mesh;
  42292. /**
  42293. * 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
  42294. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42295. * See http://doc.babylonjs.com/resources/baking_transformations
  42296. */
  42297. gazeTrackerMesh: Mesh;
  42298. /**
  42299. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42300. */
  42301. updateGazeTrackerScale: boolean;
  42302. /**
  42303. * If the gaze trackers color should be updated when selecting meshes
  42304. */
  42305. updateGazeTrackerColor: boolean;
  42306. /**
  42307. * The gaze tracking mesh corresponding to the left controller
  42308. */
  42309. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42310. /**
  42311. * The gaze tracking mesh corresponding to the right controller
  42312. */
  42313. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42314. /**
  42315. * If the ray of the gaze should be displayed.
  42316. */
  42317. /**
  42318. * Sets if the ray of the gaze should be displayed.
  42319. */
  42320. displayGaze: boolean;
  42321. /**
  42322. * If the ray of the LaserPointer should be displayed.
  42323. */
  42324. /**
  42325. * Sets if the ray of the LaserPointer should be displayed.
  42326. */
  42327. displayLaserPointer: boolean;
  42328. /**
  42329. * The deviceOrientationCamera used as the camera when not in VR.
  42330. */
  42331. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42332. /**
  42333. * Based on the current WebVR support, returns the current VR camera used.
  42334. */
  42335. readonly currentVRCamera: Nullable<Camera>;
  42336. /**
  42337. * The webVRCamera which is used when in VR.
  42338. */
  42339. readonly webVRCamera: WebVRFreeCamera;
  42340. /**
  42341. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42342. */
  42343. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42344. /**
  42345. * The html button that is used to trigger entering into VR.
  42346. */
  42347. readonly vrButton: Nullable<HTMLButtonElement>;
  42348. private readonly _teleportationRequestInitiated;
  42349. /**
  42350. * Defines wether or not Pointer lock should be requested when switching to
  42351. * full screen.
  42352. */
  42353. requestPointerLockOnFullScreen: boolean;
  42354. /**
  42355. * Instantiates a VRExperienceHelper.
  42356. * Helps to quickly add VR support to an existing scene.
  42357. * @param scene The scene the VRExperienceHelper belongs to.
  42358. * @param webVROptions Options to modify the vr experience helper's behavior.
  42359. */
  42360. constructor(scene: Scene,
  42361. /** Options to modify the vr experience helper's behavior. */
  42362. webVROptions?: VRExperienceHelperOptions);
  42363. private _onDefaultMeshLoaded;
  42364. private _onResize;
  42365. private _onFullscreenChange;
  42366. /**
  42367. * Gets a value indicating if we are currently in VR mode.
  42368. */
  42369. readonly isInVRMode: boolean;
  42370. private onVrDisplayPresentChange;
  42371. private onVRDisplayChanged;
  42372. private moveButtonToBottomRight;
  42373. private displayVRButton;
  42374. private updateButtonVisibility;
  42375. private _cachedAngularSensibility;
  42376. /**
  42377. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42378. * Otherwise, will use the fullscreen API.
  42379. */
  42380. enterVR(): void;
  42381. /**
  42382. * Attempt to exit VR, or fullscreen.
  42383. */
  42384. exitVR(): void;
  42385. /**
  42386. * The position of the vr experience helper.
  42387. */
  42388. /**
  42389. * Sets the position of the vr experience helper.
  42390. */
  42391. position: Vector3;
  42392. /**
  42393. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42394. */
  42395. enableInteractions(): void;
  42396. private readonly _noControllerIsActive;
  42397. private beforeRender;
  42398. private _isTeleportationFloor;
  42399. /**
  42400. * Adds a floor mesh to be used for teleportation.
  42401. * @param floorMesh the mesh to be used for teleportation.
  42402. */
  42403. addFloorMesh(floorMesh: Mesh): void;
  42404. /**
  42405. * Removes a floor mesh from being used for teleportation.
  42406. * @param floorMesh the mesh to be removed.
  42407. */
  42408. removeFloorMesh(floorMesh: Mesh): void;
  42409. /**
  42410. * Enables interactions and teleportation using the VR controllers and gaze.
  42411. * @param vrTeleportationOptions options to modify teleportation behavior.
  42412. */
  42413. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42414. private _onNewGamepadConnected;
  42415. private _tryEnableInteractionOnController;
  42416. private _onNewGamepadDisconnected;
  42417. private _enableInteractionOnController;
  42418. private _checkTeleportWithRay;
  42419. private _checkRotate;
  42420. private _checkTeleportBackwards;
  42421. private _enableTeleportationOnController;
  42422. private _createTeleportationCircles;
  42423. private _displayTeleportationTarget;
  42424. private _hideTeleportationTarget;
  42425. private _rotateCamera;
  42426. private _moveTeleportationSelectorTo;
  42427. private _workingVector;
  42428. private _workingQuaternion;
  42429. private _workingMatrix;
  42430. /**
  42431. * Teleports the users feet to the desired location
  42432. * @param location The location where the user's feet should be placed
  42433. */
  42434. teleportCamera(location: Vector3): void;
  42435. private _convertNormalToDirectionOfRay;
  42436. private _castRayAndSelectObject;
  42437. private _notifySelectedMeshUnselected;
  42438. /**
  42439. * Sets the color of the laser ray from the vr controllers.
  42440. * @param color new color for the ray.
  42441. */
  42442. changeLaserColor(color: Color3): void;
  42443. /**
  42444. * Sets the color of the ray from the vr headsets gaze.
  42445. * @param color new color for the ray.
  42446. */
  42447. changeGazeColor(color: Color3): void;
  42448. /**
  42449. * Exits VR and disposes of the vr experience helper
  42450. */
  42451. dispose(): void;
  42452. /**
  42453. * Gets the name of the VRExperienceHelper class
  42454. * @returns "VRExperienceHelper"
  42455. */
  42456. getClassName(): string;
  42457. }
  42458. }
  42459. declare module "babylonjs/Cameras/VR/index" {
  42460. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42461. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42462. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42463. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42464. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42465. export * from "babylonjs/Cameras/VR/webVRCamera";
  42466. }
  42467. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42468. import { Observable } from "babylonjs/Misc/observable";
  42469. import { Nullable } from "babylonjs/types";
  42470. import { IDisposable, Scene } from "babylonjs/scene";
  42471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42472. /**
  42473. * Manages an XRSession to work with Babylon's engine
  42474. * @see https://doc.babylonjs.com/how_to/webxr
  42475. */
  42476. export class WebXRSessionManager implements IDisposable {
  42477. private scene;
  42478. /**
  42479. * Fires every time a new xrFrame arrives which can be used to update the camera
  42480. */
  42481. onXRFrameObservable: Observable<any>;
  42482. /**
  42483. * Fires when the xr session is ended either by the device or manually done
  42484. */
  42485. onXRSessionEnded: Observable<any>;
  42486. /**
  42487. * Underlying xr session
  42488. */
  42489. session: XRSession;
  42490. /**
  42491. * Type of reference space used when creating the session
  42492. */
  42493. referenceSpace: XRReferenceSpace;
  42494. /** @hidden */
  42495. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42496. /**
  42497. * Current XR frame
  42498. */
  42499. currentFrame: Nullable<XRFrame>;
  42500. private _xrNavigator;
  42501. private baseLayer;
  42502. /**
  42503. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42504. * @param scene The scene which the session should be created for
  42505. */
  42506. constructor(scene: Scene);
  42507. /**
  42508. * Initializes the manager
  42509. * After initialization enterXR can be called to start an XR session
  42510. * @returns Promise which resolves after it is initialized
  42511. */
  42512. initializeAsync(): Promise<void>;
  42513. /**
  42514. * Initializes an xr session
  42515. * @param xrSessionMode mode to initialize
  42516. * @returns a promise which will resolve once the session has been initialized
  42517. */
  42518. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42519. /**
  42520. * Sets the reference space on the xr session
  42521. * @param referenceSpace space to set
  42522. * @returns a promise that will resolve once the reference space has been set
  42523. */
  42524. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42525. /**
  42526. * Updates the render state of the session
  42527. * @param state state to set
  42528. * @returns a promise that resolves once the render state has been updated
  42529. */
  42530. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42531. /**
  42532. * Starts rendering to the xr layer
  42533. * @returns a promise that will resolve once rendering has started
  42534. */
  42535. startRenderingToXRAsync(): Promise<void>;
  42536. /**
  42537. * Stops the xrSession and restores the renderloop
  42538. * @returns Promise which resolves after it exits XR
  42539. */
  42540. exitXRAsync(): Promise<unknown>;
  42541. /**
  42542. * Checks if a session would be supported for the creation options specified
  42543. * @param sessionMode session mode to check if supported eg. immersive-vr
  42544. * @returns true if supported
  42545. */
  42546. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42547. /**
  42548. * @hidden
  42549. * Converts the render layer of xrSession to a render target
  42550. * @param session session to create render target for
  42551. * @param scene scene the new render target should be created for
  42552. */
  42553. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42554. /**
  42555. * Disposes of the session manager
  42556. */
  42557. dispose(): void;
  42558. }
  42559. }
  42560. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42561. import { Scene } from "babylonjs/scene";
  42562. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42563. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42564. /**
  42565. * WebXR Camera which holds the views for the xrSession
  42566. * @see https://doc.babylonjs.com/how_to/webxr
  42567. */
  42568. export class WebXRCamera extends FreeCamera {
  42569. private static _TmpMatrix;
  42570. /**
  42571. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42572. * @param name the name of the camera
  42573. * @param scene the scene to add the camera to
  42574. */
  42575. constructor(name: string, scene: Scene);
  42576. private _updateNumberOfRigCameras;
  42577. /** @hidden */
  42578. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42579. /**
  42580. * Updates the cameras position from the current pose information of the XR session
  42581. * @param xrSessionManager the session containing pose information
  42582. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42583. */
  42584. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42585. }
  42586. }
  42587. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42588. import { Nullable } from "babylonjs/types";
  42589. import { IDisposable } from "babylonjs/scene";
  42590. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42591. /**
  42592. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42593. */
  42594. export class WebXRManagedOutputCanvas implements IDisposable {
  42595. private helper;
  42596. private _canvas;
  42597. /**
  42598. * xrpresent context of the canvas which can be used to display/mirror xr content
  42599. */
  42600. canvasContext: WebGLRenderingContext;
  42601. /**
  42602. * xr layer for the canvas
  42603. */
  42604. xrLayer: Nullable<XRWebGLLayer>;
  42605. /**
  42606. * Initializes the xr layer for the session
  42607. * @param xrSession xr session
  42608. * @returns a promise that will resolve once the XR Layer has been created
  42609. */
  42610. initializeXRLayerAsync(xrSession: any): any;
  42611. /**
  42612. * Initializes the canvas to be added/removed upon entering/exiting xr
  42613. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42614. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42615. */
  42616. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42617. /**
  42618. * Disposes of the object
  42619. */
  42620. dispose(): void;
  42621. private _setManagedOutputCanvas;
  42622. private _addCanvas;
  42623. private _removeCanvas;
  42624. }
  42625. }
  42626. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42627. import { Observable } from "babylonjs/Misc/observable";
  42628. import { IDisposable, Scene } from "babylonjs/scene";
  42629. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42631. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42632. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42633. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42634. /**
  42635. * States of the webXR experience
  42636. */
  42637. export enum WebXRState {
  42638. /**
  42639. * Transitioning to being in XR mode
  42640. */
  42641. ENTERING_XR = 0,
  42642. /**
  42643. * Transitioning to non XR mode
  42644. */
  42645. EXITING_XR = 1,
  42646. /**
  42647. * In XR mode and presenting
  42648. */
  42649. IN_XR = 2,
  42650. /**
  42651. * Not entered XR mode
  42652. */
  42653. NOT_IN_XR = 3
  42654. }
  42655. /**
  42656. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42657. * @see https://doc.babylonjs.com/how_to/webxr
  42658. */
  42659. export class WebXRExperienceHelper implements IDisposable {
  42660. private scene;
  42661. /**
  42662. * 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
  42663. */
  42664. container: AbstractMesh;
  42665. /**
  42666. * Camera used to render xr content
  42667. */
  42668. camera: WebXRCamera;
  42669. /**
  42670. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42671. */
  42672. state: WebXRState;
  42673. private _setState;
  42674. private static _TmpVector;
  42675. /**
  42676. * Fires when the state of the experience helper has changed
  42677. */
  42678. onStateChangedObservable: Observable<WebXRState>;
  42679. /** Session manager used to keep track of xr session */
  42680. sessionManager: WebXRSessionManager;
  42681. private _nonVRCamera;
  42682. private _originalSceneAutoClear;
  42683. private _supported;
  42684. /**
  42685. * Creates the experience helper
  42686. * @param scene the scene to attach the experience helper to
  42687. * @returns a promise for the experience helper
  42688. */
  42689. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42690. /**
  42691. * Creates a WebXRExperienceHelper
  42692. * @param scene The scene the helper should be created in
  42693. */
  42694. private constructor();
  42695. /**
  42696. * Exits XR mode and returns the scene to its original state
  42697. * @returns promise that resolves after xr mode has exited
  42698. */
  42699. exitXRAsync(): Promise<unknown>;
  42700. /**
  42701. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42702. * @param sessionCreationOptions options for the XR session
  42703. * @param referenceSpaceType frame of reference of the XR session
  42704. * @param outputCanvas the output canvas that will be used to enter XR mode
  42705. * @returns promise that resolves after xr mode has entered
  42706. */
  42707. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42708. /**
  42709. * Updates the global position of the camera by moving the camera's container
  42710. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42711. * @param position The desired global position of the camera
  42712. */
  42713. setPositionOfCameraUsingContainer(position: Vector3): void;
  42714. /**
  42715. * Rotates the xr camera by rotating the camera's container around the camera's position
  42716. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42717. * @param rotation the desired quaternion rotation to apply to the camera
  42718. */
  42719. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42720. /**
  42721. * Disposes of the experience helper
  42722. */
  42723. dispose(): void;
  42724. }
  42725. }
  42726. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42727. import { Nullable } from "babylonjs/types";
  42728. import { Observable } from "babylonjs/Misc/observable";
  42729. import { IDisposable, Scene } from "babylonjs/scene";
  42730. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42731. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42732. /**
  42733. * Button which can be used to enter a different mode of XR
  42734. */
  42735. export class WebXREnterExitUIButton {
  42736. /** button element */
  42737. element: HTMLElement;
  42738. /** XR initialization options for the button */
  42739. sessionMode: XRSessionMode;
  42740. /** Reference space type */
  42741. referenceSpaceType: XRReferenceSpaceType;
  42742. /**
  42743. * Creates a WebXREnterExitUIButton
  42744. * @param element button element
  42745. * @param sessionMode XR initialization session mode
  42746. * @param referenceSpaceType the type of reference space to be used
  42747. */
  42748. constructor(
  42749. /** button element */
  42750. element: HTMLElement,
  42751. /** XR initialization options for the button */
  42752. sessionMode: XRSessionMode,
  42753. /** Reference space type */
  42754. referenceSpaceType: XRReferenceSpaceType);
  42755. /**
  42756. * Overwritable function which can be used to update the button's visuals when the state changes
  42757. * @param activeButton the current active button in the UI
  42758. */
  42759. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42760. }
  42761. /**
  42762. * Options to create the webXR UI
  42763. */
  42764. export class WebXREnterExitUIOptions {
  42765. /**
  42766. * Context to enter xr with
  42767. */
  42768. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42769. /**
  42770. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42771. */
  42772. customButtons?: Array<WebXREnterExitUIButton>;
  42773. }
  42774. /**
  42775. * UI to allow the user to enter/exit XR mode
  42776. */
  42777. export class WebXREnterExitUI implements IDisposable {
  42778. private scene;
  42779. private _overlay;
  42780. private _buttons;
  42781. private _activeButton;
  42782. /**
  42783. * Fired every time the active button is changed.
  42784. *
  42785. * When xr is entered via a button that launches xr that button will be the callback parameter
  42786. *
  42787. * When exiting xr the callback parameter will be null)
  42788. */
  42789. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42790. /**
  42791. * Creates UI to allow the user to enter/exit XR mode
  42792. * @param scene the scene to add the ui to
  42793. * @param helper the xr experience helper to enter/exit xr with
  42794. * @param options options to configure the UI
  42795. * @returns the created ui
  42796. */
  42797. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42798. private constructor();
  42799. private _updateButtons;
  42800. /**
  42801. * Disposes of the object
  42802. */
  42803. dispose(): void;
  42804. }
  42805. }
  42806. declare module "babylonjs/Cameras/XR/webXRController" {
  42807. import { Nullable } from "babylonjs/types";
  42808. import { Observable } from "babylonjs/Misc/observable";
  42809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42810. import { Ray } from "babylonjs/Culling/ray";
  42811. import { Scene } from "babylonjs/scene";
  42812. /**
  42813. * Represents an XR input
  42814. */
  42815. export class WebXRController {
  42816. private scene;
  42817. /** The underlying input source for the controller */
  42818. inputSource: XRInputSource;
  42819. private parentContainer;
  42820. /**
  42821. * 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
  42822. */
  42823. grip?: AbstractMesh;
  42824. /**
  42825. * Pointer which can be used to select objects or attach a visible laser to
  42826. */
  42827. pointer: AbstractMesh;
  42828. /**
  42829. * Event that fires when the controller is removed/disposed
  42830. */
  42831. onDisposeObservable: Observable<{}>;
  42832. private _tmpMatrix;
  42833. private _tmpQuaternion;
  42834. private _tmpVector;
  42835. /**
  42836. * Creates the controller
  42837. * @see https://doc.babylonjs.com/how_to/webxr
  42838. * @param scene the scene which the controller should be associated to
  42839. * @param inputSource the underlying input source for the controller
  42840. * @param parentContainer parent that the controller meshes should be children of
  42841. */
  42842. constructor(scene: Scene,
  42843. /** The underlying input source for the controller */
  42844. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42845. /**
  42846. * Updates the controller pose based on the given XRFrame
  42847. * @param xrFrame xr frame to update the pose with
  42848. * @param referenceSpace reference space to use
  42849. */
  42850. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42851. /**
  42852. * Gets a world space ray coming from the controller
  42853. * @param result the resulting ray
  42854. */
  42855. getWorldPointerRayToRef(result: Ray): void;
  42856. /**
  42857. * Disposes of the object
  42858. */
  42859. dispose(): void;
  42860. }
  42861. }
  42862. declare module "babylonjs/Cameras/XR/webXRInput" {
  42863. import { Observable } from "babylonjs/Misc/observable";
  42864. import { IDisposable } from "babylonjs/scene";
  42865. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42866. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42867. /**
  42868. * XR input used to track XR inputs such as controllers/rays
  42869. */
  42870. export class WebXRInput implements IDisposable {
  42871. /**
  42872. * Base experience the input listens to
  42873. */
  42874. baseExperience: WebXRExperienceHelper;
  42875. /**
  42876. * XR controllers being tracked
  42877. */
  42878. controllers: Array<WebXRController>;
  42879. private _frameObserver;
  42880. private _stateObserver;
  42881. /**
  42882. * Event when a controller has been connected/added
  42883. */
  42884. onControllerAddedObservable: Observable<WebXRController>;
  42885. /**
  42886. * Event when a controller has been removed/disconnected
  42887. */
  42888. onControllerRemovedObservable: Observable<WebXRController>;
  42889. /**
  42890. * Initializes the WebXRInput
  42891. * @param baseExperience experience helper which the input should be created for
  42892. */
  42893. constructor(
  42894. /**
  42895. * Base experience the input listens to
  42896. */
  42897. baseExperience: WebXRExperienceHelper);
  42898. private _onInputSourcesChange;
  42899. private _addAndRemoveControllers;
  42900. /**
  42901. * Disposes of the object
  42902. */
  42903. dispose(): void;
  42904. }
  42905. }
  42906. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42908. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42909. /**
  42910. * Enables teleportation
  42911. */
  42912. export class WebXRControllerTeleportation {
  42913. private _teleportationFillColor;
  42914. private _teleportationBorderColor;
  42915. private _tmpRay;
  42916. private _tmpVector;
  42917. /**
  42918. * Creates a WebXRControllerTeleportation
  42919. * @param input input manager to add teleportation to
  42920. * @param floorMeshes floormeshes which can be teleported to
  42921. */
  42922. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42923. }
  42924. }
  42925. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42926. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42927. /**
  42928. * Handles pointer input automatically for the pointer of XR controllers
  42929. */
  42930. export class WebXRControllerPointerSelection {
  42931. private static _idCounter;
  42932. private _tmpRay;
  42933. /**
  42934. * Creates a WebXRControllerPointerSelection
  42935. * @param input input manager to setup pointer selection
  42936. */
  42937. constructor(input: WebXRInput);
  42938. private _convertNormalToDirectionOfRay;
  42939. private _updatePointerDistance;
  42940. }
  42941. }
  42942. declare module "babylonjs/Loading/sceneLoader" {
  42943. import { Observable } from "babylonjs/Misc/observable";
  42944. import { Nullable } from "babylonjs/types";
  42945. import { Scene } from "babylonjs/scene";
  42946. import { Engine } from "babylonjs/Engines/engine";
  42947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42948. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42949. import { AssetContainer } from "babylonjs/assetContainer";
  42950. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42951. import { Skeleton } from "babylonjs/Bones/skeleton";
  42952. /**
  42953. * Class used to represent data loading progression
  42954. */
  42955. export class SceneLoaderProgressEvent {
  42956. /** defines if data length to load can be evaluated */
  42957. readonly lengthComputable: boolean;
  42958. /** defines the loaded data length */
  42959. readonly loaded: number;
  42960. /** defines the data length to load */
  42961. readonly total: number;
  42962. /**
  42963. * Create a new progress event
  42964. * @param lengthComputable defines if data length to load can be evaluated
  42965. * @param loaded defines the loaded data length
  42966. * @param total defines the data length to load
  42967. */
  42968. constructor(
  42969. /** defines if data length to load can be evaluated */
  42970. lengthComputable: boolean,
  42971. /** defines the loaded data length */
  42972. loaded: number,
  42973. /** defines the data length to load */
  42974. total: number);
  42975. /**
  42976. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42977. * @param event defines the source event
  42978. * @returns a new SceneLoaderProgressEvent
  42979. */
  42980. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42981. }
  42982. /**
  42983. * Interface used by SceneLoader plugins to define supported file extensions
  42984. */
  42985. export interface ISceneLoaderPluginExtensions {
  42986. /**
  42987. * Defines the list of supported extensions
  42988. */
  42989. [extension: string]: {
  42990. isBinary: boolean;
  42991. };
  42992. }
  42993. /**
  42994. * Interface used by SceneLoader plugin factory
  42995. */
  42996. export interface ISceneLoaderPluginFactory {
  42997. /**
  42998. * Defines the name of the factory
  42999. */
  43000. name: string;
  43001. /**
  43002. * Function called to create a new plugin
  43003. * @return the new plugin
  43004. */
  43005. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43006. /**
  43007. * Boolean indicating if the plugin can direct load specific data
  43008. */
  43009. canDirectLoad?: (data: string) => boolean;
  43010. }
  43011. /**
  43012. * Interface used to define a SceneLoader plugin
  43013. */
  43014. export interface ISceneLoaderPlugin {
  43015. /**
  43016. * The friendly name of this plugin.
  43017. */
  43018. name: string;
  43019. /**
  43020. * The file extensions supported by this plugin.
  43021. */
  43022. extensions: string | ISceneLoaderPluginExtensions;
  43023. /**
  43024. * Import meshes into a scene.
  43025. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43026. * @param scene The scene to import into
  43027. * @param data The data to import
  43028. * @param rootUrl The root url for scene and resources
  43029. * @param meshes The meshes array to import into
  43030. * @param particleSystems The particle systems array to import into
  43031. * @param skeletons The skeletons array to import into
  43032. * @param onError The callback when import fails
  43033. * @returns True if successful or false otherwise
  43034. */
  43035. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43036. /**
  43037. * Load into a scene.
  43038. * @param scene The scene to load into
  43039. * @param data The data to import
  43040. * @param rootUrl The root url for scene and resources
  43041. * @param onError The callback when import fails
  43042. * @returns true if successful or false otherwise
  43043. */
  43044. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43045. /**
  43046. * The callback that returns true if the data can be directly loaded.
  43047. */
  43048. canDirectLoad?: (data: string) => boolean;
  43049. /**
  43050. * The callback that allows custom handling of the root url based on the response url.
  43051. */
  43052. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43053. /**
  43054. * Load into an asset container.
  43055. * @param scene The scene to load into
  43056. * @param data The data to import
  43057. * @param rootUrl The root url for scene and resources
  43058. * @param onError The callback when import fails
  43059. * @returns The loaded asset container
  43060. */
  43061. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43062. }
  43063. /**
  43064. * Interface used to define an async SceneLoader plugin
  43065. */
  43066. export interface ISceneLoaderPluginAsync {
  43067. /**
  43068. * The friendly name of this plugin.
  43069. */
  43070. name: string;
  43071. /**
  43072. * The file extensions supported by this plugin.
  43073. */
  43074. extensions: string | ISceneLoaderPluginExtensions;
  43075. /**
  43076. * Import meshes into a scene.
  43077. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43078. * @param scene The scene to import into
  43079. * @param data The data to import
  43080. * @param rootUrl The root url for scene and resources
  43081. * @param onProgress The callback when the load progresses
  43082. * @param fileName Defines the name of the file to load
  43083. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43084. */
  43085. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43086. meshes: AbstractMesh[];
  43087. particleSystems: IParticleSystem[];
  43088. skeletons: Skeleton[];
  43089. animationGroups: AnimationGroup[];
  43090. }>;
  43091. /**
  43092. * Load into a scene.
  43093. * @param scene The scene to load into
  43094. * @param data The data to import
  43095. * @param rootUrl The root url for scene and resources
  43096. * @param onProgress The callback when the load progresses
  43097. * @param fileName Defines the name of the file to load
  43098. * @returns Nothing
  43099. */
  43100. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43101. /**
  43102. * The callback that returns true if the data can be directly loaded.
  43103. */
  43104. canDirectLoad?: (data: string) => boolean;
  43105. /**
  43106. * The callback that allows custom handling of the root url based on the response url.
  43107. */
  43108. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43109. /**
  43110. * Load into an asset container.
  43111. * @param scene The scene to load into
  43112. * @param data The data to import
  43113. * @param rootUrl The root url for scene and resources
  43114. * @param onProgress The callback when the load progresses
  43115. * @param fileName Defines the name of the file to load
  43116. * @returns The loaded asset container
  43117. */
  43118. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43119. }
  43120. /**
  43121. * Class used to load scene from various file formats using registered plugins
  43122. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43123. */
  43124. export class SceneLoader {
  43125. /**
  43126. * No logging while loading
  43127. */
  43128. static readonly NO_LOGGING: number;
  43129. /**
  43130. * Minimal logging while loading
  43131. */
  43132. static readonly MINIMAL_LOGGING: number;
  43133. /**
  43134. * Summary logging while loading
  43135. */
  43136. static readonly SUMMARY_LOGGING: number;
  43137. /**
  43138. * Detailled logging while loading
  43139. */
  43140. static readonly DETAILED_LOGGING: number;
  43141. /**
  43142. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43143. */
  43144. static ForceFullSceneLoadingForIncremental: boolean;
  43145. /**
  43146. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43147. */
  43148. static ShowLoadingScreen: boolean;
  43149. /**
  43150. * Defines the current logging level (while loading the scene)
  43151. * @ignorenaming
  43152. */
  43153. static loggingLevel: number;
  43154. /**
  43155. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43156. */
  43157. static CleanBoneMatrixWeights: boolean;
  43158. /**
  43159. * Event raised when a plugin is used to load a scene
  43160. */
  43161. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43162. private static _registeredPlugins;
  43163. private static _getDefaultPlugin;
  43164. private static _getPluginForExtension;
  43165. private static _getPluginForDirectLoad;
  43166. private static _getPluginForFilename;
  43167. private static _getDirectLoad;
  43168. private static _loadData;
  43169. private static _getFileInfo;
  43170. /**
  43171. * Gets a plugin that can load the given extension
  43172. * @param extension defines the extension to load
  43173. * @returns a plugin or null if none works
  43174. */
  43175. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43176. /**
  43177. * Gets a boolean indicating that the given extension can be loaded
  43178. * @param extension defines the extension to load
  43179. * @returns true if the extension is supported
  43180. */
  43181. static IsPluginForExtensionAvailable(extension: string): boolean;
  43182. /**
  43183. * Adds a new plugin to the list of registered plugins
  43184. * @param plugin defines the plugin to add
  43185. */
  43186. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43187. /**
  43188. * Import meshes into a scene
  43189. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43190. * @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)
  43191. * @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)
  43192. * @param scene the instance of BABYLON.Scene to append to
  43193. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43194. * @param onProgress a callback with a progress event for each file being loaded
  43195. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43196. * @param pluginExtension the extension used to determine the plugin
  43197. * @returns The loaded plugin
  43198. */
  43199. 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>;
  43200. /**
  43201. * Import meshes into a scene
  43202. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43203. * @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)
  43204. * @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)
  43205. * @param scene the instance of BABYLON.Scene to append to
  43206. * @param onProgress a callback with a progress event for each file being loaded
  43207. * @param pluginExtension the extension used to determine the plugin
  43208. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43209. */
  43210. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43211. meshes: AbstractMesh[];
  43212. particleSystems: IParticleSystem[];
  43213. skeletons: Skeleton[];
  43214. animationGroups: AnimationGroup[];
  43215. }>;
  43216. /**
  43217. * Load a scene
  43218. * @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)
  43219. * @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)
  43220. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43221. * @param onSuccess a callback with the scene when import succeeds
  43222. * @param onProgress a callback with a progress event for each file being loaded
  43223. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43224. * @param pluginExtension the extension used to determine the plugin
  43225. * @returns The loaded plugin
  43226. */
  43227. 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>;
  43228. /**
  43229. * Load a scene
  43230. * @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)
  43231. * @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)
  43232. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43233. * @param onProgress a callback with a progress event for each file being loaded
  43234. * @param pluginExtension the extension used to determine the plugin
  43235. * @returns The loaded scene
  43236. */
  43237. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43238. /**
  43239. * Append a scene
  43240. * @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)
  43241. * @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)
  43242. * @param scene is the instance of BABYLON.Scene to append to
  43243. * @param onSuccess a callback with the scene when import succeeds
  43244. * @param onProgress a callback with a progress event for each file being loaded
  43245. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43246. * @param pluginExtension the extension used to determine the plugin
  43247. * @returns The loaded plugin
  43248. */
  43249. 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>;
  43250. /**
  43251. * Append a scene
  43252. * @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)
  43253. * @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)
  43254. * @param scene is the instance of BABYLON.Scene to append to
  43255. * @param onProgress a callback with a progress event for each file being loaded
  43256. * @param pluginExtension the extension used to determine the plugin
  43257. * @returns The given scene
  43258. */
  43259. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43260. /**
  43261. * Load a scene into an asset container
  43262. * @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)
  43263. * @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)
  43264. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43265. * @param onSuccess a callback with the scene when import succeeds
  43266. * @param onProgress a callback with a progress event for each file being loaded
  43267. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43268. * @param pluginExtension the extension used to determine the plugin
  43269. * @returns The loaded plugin
  43270. */
  43271. 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>;
  43272. /**
  43273. * Load a scene into an asset container
  43274. * @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)
  43275. * @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)
  43276. * @param scene is the instance of Scene to append to
  43277. * @param onProgress a callback with a progress event for each file being loaded
  43278. * @param pluginExtension the extension used to determine the plugin
  43279. * @returns The loaded asset container
  43280. */
  43281. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43282. }
  43283. }
  43284. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43285. import { Scene } from "babylonjs/scene";
  43286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43287. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43288. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43289. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43290. /**
  43291. * Generic Controller
  43292. */
  43293. export class GenericController extends WebVRController {
  43294. /**
  43295. * Base Url for the controller model.
  43296. */
  43297. static readonly MODEL_BASE_URL: string;
  43298. /**
  43299. * File name for the controller model.
  43300. */
  43301. static readonly MODEL_FILENAME: string;
  43302. /**
  43303. * Creates a new GenericController from a gamepad
  43304. * @param vrGamepad the gamepad that the controller should be created from
  43305. */
  43306. constructor(vrGamepad: any);
  43307. /**
  43308. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43309. * @param scene scene in which to add meshes
  43310. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43311. */
  43312. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43313. /**
  43314. * Called once for each button that changed state since the last frame
  43315. * @param buttonIdx Which button index changed
  43316. * @param state New state of the button
  43317. * @param changes Which properties on the state changed since last frame
  43318. */
  43319. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43320. }
  43321. }
  43322. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43323. import { Observable } from "babylonjs/Misc/observable";
  43324. import { Scene } from "babylonjs/scene";
  43325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43326. import { Ray } from "babylonjs/Culling/ray";
  43327. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43328. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43329. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43330. /**
  43331. * Defines the WindowsMotionController object that the state of the windows motion controller
  43332. */
  43333. export class WindowsMotionController extends WebVRController {
  43334. /**
  43335. * The base url used to load the left and right controller models
  43336. */
  43337. static MODEL_BASE_URL: string;
  43338. /**
  43339. * The name of the left controller model file
  43340. */
  43341. static MODEL_LEFT_FILENAME: string;
  43342. /**
  43343. * The name of the right controller model file
  43344. */
  43345. static MODEL_RIGHT_FILENAME: string;
  43346. /**
  43347. * The controller name prefix for this controller type
  43348. */
  43349. static readonly GAMEPAD_ID_PREFIX: string;
  43350. /**
  43351. * The controller id pattern for this controller type
  43352. */
  43353. private static readonly GAMEPAD_ID_PATTERN;
  43354. private _loadedMeshInfo;
  43355. private readonly _mapping;
  43356. /**
  43357. * Fired when the trackpad on this controller is clicked
  43358. */
  43359. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43360. /**
  43361. * Fired when the trackpad on this controller is modified
  43362. */
  43363. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43364. /**
  43365. * The current x and y values of this controller's trackpad
  43366. */
  43367. trackpad: StickValues;
  43368. /**
  43369. * Creates a new WindowsMotionController from a gamepad
  43370. * @param vrGamepad the gamepad that the controller should be created from
  43371. */
  43372. constructor(vrGamepad: any);
  43373. /**
  43374. * Fired when the trigger on this controller is modified
  43375. */
  43376. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43377. /**
  43378. * Fired when the menu button on this controller is modified
  43379. */
  43380. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43381. /**
  43382. * Fired when the grip button on this controller is modified
  43383. */
  43384. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43385. /**
  43386. * Fired when the thumbstick button on this controller is modified
  43387. */
  43388. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43389. /**
  43390. * Fired when the touchpad button on this controller is modified
  43391. */
  43392. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43393. /**
  43394. * Fired when the touchpad values on this controller are modified
  43395. */
  43396. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43397. private _updateTrackpad;
  43398. /**
  43399. * Called once per frame by the engine.
  43400. */
  43401. update(): void;
  43402. /**
  43403. * Called once for each button that changed state since the last frame
  43404. * @param buttonIdx Which button index changed
  43405. * @param state New state of the button
  43406. * @param changes Which properties on the state changed since last frame
  43407. */
  43408. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43409. /**
  43410. * Moves the buttons on the controller mesh based on their current state
  43411. * @param buttonName the name of the button to move
  43412. * @param buttonValue the value of the button which determines the buttons new position
  43413. */
  43414. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43415. /**
  43416. * Moves the axis on the controller mesh based on its current state
  43417. * @param axis the index of the axis
  43418. * @param axisValue the value of the axis which determines the meshes new position
  43419. * @hidden
  43420. */
  43421. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43422. /**
  43423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43424. * @param scene scene in which to add meshes
  43425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43426. */
  43427. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43428. /**
  43429. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43430. * can be transformed by button presses and axes values, based on this._mapping.
  43431. *
  43432. * @param scene scene in which the meshes exist
  43433. * @param meshes list of meshes that make up the controller model to process
  43434. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43435. */
  43436. private processModel;
  43437. private createMeshInfo;
  43438. /**
  43439. * Gets the ray of the controller in the direction the controller is pointing
  43440. * @param length the length the resulting ray should be
  43441. * @returns a ray in the direction the controller is pointing
  43442. */
  43443. getForwardRay(length?: number): Ray;
  43444. /**
  43445. * Disposes of the controller
  43446. */
  43447. dispose(): void;
  43448. }
  43449. }
  43450. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43451. import { Observable } from "babylonjs/Misc/observable";
  43452. import { Scene } from "babylonjs/scene";
  43453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43454. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43455. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43456. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43457. /**
  43458. * Oculus Touch Controller
  43459. */
  43460. export class OculusTouchController extends WebVRController {
  43461. /**
  43462. * Base Url for the controller model.
  43463. */
  43464. static MODEL_BASE_URL: string;
  43465. /**
  43466. * File name for the left controller model.
  43467. */
  43468. static MODEL_LEFT_FILENAME: string;
  43469. /**
  43470. * File name for the right controller model.
  43471. */
  43472. static MODEL_RIGHT_FILENAME: string;
  43473. /**
  43474. * Base Url for the Quest controller model.
  43475. */
  43476. static QUEST_MODEL_BASE_URL: string;
  43477. /**
  43478. * @hidden
  43479. * If the controllers are running on a device that needs the updated Quest controller models
  43480. */
  43481. static _IsQuest: boolean;
  43482. /**
  43483. * Fired when the secondary trigger on this controller is modified
  43484. */
  43485. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43486. /**
  43487. * Fired when the thumb rest on this controller is modified
  43488. */
  43489. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43490. /**
  43491. * Creates a new OculusTouchController from a gamepad
  43492. * @param vrGamepad the gamepad that the controller should be created from
  43493. */
  43494. constructor(vrGamepad: any);
  43495. /**
  43496. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43497. * @param scene scene in which to add meshes
  43498. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43499. */
  43500. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43501. /**
  43502. * Fired when the A button on this controller is modified
  43503. */
  43504. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43505. /**
  43506. * Fired when the B button on this controller is modified
  43507. */
  43508. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43509. /**
  43510. * Fired when the X button on this controller is modified
  43511. */
  43512. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43513. /**
  43514. * Fired when the Y button on this controller is modified
  43515. */
  43516. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43517. /**
  43518. * Called once for each button that changed state since the last frame
  43519. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43520. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43521. * 2) secondary trigger (same)
  43522. * 3) A (right) X (left), touch, pressed = value
  43523. * 4) B / Y
  43524. * 5) thumb rest
  43525. * @param buttonIdx Which button index changed
  43526. * @param state New state of the button
  43527. * @param changes Which properties on the state changed since last frame
  43528. */
  43529. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43530. }
  43531. }
  43532. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43533. import { Scene } from "babylonjs/scene";
  43534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43535. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43536. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43537. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43538. import { Observable } from "babylonjs/Misc/observable";
  43539. /**
  43540. * Vive Controller
  43541. */
  43542. export class ViveController extends WebVRController {
  43543. /**
  43544. * Base Url for the controller model.
  43545. */
  43546. static MODEL_BASE_URL: string;
  43547. /**
  43548. * File name for the controller model.
  43549. */
  43550. static MODEL_FILENAME: string;
  43551. /**
  43552. * Creates a new ViveController from a gamepad
  43553. * @param vrGamepad the gamepad that the controller should be created from
  43554. */
  43555. constructor(vrGamepad: any);
  43556. /**
  43557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43558. * @param scene scene in which to add meshes
  43559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43560. */
  43561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43562. /**
  43563. * Fired when the left button on this controller is modified
  43564. */
  43565. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43566. /**
  43567. * Fired when the right button on this controller is modified
  43568. */
  43569. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43570. /**
  43571. * Fired when the menu button on this controller is modified
  43572. */
  43573. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43574. /**
  43575. * Called once for each button that changed state since the last frame
  43576. * Vive mapping:
  43577. * 0: touchpad
  43578. * 1: trigger
  43579. * 2: left AND right buttons
  43580. * 3: menu button
  43581. * @param buttonIdx Which button index changed
  43582. * @param state New state of the button
  43583. * @param changes Which properties on the state changed since last frame
  43584. */
  43585. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43586. }
  43587. }
  43588. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43589. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43590. /**
  43591. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43592. */
  43593. export class WebXRControllerModelLoader {
  43594. /**
  43595. * Creates the WebXRControllerModelLoader
  43596. * @param input xr input that creates the controllers
  43597. */
  43598. constructor(input: WebXRInput);
  43599. }
  43600. }
  43601. declare module "babylonjs/Cameras/XR/index" {
  43602. export * from "babylonjs/Cameras/XR/webXRCamera";
  43603. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43604. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43605. export * from "babylonjs/Cameras/XR/webXRInput";
  43606. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43607. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43608. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43609. export * from "babylonjs/Cameras/XR/webXRController";
  43610. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43611. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43612. }
  43613. declare module "babylonjs/Cameras/RigModes/index" {
  43614. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43615. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43616. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43617. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43618. }
  43619. declare module "babylonjs/Cameras/index" {
  43620. export * from "babylonjs/Cameras/Inputs/index";
  43621. export * from "babylonjs/Cameras/cameraInputsManager";
  43622. export * from "babylonjs/Cameras/camera";
  43623. export * from "babylonjs/Cameras/targetCamera";
  43624. export * from "babylonjs/Cameras/freeCamera";
  43625. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43626. export * from "babylonjs/Cameras/touchCamera";
  43627. export * from "babylonjs/Cameras/arcRotateCamera";
  43628. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43629. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43630. export * from "babylonjs/Cameras/flyCamera";
  43631. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43632. export * from "babylonjs/Cameras/followCamera";
  43633. export * from "babylonjs/Cameras/gamepadCamera";
  43634. export * from "babylonjs/Cameras/Stereoscopic/index";
  43635. export * from "babylonjs/Cameras/universalCamera";
  43636. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43637. export * from "babylonjs/Cameras/VR/index";
  43638. export * from "babylonjs/Cameras/XR/index";
  43639. export * from "babylonjs/Cameras/RigModes/index";
  43640. }
  43641. declare module "babylonjs/Collisions/index" {
  43642. export * from "babylonjs/Collisions/collider";
  43643. export * from "babylonjs/Collisions/collisionCoordinator";
  43644. export * from "babylonjs/Collisions/pickingInfo";
  43645. export * from "babylonjs/Collisions/intersectionInfo";
  43646. export * from "babylonjs/Collisions/meshCollisionData";
  43647. }
  43648. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43649. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43650. import { Vector3 } from "babylonjs/Maths/math.vector";
  43651. import { Ray } from "babylonjs/Culling/ray";
  43652. import { Plane } from "babylonjs/Maths/math.plane";
  43653. /**
  43654. * Contains an array of blocks representing the octree
  43655. */
  43656. export interface IOctreeContainer<T> {
  43657. /**
  43658. * Blocks within the octree
  43659. */
  43660. blocks: Array<OctreeBlock<T>>;
  43661. }
  43662. /**
  43663. * Class used to store a cell in an octree
  43664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43665. */
  43666. export class OctreeBlock<T> {
  43667. /**
  43668. * Gets the content of the current block
  43669. */
  43670. entries: T[];
  43671. /**
  43672. * Gets the list of block children
  43673. */
  43674. blocks: Array<OctreeBlock<T>>;
  43675. private _depth;
  43676. private _maxDepth;
  43677. private _capacity;
  43678. private _minPoint;
  43679. private _maxPoint;
  43680. private _boundingVectors;
  43681. private _creationFunc;
  43682. /**
  43683. * Creates a new block
  43684. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43685. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43686. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43687. * @param depth defines the current depth of this block in the octree
  43688. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43689. * @param creationFunc defines a callback to call when an element is added to the block
  43690. */
  43691. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43692. /**
  43693. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43694. */
  43695. readonly capacity: number;
  43696. /**
  43697. * Gets the minimum vector (in world space) of the block's bounding box
  43698. */
  43699. readonly minPoint: Vector3;
  43700. /**
  43701. * Gets the maximum vector (in world space) of the block's bounding box
  43702. */
  43703. readonly maxPoint: Vector3;
  43704. /**
  43705. * Add a new element to this block
  43706. * @param entry defines the element to add
  43707. */
  43708. addEntry(entry: T): void;
  43709. /**
  43710. * Remove an element from this block
  43711. * @param entry defines the element to remove
  43712. */
  43713. removeEntry(entry: T): void;
  43714. /**
  43715. * Add an array of elements to this block
  43716. * @param entries defines the array of elements to add
  43717. */
  43718. addEntries(entries: T[]): void;
  43719. /**
  43720. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43721. * @param frustumPlanes defines the frustum planes to test
  43722. * @param selection defines the array to store current content if selection is positive
  43723. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43724. */
  43725. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43726. /**
  43727. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43728. * @param sphereCenter defines the bounding sphere center
  43729. * @param sphereRadius defines the bounding sphere radius
  43730. * @param selection defines the array to store current content if selection is positive
  43731. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43732. */
  43733. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43734. /**
  43735. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43736. * @param ray defines the ray to test with
  43737. * @param selection defines the array to store current content if selection is positive
  43738. */
  43739. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43740. /**
  43741. * Subdivide the content into child blocks (this block will then be empty)
  43742. */
  43743. createInnerBlocks(): void;
  43744. /**
  43745. * @hidden
  43746. */
  43747. 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;
  43748. }
  43749. }
  43750. declare module "babylonjs/Culling/Octrees/octree" {
  43751. import { SmartArray } from "babylonjs/Misc/smartArray";
  43752. import { Vector3 } from "babylonjs/Maths/math.vector";
  43753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43755. import { Ray } from "babylonjs/Culling/ray";
  43756. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43757. import { Plane } from "babylonjs/Maths/math.plane";
  43758. /**
  43759. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43760. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43761. */
  43762. export class Octree<T> {
  43763. /** 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.) */
  43764. maxDepth: number;
  43765. /**
  43766. * Blocks within the octree containing objects
  43767. */
  43768. blocks: Array<OctreeBlock<T>>;
  43769. /**
  43770. * Content stored in the octree
  43771. */
  43772. dynamicContent: T[];
  43773. private _maxBlockCapacity;
  43774. private _selectionContent;
  43775. private _creationFunc;
  43776. /**
  43777. * Creates a octree
  43778. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43779. * @param creationFunc function to be used to instatiate the octree
  43780. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43781. * @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.)
  43782. */
  43783. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43784. /** 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.) */
  43785. maxDepth?: number);
  43786. /**
  43787. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43788. * @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);
  43789. * @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);
  43790. * @param entries meshes to be added to the octree blocks
  43791. */
  43792. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43793. /**
  43794. * Adds a mesh to the octree
  43795. * @param entry Mesh to add to the octree
  43796. */
  43797. addMesh(entry: T): void;
  43798. /**
  43799. * Remove an element from the octree
  43800. * @param entry defines the element to remove
  43801. */
  43802. removeMesh(entry: T): void;
  43803. /**
  43804. * Selects an array of meshes within the frustum
  43805. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43806. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43807. * @returns array of meshes within the frustum
  43808. */
  43809. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43810. /**
  43811. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43812. * @param sphereCenter defines the bounding sphere center
  43813. * @param sphereRadius defines the bounding sphere radius
  43814. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43815. * @returns an array of objects that intersect the sphere
  43816. */
  43817. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43818. /**
  43819. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43820. * @param ray defines the ray to test with
  43821. * @returns array of intersected objects
  43822. */
  43823. intersectsRay(ray: Ray): SmartArray<T>;
  43824. /**
  43825. * Adds a mesh into the octree block if it intersects the block
  43826. */
  43827. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43828. /**
  43829. * Adds a submesh into the octree block if it intersects the block
  43830. */
  43831. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43832. }
  43833. }
  43834. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43835. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43836. import { Scene } from "babylonjs/scene";
  43837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43839. import { Ray } from "babylonjs/Culling/ray";
  43840. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43841. import { Collider } from "babylonjs/Collisions/collider";
  43842. module "babylonjs/scene" {
  43843. interface Scene {
  43844. /**
  43845. * @hidden
  43846. * Backing Filed
  43847. */
  43848. _selectionOctree: Octree<AbstractMesh>;
  43849. /**
  43850. * Gets the octree used to boost mesh selection (picking)
  43851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43852. */
  43853. selectionOctree: Octree<AbstractMesh>;
  43854. /**
  43855. * Creates or updates the octree used to boost selection (picking)
  43856. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43857. * @param maxCapacity defines the maximum capacity per leaf
  43858. * @param maxDepth defines the maximum depth of the octree
  43859. * @returns an octree of AbstractMesh
  43860. */
  43861. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43862. }
  43863. }
  43864. module "babylonjs/Meshes/abstractMesh" {
  43865. interface AbstractMesh {
  43866. /**
  43867. * @hidden
  43868. * Backing Field
  43869. */
  43870. _submeshesOctree: Octree<SubMesh>;
  43871. /**
  43872. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43873. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43874. * @param maxCapacity defines the maximum size of each block (64 by default)
  43875. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43876. * @returns the new octree
  43877. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43879. */
  43880. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43881. }
  43882. }
  43883. /**
  43884. * Defines the octree scene component responsible to manage any octrees
  43885. * in a given scene.
  43886. */
  43887. export class OctreeSceneComponent {
  43888. /**
  43889. * The component name help to identify the component in the list of scene components.
  43890. */
  43891. readonly name: string;
  43892. /**
  43893. * The scene the component belongs to.
  43894. */
  43895. scene: Scene;
  43896. /**
  43897. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43898. */
  43899. readonly checksIsEnabled: boolean;
  43900. /**
  43901. * Creates a new instance of the component for the given scene
  43902. * @param scene Defines the scene to register the component in
  43903. */
  43904. constructor(scene: Scene);
  43905. /**
  43906. * Registers the component in a given scene
  43907. */
  43908. register(): void;
  43909. /**
  43910. * Return the list of active meshes
  43911. * @returns the list of active meshes
  43912. */
  43913. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43914. /**
  43915. * Return the list of active sub meshes
  43916. * @param mesh The mesh to get the candidates sub meshes from
  43917. * @returns the list of active sub meshes
  43918. */
  43919. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43920. private _tempRay;
  43921. /**
  43922. * Return the list of sub meshes intersecting with a given local ray
  43923. * @param mesh defines the mesh to find the submesh for
  43924. * @param localRay defines the ray in local space
  43925. * @returns the list of intersecting sub meshes
  43926. */
  43927. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43928. /**
  43929. * Return the list of sub meshes colliding with a collider
  43930. * @param mesh defines the mesh to find the submesh for
  43931. * @param collider defines the collider to evaluate the collision against
  43932. * @returns the list of colliding sub meshes
  43933. */
  43934. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43935. /**
  43936. * Rebuilds the elements related to this component in case of
  43937. * context lost for instance.
  43938. */
  43939. rebuild(): void;
  43940. /**
  43941. * Disposes the component and the associated ressources.
  43942. */
  43943. dispose(): void;
  43944. }
  43945. }
  43946. declare module "babylonjs/Culling/Octrees/index" {
  43947. export * from "babylonjs/Culling/Octrees/octree";
  43948. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43949. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43950. }
  43951. declare module "babylonjs/Culling/index" {
  43952. export * from "babylonjs/Culling/boundingBox";
  43953. export * from "babylonjs/Culling/boundingInfo";
  43954. export * from "babylonjs/Culling/boundingSphere";
  43955. export * from "babylonjs/Culling/Octrees/index";
  43956. export * from "babylonjs/Culling/ray";
  43957. }
  43958. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43959. import { IDisposable, Scene } from "babylonjs/scene";
  43960. import { Nullable } from "babylonjs/types";
  43961. import { Observable } from "babylonjs/Misc/observable";
  43962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43963. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43964. import { Camera } from "babylonjs/Cameras/camera";
  43965. /**
  43966. * Renders a layer on top of an existing scene
  43967. */
  43968. export class UtilityLayerRenderer implements IDisposable {
  43969. /** the original scene that will be rendered on top of */
  43970. originalScene: Scene;
  43971. private _pointerCaptures;
  43972. private _lastPointerEvents;
  43973. private static _DefaultUtilityLayer;
  43974. private static _DefaultKeepDepthUtilityLayer;
  43975. private _sharedGizmoLight;
  43976. private _renderCamera;
  43977. /**
  43978. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43979. * @returns the camera that is used when rendering the utility layer
  43980. */
  43981. getRenderCamera(): Nullable<Camera>;
  43982. /**
  43983. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43984. * @param cam the camera that should be used when rendering the utility layer
  43985. */
  43986. setRenderCamera(cam: Nullable<Camera>): void;
  43987. /**
  43988. * @hidden
  43989. * Light which used by gizmos to get light shading
  43990. */
  43991. _getSharedGizmoLight(): HemisphericLight;
  43992. /**
  43993. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43994. */
  43995. pickUtilitySceneFirst: boolean;
  43996. /**
  43997. * 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)
  43998. */
  43999. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44000. /**
  44001. * 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)
  44002. */
  44003. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44004. /**
  44005. * The scene that is rendered on top of the original scene
  44006. */
  44007. utilityLayerScene: Scene;
  44008. /**
  44009. * If the utility layer should automatically be rendered on top of existing scene
  44010. */
  44011. shouldRender: boolean;
  44012. /**
  44013. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44014. */
  44015. onlyCheckPointerDownEvents: boolean;
  44016. /**
  44017. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44018. */
  44019. processAllEvents: boolean;
  44020. /**
  44021. * Observable raised when the pointer move from the utility layer scene to the main scene
  44022. */
  44023. onPointerOutObservable: Observable<number>;
  44024. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44025. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44026. private _afterRenderObserver;
  44027. private _sceneDisposeObserver;
  44028. private _originalPointerObserver;
  44029. /**
  44030. * Instantiates a UtilityLayerRenderer
  44031. * @param originalScene the original scene that will be rendered on top of
  44032. * @param handleEvents boolean indicating if the utility layer should handle events
  44033. */
  44034. constructor(
  44035. /** the original scene that will be rendered on top of */
  44036. originalScene: Scene, handleEvents?: boolean);
  44037. private _notifyObservers;
  44038. /**
  44039. * Renders the utility layers scene on top of the original scene
  44040. */
  44041. render(): void;
  44042. /**
  44043. * Disposes of the renderer
  44044. */
  44045. dispose(): void;
  44046. private _updateCamera;
  44047. }
  44048. }
  44049. declare module "babylonjs/Gizmos/gizmo" {
  44050. import { Nullable } from "babylonjs/types";
  44051. import { IDisposable } from "babylonjs/scene";
  44052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44053. import { Mesh } from "babylonjs/Meshes/mesh";
  44054. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44055. /**
  44056. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44057. */
  44058. export class Gizmo implements IDisposable {
  44059. /** The utility layer the gizmo will be added to */
  44060. gizmoLayer: UtilityLayerRenderer;
  44061. /**
  44062. * The root mesh of the gizmo
  44063. */
  44064. _rootMesh: Mesh;
  44065. private _attachedMesh;
  44066. /**
  44067. * Ratio for the scale of the gizmo (Default: 1)
  44068. */
  44069. scaleRatio: number;
  44070. /**
  44071. * If a custom mesh has been set (Default: false)
  44072. */
  44073. protected _customMeshSet: boolean;
  44074. /**
  44075. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44076. * * When set, interactions will be enabled
  44077. */
  44078. attachedMesh: Nullable<AbstractMesh>;
  44079. /**
  44080. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44081. * @param mesh The mesh to replace the default mesh of the gizmo
  44082. */
  44083. setCustomMesh(mesh: Mesh): void;
  44084. /**
  44085. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44086. */
  44087. updateGizmoRotationToMatchAttachedMesh: boolean;
  44088. /**
  44089. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44090. */
  44091. updateGizmoPositionToMatchAttachedMesh: boolean;
  44092. /**
  44093. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44094. */
  44095. updateScale: boolean;
  44096. protected _interactionsEnabled: boolean;
  44097. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44098. private _beforeRenderObserver;
  44099. private _tempVector;
  44100. /**
  44101. * Creates a gizmo
  44102. * @param gizmoLayer The utility layer the gizmo will be added to
  44103. */
  44104. constructor(
  44105. /** The utility layer the gizmo will be added to */
  44106. gizmoLayer?: UtilityLayerRenderer);
  44107. /**
  44108. * Updates the gizmo to match the attached mesh's position/rotation
  44109. */
  44110. protected _update(): void;
  44111. /**
  44112. * Disposes of the gizmo
  44113. */
  44114. dispose(): void;
  44115. }
  44116. }
  44117. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44118. import { Observable } from "babylonjs/Misc/observable";
  44119. import { Nullable } from "babylonjs/types";
  44120. import { Vector3 } from "babylonjs/Maths/math.vector";
  44121. import { Color3 } from "babylonjs/Maths/math.color";
  44122. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44124. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44125. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44126. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44127. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44128. import { Scene } from "babylonjs/scene";
  44129. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44130. /**
  44131. * Single plane drag gizmo
  44132. */
  44133. export class PlaneDragGizmo extends Gizmo {
  44134. /**
  44135. * Drag behavior responsible for the gizmos dragging interactions
  44136. */
  44137. dragBehavior: PointerDragBehavior;
  44138. private _pointerObserver;
  44139. /**
  44140. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44141. */
  44142. snapDistance: number;
  44143. /**
  44144. * Event that fires each time the gizmo snaps to a new location.
  44145. * * snapDistance is the the change in distance
  44146. */
  44147. onSnapObservable: Observable<{
  44148. snapDistance: number;
  44149. }>;
  44150. private _plane;
  44151. private _coloredMaterial;
  44152. private _hoverMaterial;
  44153. private _isEnabled;
  44154. private _parent;
  44155. /** @hidden */
  44156. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44157. /** @hidden */
  44158. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44159. /**
  44160. * Creates a PlaneDragGizmo
  44161. * @param gizmoLayer The utility layer the gizmo will be added to
  44162. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44163. * @param color The color of the gizmo
  44164. */
  44165. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44166. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44167. /**
  44168. * If the gizmo is enabled
  44169. */
  44170. isEnabled: boolean;
  44171. /**
  44172. * Disposes of the gizmo
  44173. */
  44174. dispose(): void;
  44175. }
  44176. }
  44177. declare module "babylonjs/Gizmos/positionGizmo" {
  44178. import { Observable } from "babylonjs/Misc/observable";
  44179. import { Nullable } from "babylonjs/types";
  44180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44181. import { Mesh } from "babylonjs/Meshes/mesh";
  44182. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44183. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44184. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44185. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44186. /**
  44187. * Gizmo that enables dragging a mesh along 3 axis
  44188. */
  44189. export class PositionGizmo extends Gizmo {
  44190. /**
  44191. * Internal gizmo used for interactions on the x axis
  44192. */
  44193. xGizmo: AxisDragGizmo;
  44194. /**
  44195. * Internal gizmo used for interactions on the y axis
  44196. */
  44197. yGizmo: AxisDragGizmo;
  44198. /**
  44199. * Internal gizmo used for interactions on the z axis
  44200. */
  44201. zGizmo: AxisDragGizmo;
  44202. /**
  44203. * Internal gizmo used for interactions on the yz plane
  44204. */
  44205. xPlaneGizmo: PlaneDragGizmo;
  44206. /**
  44207. * Internal gizmo used for interactions on the xz plane
  44208. */
  44209. yPlaneGizmo: PlaneDragGizmo;
  44210. /**
  44211. * Internal gizmo used for interactions on the xy plane
  44212. */
  44213. zPlaneGizmo: PlaneDragGizmo;
  44214. /**
  44215. * private variables
  44216. */
  44217. private _meshAttached;
  44218. private _updateGizmoRotationToMatchAttachedMesh;
  44219. private _snapDistance;
  44220. private _scaleRatio;
  44221. /** Fires an event when any of it's sub gizmos are dragged */
  44222. onDragStartObservable: Observable<unknown>;
  44223. /** Fires an event when any of it's sub gizmos are released from dragging */
  44224. onDragEndObservable: Observable<unknown>;
  44225. /**
  44226. * If set to true, planar drag is enabled
  44227. */
  44228. private _planarGizmoEnabled;
  44229. attachedMesh: Nullable<AbstractMesh>;
  44230. /**
  44231. * Creates a PositionGizmo
  44232. * @param gizmoLayer The utility layer the gizmo will be added to
  44233. */
  44234. constructor(gizmoLayer?: UtilityLayerRenderer);
  44235. /**
  44236. * If the planar drag gizmo is enabled
  44237. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44238. */
  44239. planarGizmoEnabled: boolean;
  44240. updateGizmoRotationToMatchAttachedMesh: boolean;
  44241. /**
  44242. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44243. */
  44244. snapDistance: number;
  44245. /**
  44246. * Ratio for the scale of the gizmo (Default: 1)
  44247. */
  44248. scaleRatio: number;
  44249. /**
  44250. * Disposes of the gizmo
  44251. */
  44252. dispose(): void;
  44253. /**
  44254. * CustomMeshes are not supported by this gizmo
  44255. * @param mesh The mesh to replace the default mesh of the gizmo
  44256. */
  44257. setCustomMesh(mesh: Mesh): void;
  44258. }
  44259. }
  44260. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44261. import { Observable } from "babylonjs/Misc/observable";
  44262. import { Nullable } from "babylonjs/types";
  44263. import { Vector3 } from "babylonjs/Maths/math.vector";
  44264. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44266. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44267. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44268. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44269. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44270. import { Scene } from "babylonjs/scene";
  44271. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44272. import { Color3 } from "babylonjs/Maths/math.color";
  44273. /**
  44274. * Single axis drag gizmo
  44275. */
  44276. export class AxisDragGizmo extends Gizmo {
  44277. /**
  44278. * Drag behavior responsible for the gizmos dragging interactions
  44279. */
  44280. dragBehavior: PointerDragBehavior;
  44281. private _pointerObserver;
  44282. /**
  44283. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44284. */
  44285. snapDistance: number;
  44286. /**
  44287. * Event that fires each time the gizmo snaps to a new location.
  44288. * * snapDistance is the the change in distance
  44289. */
  44290. onSnapObservable: Observable<{
  44291. snapDistance: number;
  44292. }>;
  44293. private _isEnabled;
  44294. private _parent;
  44295. private _arrow;
  44296. private _coloredMaterial;
  44297. private _hoverMaterial;
  44298. /** @hidden */
  44299. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44300. /** @hidden */
  44301. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44302. /**
  44303. * Creates an AxisDragGizmo
  44304. * @param gizmoLayer The utility layer the gizmo will be added to
  44305. * @param dragAxis The axis which the gizmo will be able to drag on
  44306. * @param color The color of the gizmo
  44307. */
  44308. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44309. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44310. /**
  44311. * If the gizmo is enabled
  44312. */
  44313. isEnabled: boolean;
  44314. /**
  44315. * Disposes of the gizmo
  44316. */
  44317. dispose(): void;
  44318. }
  44319. }
  44320. declare module "babylonjs/Debug/axesViewer" {
  44321. import { Vector3 } from "babylonjs/Maths/math.vector";
  44322. import { Nullable } from "babylonjs/types";
  44323. import { Scene } from "babylonjs/scene";
  44324. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44325. /**
  44326. * The Axes viewer will show 3 axes in a specific point in space
  44327. */
  44328. export class AxesViewer {
  44329. private _xAxis;
  44330. private _yAxis;
  44331. private _zAxis;
  44332. private _scaleLinesFactor;
  44333. private _instanced;
  44334. /**
  44335. * Gets the hosting scene
  44336. */
  44337. scene: Scene;
  44338. /**
  44339. * Gets or sets a number used to scale line length
  44340. */
  44341. scaleLines: number;
  44342. /** Gets the node hierarchy used to render x-axis */
  44343. readonly xAxis: TransformNode;
  44344. /** Gets the node hierarchy used to render y-axis */
  44345. readonly yAxis: TransformNode;
  44346. /** Gets the node hierarchy used to render z-axis */
  44347. readonly zAxis: TransformNode;
  44348. /**
  44349. * Creates a new AxesViewer
  44350. * @param scene defines the hosting scene
  44351. * @param scaleLines defines a number used to scale line length (1 by default)
  44352. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44353. * @param xAxis defines the node hierarchy used to render the x-axis
  44354. * @param yAxis defines the node hierarchy used to render the y-axis
  44355. * @param zAxis defines the node hierarchy used to render the z-axis
  44356. */
  44357. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44358. /**
  44359. * Force the viewer to update
  44360. * @param position defines the position of the viewer
  44361. * @param xaxis defines the x axis of the viewer
  44362. * @param yaxis defines the y axis of the viewer
  44363. * @param zaxis defines the z axis of the viewer
  44364. */
  44365. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44366. /**
  44367. * Creates an instance of this axes viewer.
  44368. * @returns a new axes viewer with instanced meshes
  44369. */
  44370. createInstance(): AxesViewer;
  44371. /** Releases resources */
  44372. dispose(): void;
  44373. private static _SetRenderingGroupId;
  44374. }
  44375. }
  44376. declare module "babylonjs/Debug/boneAxesViewer" {
  44377. import { Nullable } from "babylonjs/types";
  44378. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44379. import { Vector3 } from "babylonjs/Maths/math.vector";
  44380. import { Mesh } from "babylonjs/Meshes/mesh";
  44381. import { Bone } from "babylonjs/Bones/bone";
  44382. import { Scene } from "babylonjs/scene";
  44383. /**
  44384. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44385. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44386. */
  44387. export class BoneAxesViewer extends AxesViewer {
  44388. /**
  44389. * Gets or sets the target mesh where to display the axes viewer
  44390. */
  44391. mesh: Nullable<Mesh>;
  44392. /**
  44393. * Gets or sets the target bone where to display the axes viewer
  44394. */
  44395. bone: Nullable<Bone>;
  44396. /** Gets current position */
  44397. pos: Vector3;
  44398. /** Gets direction of X axis */
  44399. xaxis: Vector3;
  44400. /** Gets direction of Y axis */
  44401. yaxis: Vector3;
  44402. /** Gets direction of Z axis */
  44403. zaxis: Vector3;
  44404. /**
  44405. * Creates a new BoneAxesViewer
  44406. * @param scene defines the hosting scene
  44407. * @param bone defines the target bone
  44408. * @param mesh defines the target mesh
  44409. * @param scaleLines defines a scaling factor for line length (1 by default)
  44410. */
  44411. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44412. /**
  44413. * Force the viewer to update
  44414. */
  44415. update(): void;
  44416. /** Releases resources */
  44417. dispose(): void;
  44418. }
  44419. }
  44420. declare module "babylonjs/Debug/debugLayer" {
  44421. import { Scene } from "babylonjs/scene";
  44422. /**
  44423. * Interface used to define scene explorer extensibility option
  44424. */
  44425. export interface IExplorerExtensibilityOption {
  44426. /**
  44427. * Define the option label
  44428. */
  44429. label: string;
  44430. /**
  44431. * Defines the action to execute on click
  44432. */
  44433. action: (entity: any) => void;
  44434. }
  44435. /**
  44436. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44437. */
  44438. export interface IExplorerExtensibilityGroup {
  44439. /**
  44440. * Defines a predicate to test if a given type mut be extended
  44441. */
  44442. predicate: (entity: any) => boolean;
  44443. /**
  44444. * Gets the list of options added to a type
  44445. */
  44446. entries: IExplorerExtensibilityOption[];
  44447. }
  44448. /**
  44449. * Interface used to define the options to use to create the Inspector
  44450. */
  44451. export interface IInspectorOptions {
  44452. /**
  44453. * Display in overlay mode (default: false)
  44454. */
  44455. overlay?: boolean;
  44456. /**
  44457. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44458. */
  44459. globalRoot?: HTMLElement;
  44460. /**
  44461. * Display the Scene explorer
  44462. */
  44463. showExplorer?: boolean;
  44464. /**
  44465. * Display the property inspector
  44466. */
  44467. showInspector?: boolean;
  44468. /**
  44469. * Display in embed mode (both panes on the right)
  44470. */
  44471. embedMode?: boolean;
  44472. /**
  44473. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44474. */
  44475. handleResize?: boolean;
  44476. /**
  44477. * Allow the panes to popup (default: true)
  44478. */
  44479. enablePopup?: boolean;
  44480. /**
  44481. * Allow the panes to be closed by users (default: true)
  44482. */
  44483. enableClose?: boolean;
  44484. /**
  44485. * Optional list of extensibility entries
  44486. */
  44487. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44488. /**
  44489. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44490. */
  44491. inspectorURL?: string;
  44492. }
  44493. module "babylonjs/scene" {
  44494. interface Scene {
  44495. /**
  44496. * @hidden
  44497. * Backing field
  44498. */
  44499. _debugLayer: DebugLayer;
  44500. /**
  44501. * Gets the debug layer (aka Inspector) associated with the scene
  44502. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44503. */
  44504. debugLayer: DebugLayer;
  44505. }
  44506. }
  44507. /**
  44508. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44509. * what is happening in your scene
  44510. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44511. */
  44512. export class DebugLayer {
  44513. /**
  44514. * Define the url to get the inspector script from.
  44515. * By default it uses the babylonjs CDN.
  44516. * @ignoreNaming
  44517. */
  44518. static InspectorURL: string;
  44519. private _scene;
  44520. private BJSINSPECTOR;
  44521. private _onPropertyChangedObservable?;
  44522. /**
  44523. * Observable triggered when a property is changed through the inspector.
  44524. */
  44525. readonly onPropertyChangedObservable: any;
  44526. /**
  44527. * Instantiates a new debug layer.
  44528. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44529. * what is happening in your scene
  44530. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44531. * @param scene Defines the scene to inspect
  44532. */
  44533. constructor(scene: Scene);
  44534. /** Creates the inspector window. */
  44535. private _createInspector;
  44536. /**
  44537. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44538. * @param entity defines the entity to select
  44539. * @param lineContainerTitle defines the specific block to highlight
  44540. */
  44541. select(entity: any, lineContainerTitle?: string): void;
  44542. /** Get the inspector from bundle or global */
  44543. private _getGlobalInspector;
  44544. /**
  44545. * Get if the inspector is visible or not.
  44546. * @returns true if visible otherwise, false
  44547. */
  44548. isVisible(): boolean;
  44549. /**
  44550. * Hide the inspector and close its window.
  44551. */
  44552. hide(): void;
  44553. /**
  44554. * Launch the debugLayer.
  44555. * @param config Define the configuration of the inspector
  44556. * @return a promise fulfilled when the debug layer is visible
  44557. */
  44558. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44559. }
  44560. }
  44561. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44562. import { Nullable } from "babylonjs/types";
  44563. import { Scene } from "babylonjs/scene";
  44564. import { Vector4 } from "babylonjs/Maths/math.vector";
  44565. import { Color4 } from "babylonjs/Maths/math.color";
  44566. import { Mesh } from "babylonjs/Meshes/mesh";
  44567. /**
  44568. * Class containing static functions to help procedurally build meshes
  44569. */
  44570. export class BoxBuilder {
  44571. /**
  44572. * Creates a box mesh
  44573. * * The parameter `size` sets the size (float) of each box side (default 1)
  44574. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44575. * * 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)
  44576. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44580. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44581. * @param name defines the name of the mesh
  44582. * @param options defines the options used to create the mesh
  44583. * @param scene defines the hosting scene
  44584. * @returns the box mesh
  44585. */
  44586. static CreateBox(name: string, options: {
  44587. size?: number;
  44588. width?: number;
  44589. height?: number;
  44590. depth?: number;
  44591. faceUV?: Vector4[];
  44592. faceColors?: Color4[];
  44593. sideOrientation?: number;
  44594. frontUVs?: Vector4;
  44595. backUVs?: Vector4;
  44596. wrap?: boolean;
  44597. topBaseAt?: number;
  44598. bottomBaseAt?: number;
  44599. updatable?: boolean;
  44600. }, scene?: Nullable<Scene>): Mesh;
  44601. }
  44602. }
  44603. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44604. import { Vector4 } from "babylonjs/Maths/math.vector";
  44605. import { Mesh } from "babylonjs/Meshes/mesh";
  44606. /**
  44607. * Class containing static functions to help procedurally build meshes
  44608. */
  44609. export class SphereBuilder {
  44610. /**
  44611. * Creates a sphere mesh
  44612. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44613. * * 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`)
  44614. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44615. * * 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
  44616. * * 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)
  44617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44620. * @param name defines the name of the mesh
  44621. * @param options defines the options used to create the mesh
  44622. * @param scene defines the hosting scene
  44623. * @returns the sphere mesh
  44624. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44625. */
  44626. static CreateSphere(name: string, options: {
  44627. segments?: number;
  44628. diameter?: number;
  44629. diameterX?: number;
  44630. diameterY?: number;
  44631. diameterZ?: number;
  44632. arc?: number;
  44633. slice?: number;
  44634. sideOrientation?: number;
  44635. frontUVs?: Vector4;
  44636. backUVs?: Vector4;
  44637. updatable?: boolean;
  44638. }, scene: any): Mesh;
  44639. }
  44640. }
  44641. declare module "babylonjs/Debug/physicsViewer" {
  44642. import { Nullable } from "babylonjs/types";
  44643. import { Scene } from "babylonjs/scene";
  44644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44645. import { Mesh } from "babylonjs/Meshes/mesh";
  44646. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44647. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44648. /**
  44649. * Used to show the physics impostor around the specific mesh
  44650. */
  44651. export class PhysicsViewer {
  44652. /** @hidden */
  44653. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44654. /** @hidden */
  44655. protected _meshes: Array<Nullable<AbstractMesh>>;
  44656. /** @hidden */
  44657. protected _scene: Nullable<Scene>;
  44658. /** @hidden */
  44659. protected _numMeshes: number;
  44660. /** @hidden */
  44661. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44662. private _renderFunction;
  44663. private _utilityLayer;
  44664. private _debugBoxMesh;
  44665. private _debugSphereMesh;
  44666. private _debugCylinderMesh;
  44667. private _debugMaterial;
  44668. private _debugMeshMeshes;
  44669. /**
  44670. * Creates a new PhysicsViewer
  44671. * @param scene defines the hosting scene
  44672. */
  44673. constructor(scene: Scene);
  44674. /** @hidden */
  44675. protected _updateDebugMeshes(): void;
  44676. /**
  44677. * Renders a specified physic impostor
  44678. * @param impostor defines the impostor to render
  44679. * @param targetMesh defines the mesh represented by the impostor
  44680. * @returns the new debug mesh used to render the impostor
  44681. */
  44682. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44683. /**
  44684. * Hides a specified physic impostor
  44685. * @param impostor defines the impostor to hide
  44686. */
  44687. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44688. private _getDebugMaterial;
  44689. private _getDebugBoxMesh;
  44690. private _getDebugSphereMesh;
  44691. private _getDebugCylinderMesh;
  44692. private _getDebugMeshMesh;
  44693. private _getDebugMesh;
  44694. /** Releases all resources */
  44695. dispose(): void;
  44696. }
  44697. }
  44698. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44699. import { Vector3 } from "babylonjs/Maths/math.vector";
  44700. import { Color4 } from "babylonjs/Maths/math.color";
  44701. import { Nullable } from "babylonjs/types";
  44702. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44703. import { Scene } from "babylonjs/scene";
  44704. /**
  44705. * Class containing static functions to help procedurally build meshes
  44706. */
  44707. export class LinesBuilder {
  44708. /**
  44709. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44710. * * 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
  44711. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44712. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44713. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44714. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44715. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44716. * * 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
  44717. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44720. * @param name defines the name of the new line system
  44721. * @param options defines the options used to create the line system
  44722. * @param scene defines the hosting scene
  44723. * @returns a new line system mesh
  44724. */
  44725. static CreateLineSystem(name: string, options: {
  44726. lines: Vector3[][];
  44727. updatable?: boolean;
  44728. instance?: Nullable<LinesMesh>;
  44729. colors?: Nullable<Color4[][]>;
  44730. useVertexAlpha?: boolean;
  44731. }, scene: Nullable<Scene>): LinesMesh;
  44732. /**
  44733. * Creates a line mesh
  44734. * 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
  44735. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44736. * * The parameter `points` is an array successive Vector3
  44737. * * 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
  44738. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44739. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44740. * * When updating an instance, remember that only point positions can change, not the number of points
  44741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44742. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44743. * @param name defines the name of the new line system
  44744. * @param options defines the options used to create the line system
  44745. * @param scene defines the hosting scene
  44746. * @returns a new line mesh
  44747. */
  44748. static CreateLines(name: string, options: {
  44749. points: Vector3[];
  44750. updatable?: boolean;
  44751. instance?: Nullable<LinesMesh>;
  44752. colors?: Color4[];
  44753. useVertexAlpha?: boolean;
  44754. }, scene?: Nullable<Scene>): LinesMesh;
  44755. /**
  44756. * Creates a dashed line mesh
  44757. * * 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
  44758. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44759. * * The parameter `points` is an array successive Vector3
  44760. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44761. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44762. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44763. * * 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
  44764. * * When updating an instance, remember that only point positions can change, not the number of points
  44765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44766. * @param name defines the name of the mesh
  44767. * @param options defines the options used to create the mesh
  44768. * @param scene defines the hosting scene
  44769. * @returns the dashed line mesh
  44770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44771. */
  44772. static CreateDashedLines(name: string, options: {
  44773. points: Vector3[];
  44774. dashSize?: number;
  44775. gapSize?: number;
  44776. dashNb?: number;
  44777. updatable?: boolean;
  44778. instance?: LinesMesh;
  44779. }, scene?: Nullable<Scene>): LinesMesh;
  44780. }
  44781. }
  44782. declare module "babylonjs/Debug/rayHelper" {
  44783. import { Nullable } from "babylonjs/types";
  44784. import { Ray } from "babylonjs/Culling/ray";
  44785. import { Vector3 } from "babylonjs/Maths/math.vector";
  44786. import { Color3 } from "babylonjs/Maths/math.color";
  44787. import { Scene } from "babylonjs/scene";
  44788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44789. import "babylonjs/Meshes/Builders/linesBuilder";
  44790. /**
  44791. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44792. * in order to better appreciate the issue one might have.
  44793. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44794. */
  44795. export class RayHelper {
  44796. /**
  44797. * Defines the ray we are currently tryin to visualize.
  44798. */
  44799. ray: Nullable<Ray>;
  44800. private _renderPoints;
  44801. private _renderLine;
  44802. private _renderFunction;
  44803. private _scene;
  44804. private _updateToMeshFunction;
  44805. private _attachedToMesh;
  44806. private _meshSpaceDirection;
  44807. private _meshSpaceOrigin;
  44808. /**
  44809. * Helper function to create a colored helper in a scene in one line.
  44810. * @param ray Defines the ray we are currently tryin to visualize
  44811. * @param scene Defines the scene the ray is used in
  44812. * @param color Defines the color we want to see the ray in
  44813. * @returns The newly created ray helper.
  44814. */
  44815. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44816. /**
  44817. * Instantiate a new ray helper.
  44818. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44819. * in order to better appreciate the issue one might have.
  44820. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44821. * @param ray Defines the ray we are currently tryin to visualize
  44822. */
  44823. constructor(ray: Ray);
  44824. /**
  44825. * Shows the ray we are willing to debug.
  44826. * @param scene Defines the scene the ray needs to be rendered in
  44827. * @param color Defines the color the ray needs to be rendered in
  44828. */
  44829. show(scene: Scene, color?: Color3): void;
  44830. /**
  44831. * Hides the ray we are debugging.
  44832. */
  44833. hide(): void;
  44834. private _render;
  44835. /**
  44836. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44837. * @param mesh Defines the mesh we want the helper attached to
  44838. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44839. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44840. * @param length Defines the length of the ray
  44841. */
  44842. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44843. /**
  44844. * Detach the ray helper from the mesh it has previously been attached to.
  44845. */
  44846. detachFromMesh(): void;
  44847. private _updateToMesh;
  44848. /**
  44849. * Dispose the helper and release its associated resources.
  44850. */
  44851. dispose(): void;
  44852. }
  44853. }
  44854. declare module "babylonjs/Debug/skeletonViewer" {
  44855. import { Color3 } from "babylonjs/Maths/math.color";
  44856. import { Scene } from "babylonjs/scene";
  44857. import { Nullable } from "babylonjs/types";
  44858. import { Skeleton } from "babylonjs/Bones/skeleton";
  44859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44861. /**
  44862. * Class used to render a debug view of a given skeleton
  44863. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44864. */
  44865. export class SkeletonViewer {
  44866. /** defines the skeleton to render */
  44867. skeleton: Skeleton;
  44868. /** defines the mesh attached to the skeleton */
  44869. mesh: AbstractMesh;
  44870. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44871. autoUpdateBonesMatrices: boolean;
  44872. /** defines the rendering group id to use with the viewer */
  44873. renderingGroupId: number;
  44874. /** Gets or sets the color used to render the skeleton */
  44875. color: Color3;
  44876. private _scene;
  44877. private _debugLines;
  44878. private _debugMesh;
  44879. private _isEnabled;
  44880. private _renderFunction;
  44881. private _utilityLayer;
  44882. /**
  44883. * Returns the mesh used to render the bones
  44884. */
  44885. readonly debugMesh: Nullable<LinesMesh>;
  44886. /**
  44887. * Creates a new SkeletonViewer
  44888. * @param skeleton defines the skeleton to render
  44889. * @param mesh defines the mesh attached to the skeleton
  44890. * @param scene defines the hosting scene
  44891. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44892. * @param renderingGroupId defines the rendering group id to use with the viewer
  44893. */
  44894. constructor(
  44895. /** defines the skeleton to render */
  44896. skeleton: Skeleton,
  44897. /** defines the mesh attached to the skeleton */
  44898. mesh: AbstractMesh, scene: Scene,
  44899. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44900. autoUpdateBonesMatrices?: boolean,
  44901. /** defines the rendering group id to use with the viewer */
  44902. renderingGroupId?: number);
  44903. /** Gets or sets a boolean indicating if the viewer is enabled */
  44904. isEnabled: boolean;
  44905. private _getBonePosition;
  44906. private _getLinesForBonesWithLength;
  44907. private _getLinesForBonesNoLength;
  44908. /** Update the viewer to sync with current skeleton state */
  44909. update(): void;
  44910. /** Release associated resources */
  44911. dispose(): void;
  44912. }
  44913. }
  44914. declare module "babylonjs/Debug/index" {
  44915. export * from "babylonjs/Debug/axesViewer";
  44916. export * from "babylonjs/Debug/boneAxesViewer";
  44917. export * from "babylonjs/Debug/debugLayer";
  44918. export * from "babylonjs/Debug/physicsViewer";
  44919. export * from "babylonjs/Debug/rayHelper";
  44920. export * from "babylonjs/Debug/skeletonViewer";
  44921. }
  44922. declare module "babylonjs/Engines/nullEngine" {
  44923. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44924. import { Scene } from "babylonjs/scene";
  44925. import { Engine } from "babylonjs/Engines/engine";
  44926. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44927. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44929. import { Effect } from "babylonjs/Materials/effect";
  44930. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44931. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44932. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44933. /**
  44934. * Options to create the null engine
  44935. */
  44936. export class NullEngineOptions {
  44937. /**
  44938. * Render width (Default: 512)
  44939. */
  44940. renderWidth: number;
  44941. /**
  44942. * Render height (Default: 256)
  44943. */
  44944. renderHeight: number;
  44945. /**
  44946. * Texture size (Default: 512)
  44947. */
  44948. textureSize: number;
  44949. /**
  44950. * If delta time between frames should be constant
  44951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44952. */
  44953. deterministicLockstep: boolean;
  44954. /**
  44955. * Maximum about of steps between frames (Default: 4)
  44956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44957. */
  44958. lockstepMaxSteps: number;
  44959. }
  44960. /**
  44961. * The null engine class provides support for headless version of babylon.js.
  44962. * This can be used in server side scenario or for testing purposes
  44963. */
  44964. export class NullEngine extends Engine {
  44965. private _options;
  44966. /**
  44967. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44968. */
  44969. isDeterministicLockStep(): boolean;
  44970. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44971. getLockstepMaxSteps(): number;
  44972. /**
  44973. * Sets hardware scaling, used to save performance if needed
  44974. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44975. */
  44976. getHardwareScalingLevel(): number;
  44977. constructor(options?: NullEngineOptions);
  44978. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44979. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44980. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44981. getRenderWidth(useScreen?: boolean): number;
  44982. getRenderHeight(useScreen?: boolean): number;
  44983. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44984. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44985. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44986. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44987. bindSamplers(effect: Effect): void;
  44988. enableEffect(effect: Effect): void;
  44989. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44990. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44991. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44992. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44993. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44994. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44995. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44996. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44997. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44998. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44999. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45000. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45001. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45002. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45003. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45004. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45005. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45006. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45007. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45008. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45009. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45010. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45011. bindBuffers(vertexBuffers: {
  45012. [key: string]: VertexBuffer;
  45013. }, indexBuffer: DataBuffer, effect: Effect): void;
  45014. wipeCaches(bruteForce?: boolean): void;
  45015. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45016. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45017. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45018. /** @hidden */
  45019. _createTexture(): WebGLTexture;
  45020. /** @hidden */
  45021. _releaseTexture(texture: InternalTexture): void;
  45022. 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;
  45023. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45024. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45025. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45026. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45027. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45028. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45029. areAllEffectsReady(): boolean;
  45030. /**
  45031. * @hidden
  45032. * Get the current error code of the webGL context
  45033. * @returns the error code
  45034. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45035. */
  45036. getError(): number;
  45037. /** @hidden */
  45038. _getUnpackAlignement(): number;
  45039. /** @hidden */
  45040. _unpackFlipY(value: boolean): void;
  45041. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45042. /**
  45043. * Updates a dynamic vertex buffer.
  45044. * @param vertexBuffer the vertex buffer to update
  45045. * @param data the data used to update the vertex buffer
  45046. * @param byteOffset the byte offset of the data (optional)
  45047. * @param byteLength the byte length of the data (optional)
  45048. */
  45049. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45050. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45051. /** @hidden */
  45052. _bindTexture(channel: number, texture: InternalTexture): void;
  45053. /** @hidden */
  45054. _releaseBuffer(buffer: DataBuffer): boolean;
  45055. releaseEffects(): void;
  45056. displayLoadingUI(): void;
  45057. hideLoadingUI(): void;
  45058. /** @hidden */
  45059. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45060. /** @hidden */
  45061. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45062. /** @hidden */
  45063. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45064. /** @hidden */
  45065. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45066. }
  45067. }
  45068. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45069. import { Nullable, int } from "babylonjs/types";
  45070. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45071. /** @hidden */
  45072. export class _OcclusionDataStorage {
  45073. /** @hidden */
  45074. occlusionInternalRetryCounter: number;
  45075. /** @hidden */
  45076. isOcclusionQueryInProgress: boolean;
  45077. /** @hidden */
  45078. isOccluded: boolean;
  45079. /** @hidden */
  45080. occlusionRetryCount: number;
  45081. /** @hidden */
  45082. occlusionType: number;
  45083. /** @hidden */
  45084. occlusionQueryAlgorithmType: number;
  45085. }
  45086. module "babylonjs/Engines/engine" {
  45087. interface Engine {
  45088. /**
  45089. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45090. * @return the new query
  45091. */
  45092. createQuery(): WebGLQuery;
  45093. /**
  45094. * Delete and release a webGL query
  45095. * @param query defines the query to delete
  45096. * @return the current engine
  45097. */
  45098. deleteQuery(query: WebGLQuery): Engine;
  45099. /**
  45100. * Check if a given query has resolved and got its value
  45101. * @param query defines the query to check
  45102. * @returns true if the query got its value
  45103. */
  45104. isQueryResultAvailable(query: WebGLQuery): boolean;
  45105. /**
  45106. * Gets the value of a given query
  45107. * @param query defines the query to check
  45108. * @returns the value of the query
  45109. */
  45110. getQueryResult(query: WebGLQuery): number;
  45111. /**
  45112. * Initiates an occlusion query
  45113. * @param algorithmType defines the algorithm to use
  45114. * @param query defines the query to use
  45115. * @returns the current engine
  45116. * @see http://doc.babylonjs.com/features/occlusionquery
  45117. */
  45118. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45119. /**
  45120. * Ends an occlusion query
  45121. * @see http://doc.babylonjs.com/features/occlusionquery
  45122. * @param algorithmType defines the algorithm to use
  45123. * @returns the current engine
  45124. */
  45125. endOcclusionQuery(algorithmType: number): Engine;
  45126. /**
  45127. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45128. * Please note that only one query can be issued at a time
  45129. * @returns a time token used to track the time span
  45130. */
  45131. startTimeQuery(): Nullable<_TimeToken>;
  45132. /**
  45133. * Ends a time query
  45134. * @param token defines the token used to measure the time span
  45135. * @returns the time spent (in ns)
  45136. */
  45137. endTimeQuery(token: _TimeToken): int;
  45138. /** @hidden */
  45139. _currentNonTimestampToken: Nullable<_TimeToken>;
  45140. /** @hidden */
  45141. _createTimeQuery(): WebGLQuery;
  45142. /** @hidden */
  45143. _deleteTimeQuery(query: WebGLQuery): void;
  45144. /** @hidden */
  45145. _getGlAlgorithmType(algorithmType: number): number;
  45146. /** @hidden */
  45147. _getTimeQueryResult(query: WebGLQuery): any;
  45148. /** @hidden */
  45149. _getTimeQueryAvailability(query: WebGLQuery): any;
  45150. }
  45151. }
  45152. module "babylonjs/Meshes/abstractMesh" {
  45153. interface AbstractMesh {
  45154. /**
  45155. * Backing filed
  45156. * @hidden
  45157. */
  45158. __occlusionDataStorage: _OcclusionDataStorage;
  45159. /**
  45160. * Access property
  45161. * @hidden
  45162. */
  45163. _occlusionDataStorage: _OcclusionDataStorage;
  45164. /**
  45165. * 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.
  45166. * The default value is -1 which means don't break the query and wait till the result
  45167. * @see http://doc.babylonjs.com/features/occlusionquery
  45168. */
  45169. occlusionRetryCount: number;
  45170. /**
  45171. * 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:
  45172. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45173. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45174. * * 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.
  45175. * @see http://doc.babylonjs.com/features/occlusionquery
  45176. */
  45177. occlusionType: number;
  45178. /**
  45179. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45180. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45181. * * 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.
  45182. * @see http://doc.babylonjs.com/features/occlusionquery
  45183. */
  45184. occlusionQueryAlgorithmType: number;
  45185. /**
  45186. * 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
  45187. * @see http://doc.babylonjs.com/features/occlusionquery
  45188. */
  45189. isOccluded: boolean;
  45190. /**
  45191. * Flag to check the progress status of the query
  45192. * @see http://doc.babylonjs.com/features/occlusionquery
  45193. */
  45194. isOcclusionQueryInProgress: boolean;
  45195. }
  45196. }
  45197. }
  45198. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45199. import { Nullable } from "babylonjs/types";
  45200. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45201. /** @hidden */
  45202. export var _forceTransformFeedbackToBundle: boolean;
  45203. module "babylonjs/Engines/engine" {
  45204. interface Engine {
  45205. /**
  45206. * Creates a webGL transform feedback object
  45207. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45208. * @returns the webGL transform feedback object
  45209. */
  45210. createTransformFeedback(): WebGLTransformFeedback;
  45211. /**
  45212. * Delete a webGL transform feedback object
  45213. * @param value defines the webGL transform feedback object to delete
  45214. */
  45215. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45216. /**
  45217. * Bind a webGL transform feedback object to the webgl context
  45218. * @param value defines the webGL transform feedback object to bind
  45219. */
  45220. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45221. /**
  45222. * Begins a transform feedback operation
  45223. * @param usePoints defines if points or triangles must be used
  45224. */
  45225. beginTransformFeedback(usePoints: boolean): void;
  45226. /**
  45227. * Ends a transform feedback operation
  45228. */
  45229. endTransformFeedback(): void;
  45230. /**
  45231. * Specify the varyings to use with transform feedback
  45232. * @param program defines the associated webGL program
  45233. * @param value defines the list of strings representing the varying names
  45234. */
  45235. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45236. /**
  45237. * Bind a webGL buffer for a transform feedback operation
  45238. * @param value defines the webGL buffer to bind
  45239. */
  45240. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45241. }
  45242. }
  45243. }
  45244. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45245. import { Scene } from "babylonjs/scene";
  45246. import { Engine } from "babylonjs/Engines/engine";
  45247. import { Texture } from "babylonjs/Materials/Textures/texture";
  45248. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45249. import "babylonjs/Engines/Extensions/engine.multiRender";
  45250. /**
  45251. * Creation options of the multi render target texture.
  45252. */
  45253. export interface IMultiRenderTargetOptions {
  45254. /**
  45255. * Define if the texture needs to create mip maps after render.
  45256. */
  45257. generateMipMaps?: boolean;
  45258. /**
  45259. * Define the types of all the draw buffers we want to create
  45260. */
  45261. types?: number[];
  45262. /**
  45263. * Define the sampling modes of all the draw buffers we want to create
  45264. */
  45265. samplingModes?: number[];
  45266. /**
  45267. * Define if a depth buffer is required
  45268. */
  45269. generateDepthBuffer?: boolean;
  45270. /**
  45271. * Define if a stencil buffer is required
  45272. */
  45273. generateStencilBuffer?: boolean;
  45274. /**
  45275. * Define if a depth texture is required instead of a depth buffer
  45276. */
  45277. generateDepthTexture?: boolean;
  45278. /**
  45279. * Define the number of desired draw buffers
  45280. */
  45281. textureCount?: number;
  45282. /**
  45283. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45284. */
  45285. doNotChangeAspectRatio?: boolean;
  45286. /**
  45287. * Define the default type of the buffers we are creating
  45288. */
  45289. defaultType?: number;
  45290. }
  45291. /**
  45292. * A multi render target, like a render target provides the ability to render to a texture.
  45293. * Unlike the render target, it can render to several draw buffers in one draw.
  45294. * This is specially interesting in deferred rendering or for any effects requiring more than
  45295. * just one color from a single pass.
  45296. */
  45297. export class MultiRenderTarget extends RenderTargetTexture {
  45298. private _internalTextures;
  45299. private _textures;
  45300. private _multiRenderTargetOptions;
  45301. /**
  45302. * Get if draw buffers are currently supported by the used hardware and browser.
  45303. */
  45304. readonly isSupported: boolean;
  45305. /**
  45306. * Get the list of textures generated by the multi render target.
  45307. */
  45308. readonly textures: Texture[];
  45309. /**
  45310. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45311. */
  45312. readonly depthTexture: Texture;
  45313. /**
  45314. * Set the wrapping mode on U of all the textures we are rendering to.
  45315. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45316. */
  45317. wrapU: number;
  45318. /**
  45319. * Set the wrapping mode on V of all the textures we are rendering to.
  45320. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45321. */
  45322. wrapV: number;
  45323. /**
  45324. * Instantiate a new multi render target texture.
  45325. * A multi render target, like a render target provides the ability to render to a texture.
  45326. * Unlike the render target, it can render to several draw buffers in one draw.
  45327. * This is specially interesting in deferred rendering or for any effects requiring more than
  45328. * just one color from a single pass.
  45329. * @param name Define the name of the texture
  45330. * @param size Define the size of the buffers to render to
  45331. * @param count Define the number of target we are rendering into
  45332. * @param scene Define the scene the texture belongs to
  45333. * @param options Define the options used to create the multi render target
  45334. */
  45335. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45336. /** @hidden */
  45337. _rebuild(): void;
  45338. private _createInternalTextures;
  45339. private _createTextures;
  45340. /**
  45341. * Define the number of samples used if MSAA is enabled.
  45342. */
  45343. samples: number;
  45344. /**
  45345. * Resize all the textures in the multi render target.
  45346. * Be carrefull as it will recreate all the data in the new texture.
  45347. * @param size Define the new size
  45348. */
  45349. resize(size: any): void;
  45350. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45351. /**
  45352. * Dispose the render targets and their associated resources
  45353. */
  45354. dispose(): void;
  45355. /**
  45356. * Release all the underlying texture used as draw buffers.
  45357. */
  45358. releaseInternalTextures(): void;
  45359. }
  45360. }
  45361. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45362. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45363. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45364. import { Nullable } from "babylonjs/types";
  45365. module "babylonjs/Engines/engine" {
  45366. interface Engine {
  45367. /**
  45368. * Unbind a list of render target textures from the webGL context
  45369. * This is used only when drawBuffer extension or webGL2 are active
  45370. * @param textures defines the render target textures to unbind
  45371. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45372. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45373. */
  45374. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45375. /**
  45376. * Create a multi render target texture
  45377. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45378. * @param size defines the size of the texture
  45379. * @param options defines the creation options
  45380. * @returns the cube texture as an InternalTexture
  45381. */
  45382. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45383. /**
  45384. * Update the sample count for a given multiple render target texture
  45385. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45386. * @param textures defines the textures to update
  45387. * @param samples defines the sample count to set
  45388. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45389. */
  45390. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45391. }
  45392. }
  45393. }
  45394. declare module "babylonjs/Engines/Extensions/index" {
  45395. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45396. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45397. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45398. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45399. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45400. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45401. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45402. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45403. }
  45404. declare module "babylonjs/Engines/index" {
  45405. export * from "babylonjs/Engines/constants";
  45406. export * from "babylonjs/Engines/engine";
  45407. export * from "babylonjs/Engines/engineStore";
  45408. export * from "babylonjs/Engines/nullEngine";
  45409. export * from "babylonjs/Engines/Extensions/index";
  45410. export * from "babylonjs/Engines/IPipelineContext";
  45411. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45412. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45413. }
  45414. declare module "babylonjs/Events/clipboardEvents" {
  45415. /**
  45416. * Gather the list of clipboard event types as constants.
  45417. */
  45418. export class ClipboardEventTypes {
  45419. /**
  45420. * The clipboard event is fired when a copy command is active (pressed).
  45421. */
  45422. static readonly COPY: number;
  45423. /**
  45424. * The clipboard event is fired when a cut command is active (pressed).
  45425. */
  45426. static readonly CUT: number;
  45427. /**
  45428. * The clipboard event is fired when a paste command is active (pressed).
  45429. */
  45430. static readonly PASTE: number;
  45431. }
  45432. /**
  45433. * This class is used to store clipboard related info for the onClipboardObservable event.
  45434. */
  45435. export class ClipboardInfo {
  45436. /**
  45437. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45438. */
  45439. type: number;
  45440. /**
  45441. * Defines the related dom event
  45442. */
  45443. event: ClipboardEvent;
  45444. /**
  45445. *Creates an instance of ClipboardInfo.
  45446. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45447. * @param event Defines the related dom event
  45448. */
  45449. constructor(
  45450. /**
  45451. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45452. */
  45453. type: number,
  45454. /**
  45455. * Defines the related dom event
  45456. */
  45457. event: ClipboardEvent);
  45458. /**
  45459. * Get the clipboard event's type from the keycode.
  45460. * @param keyCode Defines the keyCode for the current keyboard event.
  45461. * @return {number}
  45462. */
  45463. static GetTypeFromCharacter(keyCode: number): number;
  45464. }
  45465. }
  45466. declare module "babylonjs/Events/index" {
  45467. export * from "babylonjs/Events/keyboardEvents";
  45468. export * from "babylonjs/Events/pointerEvents";
  45469. export * from "babylonjs/Events/clipboardEvents";
  45470. }
  45471. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45472. import { Scene } from "babylonjs/scene";
  45473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45474. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45475. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45476. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45477. /**
  45478. * Google Daydream controller
  45479. */
  45480. export class DaydreamController extends WebVRController {
  45481. /**
  45482. * Base Url for the controller model.
  45483. */
  45484. static MODEL_BASE_URL: string;
  45485. /**
  45486. * File name for the controller model.
  45487. */
  45488. static MODEL_FILENAME: string;
  45489. /**
  45490. * Gamepad Id prefix used to identify Daydream Controller.
  45491. */
  45492. static readonly GAMEPAD_ID_PREFIX: string;
  45493. /**
  45494. * Creates a new DaydreamController from a gamepad
  45495. * @param vrGamepad the gamepad that the controller should be created from
  45496. */
  45497. constructor(vrGamepad: any);
  45498. /**
  45499. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45500. * @param scene scene in which to add meshes
  45501. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45502. */
  45503. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45504. /**
  45505. * Called once for each button that changed state since the last frame
  45506. * @param buttonIdx Which button index changed
  45507. * @param state New state of the button
  45508. * @param changes Which properties on the state changed since last frame
  45509. */
  45510. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45511. }
  45512. }
  45513. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45514. import { Scene } from "babylonjs/scene";
  45515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45516. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45517. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45518. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45519. /**
  45520. * Gear VR Controller
  45521. */
  45522. export class GearVRController extends WebVRController {
  45523. /**
  45524. * Base Url for the controller model.
  45525. */
  45526. static MODEL_BASE_URL: string;
  45527. /**
  45528. * File name for the controller model.
  45529. */
  45530. static MODEL_FILENAME: string;
  45531. /**
  45532. * Gamepad Id prefix used to identify this controller.
  45533. */
  45534. static readonly GAMEPAD_ID_PREFIX: string;
  45535. private readonly _buttonIndexToObservableNameMap;
  45536. /**
  45537. * Creates a new GearVRController from a gamepad
  45538. * @param vrGamepad the gamepad that the controller should be created from
  45539. */
  45540. constructor(vrGamepad: any);
  45541. /**
  45542. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45543. * @param scene scene in which to add meshes
  45544. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45545. */
  45546. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45547. /**
  45548. * Called once for each button that changed state since the last frame
  45549. * @param buttonIdx Which button index changed
  45550. * @param state New state of the button
  45551. * @param changes Which properties on the state changed since last frame
  45552. */
  45553. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45554. }
  45555. }
  45556. declare module "babylonjs/Gamepads/Controllers/index" {
  45557. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45558. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45559. export * from "babylonjs/Gamepads/Controllers/genericController";
  45560. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45561. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45562. export * from "babylonjs/Gamepads/Controllers/viveController";
  45563. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45564. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45565. }
  45566. declare module "babylonjs/Gamepads/index" {
  45567. export * from "babylonjs/Gamepads/Controllers/index";
  45568. export * from "babylonjs/Gamepads/gamepad";
  45569. export * from "babylonjs/Gamepads/gamepadManager";
  45570. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45571. export * from "babylonjs/Gamepads/xboxGamepad";
  45572. export * from "babylonjs/Gamepads/dualShockGamepad";
  45573. }
  45574. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45575. import { Scene } from "babylonjs/scene";
  45576. import { Vector4 } from "babylonjs/Maths/math.vector";
  45577. import { Color4 } from "babylonjs/Maths/math.color";
  45578. import { Mesh } from "babylonjs/Meshes/mesh";
  45579. import { Nullable } from "babylonjs/types";
  45580. /**
  45581. * Class containing static functions to help procedurally build meshes
  45582. */
  45583. export class PolyhedronBuilder {
  45584. /**
  45585. * Creates a polyhedron mesh
  45586. * * 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
  45587. * * The parameter `size` (positive float, default 1) sets the polygon size
  45588. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45589. * * 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`
  45590. * * 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
  45591. * * 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)`)
  45592. * * 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
  45593. * * 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
  45594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45597. * @param name defines the name of the mesh
  45598. * @param options defines the options used to create the mesh
  45599. * @param scene defines the hosting scene
  45600. * @returns the polyhedron mesh
  45601. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45602. */
  45603. static CreatePolyhedron(name: string, options: {
  45604. type?: number;
  45605. size?: number;
  45606. sizeX?: number;
  45607. sizeY?: number;
  45608. sizeZ?: number;
  45609. custom?: any;
  45610. faceUV?: Vector4[];
  45611. faceColors?: Color4[];
  45612. flat?: boolean;
  45613. updatable?: boolean;
  45614. sideOrientation?: number;
  45615. frontUVs?: Vector4;
  45616. backUVs?: Vector4;
  45617. }, scene?: Nullable<Scene>): Mesh;
  45618. }
  45619. }
  45620. declare module "babylonjs/Gizmos/scaleGizmo" {
  45621. import { Observable } from "babylonjs/Misc/observable";
  45622. import { Nullable } from "babylonjs/types";
  45623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45624. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45625. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45626. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45627. /**
  45628. * Gizmo that enables scaling a mesh along 3 axis
  45629. */
  45630. export class ScaleGizmo extends Gizmo {
  45631. /**
  45632. * Internal gizmo used for interactions on the x axis
  45633. */
  45634. xGizmo: AxisScaleGizmo;
  45635. /**
  45636. * Internal gizmo used for interactions on the y axis
  45637. */
  45638. yGizmo: AxisScaleGizmo;
  45639. /**
  45640. * Internal gizmo used for interactions on the z axis
  45641. */
  45642. zGizmo: AxisScaleGizmo;
  45643. /**
  45644. * Internal gizmo used to scale all axis equally
  45645. */
  45646. uniformScaleGizmo: AxisScaleGizmo;
  45647. private _meshAttached;
  45648. private _updateGizmoRotationToMatchAttachedMesh;
  45649. private _snapDistance;
  45650. private _scaleRatio;
  45651. private _uniformScalingMesh;
  45652. private _octahedron;
  45653. /** Fires an event when any of it's sub gizmos are dragged */
  45654. onDragStartObservable: Observable<unknown>;
  45655. /** Fires an event when any of it's sub gizmos are released from dragging */
  45656. onDragEndObservable: Observable<unknown>;
  45657. attachedMesh: Nullable<AbstractMesh>;
  45658. /**
  45659. * Creates a ScaleGizmo
  45660. * @param gizmoLayer The utility layer the gizmo will be added to
  45661. */
  45662. constructor(gizmoLayer?: UtilityLayerRenderer);
  45663. updateGizmoRotationToMatchAttachedMesh: boolean;
  45664. /**
  45665. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45666. */
  45667. snapDistance: number;
  45668. /**
  45669. * Ratio for the scale of the gizmo (Default: 1)
  45670. */
  45671. scaleRatio: number;
  45672. /**
  45673. * Disposes of the gizmo
  45674. */
  45675. dispose(): void;
  45676. }
  45677. }
  45678. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45679. import { Observable } from "babylonjs/Misc/observable";
  45680. import { Nullable } from "babylonjs/types";
  45681. import { Vector3 } from "babylonjs/Maths/math.vector";
  45682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45683. import { Mesh } from "babylonjs/Meshes/mesh";
  45684. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45685. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45686. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45687. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45688. import { Color3 } from "babylonjs/Maths/math.color";
  45689. /**
  45690. * Single axis scale gizmo
  45691. */
  45692. export class AxisScaleGizmo extends Gizmo {
  45693. /**
  45694. * Drag behavior responsible for the gizmos dragging interactions
  45695. */
  45696. dragBehavior: PointerDragBehavior;
  45697. private _pointerObserver;
  45698. /**
  45699. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45700. */
  45701. snapDistance: number;
  45702. /**
  45703. * Event that fires each time the gizmo snaps to a new location.
  45704. * * snapDistance is the the change in distance
  45705. */
  45706. onSnapObservable: Observable<{
  45707. snapDistance: number;
  45708. }>;
  45709. /**
  45710. * If the scaling operation should be done on all axis (default: false)
  45711. */
  45712. uniformScaling: boolean;
  45713. private _isEnabled;
  45714. private _parent;
  45715. private _arrow;
  45716. private _coloredMaterial;
  45717. private _hoverMaterial;
  45718. /**
  45719. * Creates an AxisScaleGizmo
  45720. * @param gizmoLayer The utility layer the gizmo will be added to
  45721. * @param dragAxis The axis which the gizmo will be able to scale on
  45722. * @param color The color of the gizmo
  45723. */
  45724. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45726. /**
  45727. * If the gizmo is enabled
  45728. */
  45729. isEnabled: boolean;
  45730. /**
  45731. * Disposes of the gizmo
  45732. */
  45733. dispose(): void;
  45734. /**
  45735. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45736. * @param mesh The mesh to replace the default mesh of the gizmo
  45737. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45738. */
  45739. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45740. }
  45741. }
  45742. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45743. import { Observable } from "babylonjs/Misc/observable";
  45744. import { Nullable } from "babylonjs/types";
  45745. import { Vector3 } from "babylonjs/Maths/math.vector";
  45746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45747. import { Mesh } from "babylonjs/Meshes/mesh";
  45748. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45750. import { Color3 } from "babylonjs/Maths/math.color";
  45751. import "babylonjs/Meshes/Builders/boxBuilder";
  45752. /**
  45753. * Bounding box gizmo
  45754. */
  45755. export class BoundingBoxGizmo extends Gizmo {
  45756. private _lineBoundingBox;
  45757. private _rotateSpheresParent;
  45758. private _scaleBoxesParent;
  45759. private _boundingDimensions;
  45760. private _renderObserver;
  45761. private _pointerObserver;
  45762. private _scaleDragSpeed;
  45763. private _tmpQuaternion;
  45764. private _tmpVector;
  45765. private _tmpRotationMatrix;
  45766. /**
  45767. * 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)
  45768. */
  45769. ignoreChildren: boolean;
  45770. /**
  45771. * 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)
  45772. */
  45773. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45774. /**
  45775. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45776. */
  45777. rotationSphereSize: number;
  45778. /**
  45779. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45780. */
  45781. scaleBoxSize: number;
  45782. /**
  45783. * 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)
  45784. */
  45785. fixedDragMeshScreenSize: boolean;
  45786. /**
  45787. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45788. */
  45789. fixedDragMeshScreenSizeDistanceFactor: number;
  45790. /**
  45791. * Fired when a rotation sphere or scale box is dragged
  45792. */
  45793. onDragStartObservable: Observable<{}>;
  45794. /**
  45795. * Fired when a scale box is dragged
  45796. */
  45797. onScaleBoxDragObservable: Observable<{}>;
  45798. /**
  45799. * Fired when a scale box drag is ended
  45800. */
  45801. onScaleBoxDragEndObservable: Observable<{}>;
  45802. /**
  45803. * Fired when a rotation sphere is dragged
  45804. */
  45805. onRotationSphereDragObservable: Observable<{}>;
  45806. /**
  45807. * Fired when a rotation sphere drag is ended
  45808. */
  45809. onRotationSphereDragEndObservable: Observable<{}>;
  45810. /**
  45811. * 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)
  45812. */
  45813. scalePivot: Nullable<Vector3>;
  45814. /**
  45815. * Mesh used as a pivot to rotate the attached mesh
  45816. */
  45817. private _anchorMesh;
  45818. private _existingMeshScale;
  45819. private _dragMesh;
  45820. private pointerDragBehavior;
  45821. private coloredMaterial;
  45822. private hoverColoredMaterial;
  45823. /**
  45824. * Sets the color of the bounding box gizmo
  45825. * @param color the color to set
  45826. */
  45827. setColor(color: Color3): void;
  45828. /**
  45829. * Creates an BoundingBoxGizmo
  45830. * @param gizmoLayer The utility layer the gizmo will be added to
  45831. * @param color The color of the gizmo
  45832. */
  45833. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45834. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45835. private _selectNode;
  45836. /**
  45837. * Updates the bounding box information for the Gizmo
  45838. */
  45839. updateBoundingBox(): void;
  45840. private _updateRotationSpheres;
  45841. private _updateScaleBoxes;
  45842. /**
  45843. * Enables rotation on the specified axis and disables rotation on the others
  45844. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45845. */
  45846. setEnabledRotationAxis(axis: string): void;
  45847. /**
  45848. * Enables/disables scaling
  45849. * @param enable if scaling should be enabled
  45850. */
  45851. setEnabledScaling(enable: boolean): void;
  45852. private _updateDummy;
  45853. /**
  45854. * Enables a pointer drag behavior on the bounding box of the gizmo
  45855. */
  45856. enableDragBehavior(): void;
  45857. /**
  45858. * Disposes of the gizmo
  45859. */
  45860. dispose(): void;
  45861. /**
  45862. * 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)
  45863. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45864. * @returns the bounding box mesh with the passed in mesh as a child
  45865. */
  45866. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45867. /**
  45868. * CustomMeshes are not supported by this gizmo
  45869. * @param mesh The mesh to replace the default mesh of the gizmo
  45870. */
  45871. setCustomMesh(mesh: Mesh): void;
  45872. }
  45873. }
  45874. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45875. import { Observable } from "babylonjs/Misc/observable";
  45876. import { Nullable } from "babylonjs/types";
  45877. import { Vector3 } from "babylonjs/Maths/math.vector";
  45878. import { Color3 } from "babylonjs/Maths/math.color";
  45879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45880. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45881. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45882. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45883. import "babylonjs/Meshes/Builders/linesBuilder";
  45884. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45885. /**
  45886. * Single plane rotation gizmo
  45887. */
  45888. export class PlaneRotationGizmo extends Gizmo {
  45889. /**
  45890. * Drag behavior responsible for the gizmos dragging interactions
  45891. */
  45892. dragBehavior: PointerDragBehavior;
  45893. private _pointerObserver;
  45894. /**
  45895. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45896. */
  45897. snapDistance: number;
  45898. /**
  45899. * Event that fires each time the gizmo snaps to a new location.
  45900. * * snapDistance is the the change in distance
  45901. */
  45902. onSnapObservable: Observable<{
  45903. snapDistance: number;
  45904. }>;
  45905. private _isEnabled;
  45906. private _parent;
  45907. /**
  45908. * Creates a PlaneRotationGizmo
  45909. * @param gizmoLayer The utility layer the gizmo will be added to
  45910. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45911. * @param color The color of the gizmo
  45912. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45913. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45914. */
  45915. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45917. /**
  45918. * If the gizmo is enabled
  45919. */
  45920. isEnabled: boolean;
  45921. /**
  45922. * Disposes of the gizmo
  45923. */
  45924. dispose(): void;
  45925. }
  45926. }
  45927. declare module "babylonjs/Gizmos/rotationGizmo" {
  45928. import { Observable } from "babylonjs/Misc/observable";
  45929. import { Nullable } from "babylonjs/types";
  45930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45931. import { Mesh } from "babylonjs/Meshes/mesh";
  45932. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45933. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45934. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45935. /**
  45936. * Gizmo that enables rotating a mesh along 3 axis
  45937. */
  45938. export class RotationGizmo extends Gizmo {
  45939. /**
  45940. * Internal gizmo used for interactions on the x axis
  45941. */
  45942. xGizmo: PlaneRotationGizmo;
  45943. /**
  45944. * Internal gizmo used for interactions on the y axis
  45945. */
  45946. yGizmo: PlaneRotationGizmo;
  45947. /**
  45948. * Internal gizmo used for interactions on the z axis
  45949. */
  45950. zGizmo: PlaneRotationGizmo;
  45951. /** Fires an event when any of it's sub gizmos are dragged */
  45952. onDragStartObservable: Observable<unknown>;
  45953. /** Fires an event when any of it's sub gizmos are released from dragging */
  45954. onDragEndObservable: Observable<unknown>;
  45955. private _meshAttached;
  45956. attachedMesh: Nullable<AbstractMesh>;
  45957. /**
  45958. * Creates a RotationGizmo
  45959. * @param gizmoLayer The utility layer the gizmo will be added to
  45960. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45961. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45962. */
  45963. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45964. updateGizmoRotationToMatchAttachedMesh: boolean;
  45965. /**
  45966. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45967. */
  45968. snapDistance: number;
  45969. /**
  45970. * Ratio for the scale of the gizmo (Default: 1)
  45971. */
  45972. scaleRatio: number;
  45973. /**
  45974. * Disposes of the gizmo
  45975. */
  45976. dispose(): void;
  45977. /**
  45978. * CustomMeshes are not supported by this gizmo
  45979. * @param mesh The mesh to replace the default mesh of the gizmo
  45980. */
  45981. setCustomMesh(mesh: Mesh): void;
  45982. }
  45983. }
  45984. declare module "babylonjs/Gizmos/gizmoManager" {
  45985. import { Observable } from "babylonjs/Misc/observable";
  45986. import { Nullable } from "babylonjs/types";
  45987. import { Scene, IDisposable } from "babylonjs/scene";
  45988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45989. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45990. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45991. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45992. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45993. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45994. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45995. /**
  45996. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45997. */
  45998. export class GizmoManager implements IDisposable {
  45999. private scene;
  46000. /**
  46001. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46002. */
  46003. gizmos: {
  46004. positionGizmo: Nullable<PositionGizmo>;
  46005. rotationGizmo: Nullable<RotationGizmo>;
  46006. scaleGizmo: Nullable<ScaleGizmo>;
  46007. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46008. };
  46009. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46010. clearGizmoOnEmptyPointerEvent: boolean;
  46011. /** Fires an event when the manager is attached to a mesh */
  46012. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46013. private _gizmosEnabled;
  46014. private _pointerObserver;
  46015. private _attachedMesh;
  46016. private _boundingBoxColor;
  46017. private _defaultUtilityLayer;
  46018. private _defaultKeepDepthUtilityLayer;
  46019. /**
  46020. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46021. */
  46022. boundingBoxDragBehavior: SixDofDragBehavior;
  46023. /**
  46024. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46025. */
  46026. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46027. /**
  46028. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46029. */
  46030. usePointerToAttachGizmos: boolean;
  46031. /**
  46032. * Utility layer that the bounding box gizmo belongs to
  46033. */
  46034. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46035. /**
  46036. * Utility layer that all gizmos besides bounding box belong to
  46037. */
  46038. readonly utilityLayer: UtilityLayerRenderer;
  46039. /**
  46040. * Instatiates a gizmo manager
  46041. * @param scene the scene to overlay the gizmos on top of
  46042. */
  46043. constructor(scene: Scene);
  46044. /**
  46045. * Attaches a set of gizmos to the specified mesh
  46046. * @param mesh The mesh the gizmo's should be attached to
  46047. */
  46048. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46049. /**
  46050. * If the position gizmo is enabled
  46051. */
  46052. positionGizmoEnabled: boolean;
  46053. /**
  46054. * If the rotation gizmo is enabled
  46055. */
  46056. rotationGizmoEnabled: boolean;
  46057. /**
  46058. * If the scale gizmo is enabled
  46059. */
  46060. scaleGizmoEnabled: boolean;
  46061. /**
  46062. * If the boundingBox gizmo is enabled
  46063. */
  46064. boundingBoxGizmoEnabled: boolean;
  46065. /**
  46066. * Disposes of the gizmo manager
  46067. */
  46068. dispose(): void;
  46069. }
  46070. }
  46071. declare module "babylonjs/Lights/directionalLight" {
  46072. import { Camera } from "babylonjs/Cameras/camera";
  46073. import { Scene } from "babylonjs/scene";
  46074. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46076. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46077. import { Effect } from "babylonjs/Materials/effect";
  46078. /**
  46079. * A directional light is defined by a direction (what a surprise!).
  46080. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46081. * 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.
  46082. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46083. */
  46084. export class DirectionalLight extends ShadowLight {
  46085. private _shadowFrustumSize;
  46086. /**
  46087. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46088. */
  46089. /**
  46090. * Specifies a fix frustum size for the shadow generation.
  46091. */
  46092. shadowFrustumSize: number;
  46093. private _shadowOrthoScale;
  46094. /**
  46095. * Gets the shadow projection scale against the optimal computed one.
  46096. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46097. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46098. */
  46099. /**
  46100. * Sets the shadow projection scale against the optimal computed one.
  46101. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46102. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46103. */
  46104. shadowOrthoScale: number;
  46105. /**
  46106. * Automatically compute the projection matrix to best fit (including all the casters)
  46107. * on each frame.
  46108. */
  46109. autoUpdateExtends: boolean;
  46110. private _orthoLeft;
  46111. private _orthoRight;
  46112. private _orthoTop;
  46113. private _orthoBottom;
  46114. /**
  46115. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46116. * The directional light is emitted from everywhere in the given direction.
  46117. * It can cast shadows.
  46118. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46119. * @param name The friendly name of the light
  46120. * @param direction The direction of the light
  46121. * @param scene The scene the light belongs to
  46122. */
  46123. constructor(name: string, direction: Vector3, scene: Scene);
  46124. /**
  46125. * Returns the string "DirectionalLight".
  46126. * @return The class name
  46127. */
  46128. getClassName(): string;
  46129. /**
  46130. * Returns the integer 1.
  46131. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46132. */
  46133. getTypeID(): number;
  46134. /**
  46135. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46136. * Returns the DirectionalLight Shadow projection matrix.
  46137. */
  46138. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46139. /**
  46140. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46141. * Returns the DirectionalLight Shadow projection matrix.
  46142. */
  46143. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46144. /**
  46145. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46146. * Returns the DirectionalLight Shadow projection matrix.
  46147. */
  46148. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46149. protected _buildUniformLayout(): void;
  46150. /**
  46151. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46152. * @param effect The effect to update
  46153. * @param lightIndex The index of the light in the effect to update
  46154. * @returns The directional light
  46155. */
  46156. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46157. /**
  46158. * Gets the minZ used for shadow according to both the scene and the light.
  46159. *
  46160. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46161. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46162. * @param activeCamera The camera we are returning the min for
  46163. * @returns the depth min z
  46164. */
  46165. getDepthMinZ(activeCamera: Camera): number;
  46166. /**
  46167. * Gets the maxZ used for shadow according to both the scene and the light.
  46168. *
  46169. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46170. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46171. * @param activeCamera The camera we are returning the max for
  46172. * @returns the depth max z
  46173. */
  46174. getDepthMaxZ(activeCamera: Camera): number;
  46175. /**
  46176. * Prepares the list of defines specific to the light type.
  46177. * @param defines the list of defines
  46178. * @param lightIndex defines the index of the light for the effect
  46179. */
  46180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46181. }
  46182. }
  46183. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46184. import { Mesh } from "babylonjs/Meshes/mesh";
  46185. /**
  46186. * Class containing static functions to help procedurally build meshes
  46187. */
  46188. export class HemisphereBuilder {
  46189. /**
  46190. * Creates a hemisphere mesh
  46191. * @param name defines the name of the mesh
  46192. * @param options defines the options used to create the mesh
  46193. * @param scene defines the hosting scene
  46194. * @returns the hemisphere mesh
  46195. */
  46196. static CreateHemisphere(name: string, options: {
  46197. segments?: number;
  46198. diameter?: number;
  46199. sideOrientation?: number;
  46200. }, scene: any): Mesh;
  46201. }
  46202. }
  46203. declare module "babylonjs/Lights/spotLight" {
  46204. import { Nullable } from "babylonjs/types";
  46205. import { Scene } from "babylonjs/scene";
  46206. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46208. import { Effect } from "babylonjs/Materials/effect";
  46209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46210. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46211. /**
  46212. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46213. * These values define a cone of light starting from the position, emitting toward the direction.
  46214. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46215. * and the exponent defines the speed of the decay of the light with distance (reach).
  46216. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46217. */
  46218. export class SpotLight extends ShadowLight {
  46219. private _angle;
  46220. private _innerAngle;
  46221. private _cosHalfAngle;
  46222. private _lightAngleScale;
  46223. private _lightAngleOffset;
  46224. /**
  46225. * Gets the cone angle of the spot light in Radians.
  46226. */
  46227. /**
  46228. * Sets the cone angle of the spot light in Radians.
  46229. */
  46230. angle: number;
  46231. /**
  46232. * Only used in gltf falloff mode, this defines the angle where
  46233. * the directional falloff will start before cutting at angle which could be seen
  46234. * as outer angle.
  46235. */
  46236. /**
  46237. * Only used in gltf falloff mode, this defines the angle where
  46238. * the directional falloff will start before cutting at angle which could be seen
  46239. * as outer angle.
  46240. */
  46241. innerAngle: number;
  46242. private _shadowAngleScale;
  46243. /**
  46244. * Allows scaling the angle of the light for shadow generation only.
  46245. */
  46246. /**
  46247. * Allows scaling the angle of the light for shadow generation only.
  46248. */
  46249. shadowAngleScale: number;
  46250. /**
  46251. * The light decay speed with the distance from the emission spot.
  46252. */
  46253. exponent: number;
  46254. private _projectionTextureMatrix;
  46255. /**
  46256. * Allows reading the projecton texture
  46257. */
  46258. readonly projectionTextureMatrix: Matrix;
  46259. protected _projectionTextureLightNear: number;
  46260. /**
  46261. * Gets the near clip of the Spotlight for texture projection.
  46262. */
  46263. /**
  46264. * Sets the near clip of the Spotlight for texture projection.
  46265. */
  46266. projectionTextureLightNear: number;
  46267. protected _projectionTextureLightFar: number;
  46268. /**
  46269. * Gets the far clip of the Spotlight for texture projection.
  46270. */
  46271. /**
  46272. * Sets the far clip of the Spotlight for texture projection.
  46273. */
  46274. projectionTextureLightFar: number;
  46275. protected _projectionTextureUpDirection: Vector3;
  46276. /**
  46277. * Gets the Up vector of the Spotlight for texture projection.
  46278. */
  46279. /**
  46280. * Sets the Up vector of the Spotlight for texture projection.
  46281. */
  46282. projectionTextureUpDirection: Vector3;
  46283. private _projectionTexture;
  46284. /**
  46285. * Gets the projection texture of the light.
  46286. */
  46287. /**
  46288. * Sets the projection texture of the light.
  46289. */
  46290. projectionTexture: Nullable<BaseTexture>;
  46291. private _projectionTextureViewLightDirty;
  46292. private _projectionTextureProjectionLightDirty;
  46293. private _projectionTextureDirty;
  46294. private _projectionTextureViewTargetVector;
  46295. private _projectionTextureViewLightMatrix;
  46296. private _projectionTextureProjectionLightMatrix;
  46297. private _projectionTextureScalingMatrix;
  46298. /**
  46299. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46300. * It can cast shadows.
  46301. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46302. * @param name The light friendly name
  46303. * @param position The position of the spot light in the scene
  46304. * @param direction The direction of the light in the scene
  46305. * @param angle The cone angle of the light in Radians
  46306. * @param exponent The light decay speed with the distance from the emission spot
  46307. * @param scene The scene the lights belongs to
  46308. */
  46309. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46310. /**
  46311. * Returns the string "SpotLight".
  46312. * @returns the class name
  46313. */
  46314. getClassName(): string;
  46315. /**
  46316. * Returns the integer 2.
  46317. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46318. */
  46319. getTypeID(): number;
  46320. /**
  46321. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46322. */
  46323. protected _setDirection(value: Vector3): void;
  46324. /**
  46325. * Overrides the position setter to recompute the projection texture view light Matrix.
  46326. */
  46327. protected _setPosition(value: Vector3): void;
  46328. /**
  46329. * 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.
  46330. * Returns the SpotLight.
  46331. */
  46332. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46333. protected _computeProjectionTextureViewLightMatrix(): void;
  46334. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46335. /**
  46336. * Main function for light texture projection matrix computing.
  46337. */
  46338. protected _computeProjectionTextureMatrix(): void;
  46339. protected _buildUniformLayout(): void;
  46340. private _computeAngleValues;
  46341. /**
  46342. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46343. * @param effect The effect to update
  46344. * @param lightIndex The index of the light in the effect to update
  46345. * @returns The spot light
  46346. */
  46347. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46348. /**
  46349. * Disposes the light and the associated resources.
  46350. */
  46351. dispose(): void;
  46352. /**
  46353. * Prepares the list of defines specific to the light type.
  46354. * @param defines the list of defines
  46355. * @param lightIndex defines the index of the light for the effect
  46356. */
  46357. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46358. }
  46359. }
  46360. declare module "babylonjs/Gizmos/lightGizmo" {
  46361. import { Nullable } from "babylonjs/types";
  46362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46364. import { Light } from "babylonjs/Lights/light";
  46365. /**
  46366. * Gizmo that enables viewing a light
  46367. */
  46368. export class LightGizmo extends Gizmo {
  46369. private _lightMesh;
  46370. private _material;
  46371. private cachedPosition;
  46372. private cachedForward;
  46373. /**
  46374. * Creates a LightGizmo
  46375. * @param gizmoLayer The utility layer the gizmo will be added to
  46376. */
  46377. constructor(gizmoLayer?: UtilityLayerRenderer);
  46378. private _light;
  46379. /**
  46380. * The light that the gizmo is attached to
  46381. */
  46382. light: Nullable<Light>;
  46383. /**
  46384. * @hidden
  46385. * Updates the gizmo to match the attached mesh's position/rotation
  46386. */
  46387. protected _update(): void;
  46388. private static _Scale;
  46389. /**
  46390. * Creates the lines for a light mesh
  46391. */
  46392. private static _createLightLines;
  46393. /**
  46394. * Disposes of the light gizmo
  46395. */
  46396. dispose(): void;
  46397. private static _CreateHemisphericLightMesh;
  46398. private static _CreatePointLightMesh;
  46399. private static _CreateSpotLightMesh;
  46400. private static _CreateDirectionalLightMesh;
  46401. }
  46402. }
  46403. declare module "babylonjs/Gizmos/index" {
  46404. export * from "babylonjs/Gizmos/axisDragGizmo";
  46405. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46406. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46407. export * from "babylonjs/Gizmos/gizmo";
  46408. export * from "babylonjs/Gizmos/gizmoManager";
  46409. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46410. export * from "babylonjs/Gizmos/positionGizmo";
  46411. export * from "babylonjs/Gizmos/rotationGizmo";
  46412. export * from "babylonjs/Gizmos/scaleGizmo";
  46413. export * from "babylonjs/Gizmos/lightGizmo";
  46414. export * from "babylonjs/Gizmos/planeDragGizmo";
  46415. }
  46416. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46417. /** @hidden */
  46418. export var backgroundFragmentDeclaration: {
  46419. name: string;
  46420. shader: string;
  46421. };
  46422. }
  46423. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46424. /** @hidden */
  46425. export var backgroundUboDeclaration: {
  46426. name: string;
  46427. shader: string;
  46428. };
  46429. }
  46430. declare module "babylonjs/Shaders/background.fragment" {
  46431. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46432. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46433. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46434. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46435. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46436. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46437. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46438. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46439. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46440. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46441. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46442. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46443. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46444. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46445. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46446. /** @hidden */
  46447. export var backgroundPixelShader: {
  46448. name: string;
  46449. shader: string;
  46450. };
  46451. }
  46452. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46453. /** @hidden */
  46454. export var backgroundVertexDeclaration: {
  46455. name: string;
  46456. shader: string;
  46457. };
  46458. }
  46459. declare module "babylonjs/Shaders/background.vertex" {
  46460. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46461. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46463. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46465. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46466. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46467. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46468. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46469. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46470. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46471. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46472. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46473. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46474. /** @hidden */
  46475. export var backgroundVertexShader: {
  46476. name: string;
  46477. shader: string;
  46478. };
  46479. }
  46480. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46481. import { Nullable, int, float } from "babylonjs/types";
  46482. import { Scene } from "babylonjs/scene";
  46483. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46486. import { Mesh } from "babylonjs/Meshes/mesh";
  46487. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46488. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46489. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46491. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46492. import { Color3 } from "babylonjs/Maths/math.color";
  46493. import "babylonjs/Shaders/background.fragment";
  46494. import "babylonjs/Shaders/background.vertex";
  46495. /**
  46496. * Background material used to create an efficient environement around your scene.
  46497. */
  46498. export class BackgroundMaterial extends PushMaterial {
  46499. /**
  46500. * Standard reflectance value at parallel view angle.
  46501. */
  46502. static StandardReflectance0: number;
  46503. /**
  46504. * Standard reflectance value at grazing angle.
  46505. */
  46506. static StandardReflectance90: number;
  46507. protected _primaryColor: Color3;
  46508. /**
  46509. * Key light Color (multiply against the environement texture)
  46510. */
  46511. primaryColor: Color3;
  46512. protected __perceptualColor: Nullable<Color3>;
  46513. /**
  46514. * Experimental Internal Use Only.
  46515. *
  46516. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46517. * This acts as a helper to set the primary color to a more "human friendly" value.
  46518. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46519. * output color as close as possible from the chosen value.
  46520. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46521. * part of lighting setup.)
  46522. */
  46523. _perceptualColor: Nullable<Color3>;
  46524. protected _primaryColorShadowLevel: float;
  46525. /**
  46526. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46527. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46528. */
  46529. primaryColorShadowLevel: float;
  46530. protected _primaryColorHighlightLevel: float;
  46531. /**
  46532. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46533. * The primary color is used at the level chosen to define what the white area would look.
  46534. */
  46535. primaryColorHighlightLevel: float;
  46536. protected _reflectionTexture: Nullable<BaseTexture>;
  46537. /**
  46538. * Reflection Texture used in the material.
  46539. * Should be author in a specific way for the best result (refer to the documentation).
  46540. */
  46541. reflectionTexture: Nullable<BaseTexture>;
  46542. protected _reflectionBlur: float;
  46543. /**
  46544. * Reflection Texture level of blur.
  46545. *
  46546. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46547. * texture twice.
  46548. */
  46549. reflectionBlur: float;
  46550. protected _diffuseTexture: Nullable<BaseTexture>;
  46551. /**
  46552. * Diffuse Texture used in the material.
  46553. * Should be author in a specific way for the best result (refer to the documentation).
  46554. */
  46555. diffuseTexture: Nullable<BaseTexture>;
  46556. protected _shadowLights: Nullable<IShadowLight[]>;
  46557. /**
  46558. * Specify the list of lights casting shadow on the material.
  46559. * All scene shadow lights will be included if null.
  46560. */
  46561. shadowLights: Nullable<IShadowLight[]>;
  46562. protected _shadowLevel: float;
  46563. /**
  46564. * Helps adjusting the shadow to a softer level if required.
  46565. * 0 means black shadows and 1 means no shadows.
  46566. */
  46567. shadowLevel: float;
  46568. protected _sceneCenter: Vector3;
  46569. /**
  46570. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46571. * It is usually zero but might be interesting to modify according to your setup.
  46572. */
  46573. sceneCenter: Vector3;
  46574. protected _opacityFresnel: boolean;
  46575. /**
  46576. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46577. * This helps ensuring a nice transition when the camera goes under the ground.
  46578. */
  46579. opacityFresnel: boolean;
  46580. protected _reflectionFresnel: boolean;
  46581. /**
  46582. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46583. * This helps adding a mirror texture on the ground.
  46584. */
  46585. reflectionFresnel: boolean;
  46586. protected _reflectionFalloffDistance: number;
  46587. /**
  46588. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46589. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46590. */
  46591. reflectionFalloffDistance: number;
  46592. protected _reflectionAmount: number;
  46593. /**
  46594. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46595. */
  46596. reflectionAmount: number;
  46597. protected _reflectionReflectance0: number;
  46598. /**
  46599. * This specifies the weight of the reflection at grazing angle.
  46600. */
  46601. reflectionReflectance0: number;
  46602. protected _reflectionReflectance90: number;
  46603. /**
  46604. * This specifies the weight of the reflection at a perpendicular point of view.
  46605. */
  46606. reflectionReflectance90: number;
  46607. /**
  46608. * Sets the reflection reflectance fresnel values according to the default standard
  46609. * empirically know to work well :-)
  46610. */
  46611. reflectionStandardFresnelWeight: number;
  46612. protected _useRGBColor: boolean;
  46613. /**
  46614. * Helps to directly use the maps channels instead of their level.
  46615. */
  46616. useRGBColor: boolean;
  46617. protected _enableNoise: boolean;
  46618. /**
  46619. * This helps reducing the banding effect that could occur on the background.
  46620. */
  46621. enableNoise: boolean;
  46622. /**
  46623. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46624. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46625. * Recommended to be keep at 1.0 except for special cases.
  46626. */
  46627. fovMultiplier: number;
  46628. private _fovMultiplier;
  46629. /**
  46630. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46631. */
  46632. useEquirectangularFOV: boolean;
  46633. private _maxSimultaneousLights;
  46634. /**
  46635. * Number of Simultaneous lights allowed on the material.
  46636. */
  46637. maxSimultaneousLights: int;
  46638. /**
  46639. * Default configuration related to image processing available in the Background Material.
  46640. */
  46641. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46642. /**
  46643. * Keep track of the image processing observer to allow dispose and replace.
  46644. */
  46645. private _imageProcessingObserver;
  46646. /**
  46647. * Attaches a new image processing configuration to the PBR Material.
  46648. * @param configuration (if null the scene configuration will be use)
  46649. */
  46650. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46651. /**
  46652. * Gets the image processing configuration used either in this material.
  46653. */
  46654. /**
  46655. * Sets the Default image processing configuration used either in the this material.
  46656. *
  46657. * If sets to null, the scene one is in use.
  46658. */
  46659. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46660. /**
  46661. * Gets wether the color curves effect is enabled.
  46662. */
  46663. /**
  46664. * Sets wether the color curves effect is enabled.
  46665. */
  46666. cameraColorCurvesEnabled: boolean;
  46667. /**
  46668. * Gets wether the color grading effect is enabled.
  46669. */
  46670. /**
  46671. * Gets wether the color grading effect is enabled.
  46672. */
  46673. cameraColorGradingEnabled: boolean;
  46674. /**
  46675. * Gets wether tonemapping is enabled or not.
  46676. */
  46677. /**
  46678. * Sets wether tonemapping is enabled or not
  46679. */
  46680. cameraToneMappingEnabled: boolean;
  46681. /**
  46682. * The camera exposure used on this material.
  46683. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46684. * This corresponds to a photographic exposure.
  46685. */
  46686. /**
  46687. * The camera exposure used on this material.
  46688. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46689. * This corresponds to a photographic exposure.
  46690. */
  46691. cameraExposure: float;
  46692. /**
  46693. * Gets The camera contrast used on this material.
  46694. */
  46695. /**
  46696. * Sets The camera contrast used on this material.
  46697. */
  46698. cameraContrast: float;
  46699. /**
  46700. * Gets the Color Grading 2D Lookup Texture.
  46701. */
  46702. /**
  46703. * Sets the Color Grading 2D Lookup Texture.
  46704. */
  46705. cameraColorGradingTexture: Nullable<BaseTexture>;
  46706. /**
  46707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46709. * 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;
  46710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46711. */
  46712. /**
  46713. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46714. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46715. * 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;
  46716. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46717. */
  46718. cameraColorCurves: Nullable<ColorCurves>;
  46719. /**
  46720. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46721. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46722. */
  46723. switchToBGR: boolean;
  46724. private _renderTargets;
  46725. private _reflectionControls;
  46726. private _white;
  46727. private _primaryShadowColor;
  46728. private _primaryHighlightColor;
  46729. /**
  46730. * Instantiates a Background Material in the given scene
  46731. * @param name The friendly name of the material
  46732. * @param scene The scene to add the material to
  46733. */
  46734. constructor(name: string, scene: Scene);
  46735. /**
  46736. * Gets a boolean indicating that current material needs to register RTT
  46737. */
  46738. readonly hasRenderTargetTextures: boolean;
  46739. /**
  46740. * The entire material has been created in order to prevent overdraw.
  46741. * @returns false
  46742. */
  46743. needAlphaTesting(): boolean;
  46744. /**
  46745. * The entire material has been created in order to prevent overdraw.
  46746. * @returns true if blending is enable
  46747. */
  46748. needAlphaBlending(): boolean;
  46749. /**
  46750. * Checks wether the material is ready to be rendered for a given mesh.
  46751. * @param mesh The mesh to render
  46752. * @param subMesh The submesh to check against
  46753. * @param useInstances Specify wether or not the material is used with instances
  46754. * @returns true if all the dependencies are ready (Textures, Effects...)
  46755. */
  46756. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46757. /**
  46758. * Compute the primary color according to the chosen perceptual color.
  46759. */
  46760. private _computePrimaryColorFromPerceptualColor;
  46761. /**
  46762. * Compute the highlights and shadow colors according to their chosen levels.
  46763. */
  46764. private _computePrimaryColors;
  46765. /**
  46766. * Build the uniform buffer used in the material.
  46767. */
  46768. buildUniformLayout(): void;
  46769. /**
  46770. * Unbind the material.
  46771. */
  46772. unbind(): void;
  46773. /**
  46774. * Bind only the world matrix to the material.
  46775. * @param world The world matrix to bind.
  46776. */
  46777. bindOnlyWorldMatrix(world: Matrix): void;
  46778. /**
  46779. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46780. * @param world The world matrix to bind.
  46781. * @param subMesh The submesh to bind for.
  46782. */
  46783. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46784. /**
  46785. * Dispose the material.
  46786. * @param forceDisposeEffect Force disposal of the associated effect.
  46787. * @param forceDisposeTextures Force disposal of the associated textures.
  46788. */
  46789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46790. /**
  46791. * Clones the material.
  46792. * @param name The cloned name.
  46793. * @returns The cloned material.
  46794. */
  46795. clone(name: string): BackgroundMaterial;
  46796. /**
  46797. * Serializes the current material to its JSON representation.
  46798. * @returns The JSON representation.
  46799. */
  46800. serialize(): any;
  46801. /**
  46802. * Gets the class name of the material
  46803. * @returns "BackgroundMaterial"
  46804. */
  46805. getClassName(): string;
  46806. /**
  46807. * Parse a JSON input to create back a background material.
  46808. * @param source The JSON data to parse
  46809. * @param scene The scene to create the parsed material in
  46810. * @param rootUrl The root url of the assets the material depends upon
  46811. * @returns the instantiated BackgroundMaterial.
  46812. */
  46813. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46814. }
  46815. }
  46816. declare module "babylonjs/Helpers/environmentHelper" {
  46817. import { Observable } from "babylonjs/Misc/observable";
  46818. import { Nullable } from "babylonjs/types";
  46819. import { Scene } from "babylonjs/scene";
  46820. import { Vector3 } from "babylonjs/Maths/math.vector";
  46821. import { Color3 } from "babylonjs/Maths/math.color";
  46822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46823. import { Mesh } from "babylonjs/Meshes/mesh";
  46824. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46825. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46826. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46827. import "babylonjs/Meshes/Builders/planeBuilder";
  46828. import "babylonjs/Meshes/Builders/boxBuilder";
  46829. /**
  46830. * Represents the different options available during the creation of
  46831. * a Environment helper.
  46832. *
  46833. * This can control the default ground, skybox and image processing setup of your scene.
  46834. */
  46835. export interface IEnvironmentHelperOptions {
  46836. /**
  46837. * Specifies wether or not to create a ground.
  46838. * True by default.
  46839. */
  46840. createGround: boolean;
  46841. /**
  46842. * Specifies the ground size.
  46843. * 15 by default.
  46844. */
  46845. groundSize: number;
  46846. /**
  46847. * The texture used on the ground for the main color.
  46848. * Comes from the BabylonJS CDN by default.
  46849. *
  46850. * Remarks: Can be either a texture or a url.
  46851. */
  46852. groundTexture: string | BaseTexture;
  46853. /**
  46854. * The color mixed in the ground texture by default.
  46855. * BabylonJS clearColor by default.
  46856. */
  46857. groundColor: Color3;
  46858. /**
  46859. * Specifies the ground opacity.
  46860. * 1 by default.
  46861. */
  46862. groundOpacity: number;
  46863. /**
  46864. * Enables the ground to receive shadows.
  46865. * True by default.
  46866. */
  46867. enableGroundShadow: boolean;
  46868. /**
  46869. * Helps preventing the shadow to be fully black on the ground.
  46870. * 0.5 by default.
  46871. */
  46872. groundShadowLevel: number;
  46873. /**
  46874. * Creates a mirror texture attach to the ground.
  46875. * false by default.
  46876. */
  46877. enableGroundMirror: boolean;
  46878. /**
  46879. * Specifies the ground mirror size ratio.
  46880. * 0.3 by default as the default kernel is 64.
  46881. */
  46882. groundMirrorSizeRatio: number;
  46883. /**
  46884. * Specifies the ground mirror blur kernel size.
  46885. * 64 by default.
  46886. */
  46887. groundMirrorBlurKernel: number;
  46888. /**
  46889. * Specifies the ground mirror visibility amount.
  46890. * 1 by default
  46891. */
  46892. groundMirrorAmount: number;
  46893. /**
  46894. * Specifies the ground mirror reflectance weight.
  46895. * This uses the standard weight of the background material to setup the fresnel effect
  46896. * of the mirror.
  46897. * 1 by default.
  46898. */
  46899. groundMirrorFresnelWeight: number;
  46900. /**
  46901. * Specifies the ground mirror Falloff distance.
  46902. * This can helps reducing the size of the reflection.
  46903. * 0 by Default.
  46904. */
  46905. groundMirrorFallOffDistance: number;
  46906. /**
  46907. * Specifies the ground mirror texture type.
  46908. * Unsigned Int by Default.
  46909. */
  46910. groundMirrorTextureType: number;
  46911. /**
  46912. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46913. * the shown objects.
  46914. */
  46915. groundYBias: number;
  46916. /**
  46917. * Specifies wether or not to create a skybox.
  46918. * True by default.
  46919. */
  46920. createSkybox: boolean;
  46921. /**
  46922. * Specifies the skybox size.
  46923. * 20 by default.
  46924. */
  46925. skyboxSize: number;
  46926. /**
  46927. * The texture used on the skybox for the main color.
  46928. * Comes from the BabylonJS CDN by default.
  46929. *
  46930. * Remarks: Can be either a texture or a url.
  46931. */
  46932. skyboxTexture: string | BaseTexture;
  46933. /**
  46934. * The color mixed in the skybox texture by default.
  46935. * BabylonJS clearColor by default.
  46936. */
  46937. skyboxColor: Color3;
  46938. /**
  46939. * The background rotation around the Y axis of the scene.
  46940. * This helps aligning the key lights of your scene with the background.
  46941. * 0 by default.
  46942. */
  46943. backgroundYRotation: number;
  46944. /**
  46945. * Compute automatically the size of the elements to best fit with the scene.
  46946. */
  46947. sizeAuto: boolean;
  46948. /**
  46949. * Default position of the rootMesh if autoSize is not true.
  46950. */
  46951. rootPosition: Vector3;
  46952. /**
  46953. * Sets up the image processing in the scene.
  46954. * true by default.
  46955. */
  46956. setupImageProcessing: boolean;
  46957. /**
  46958. * The texture used as your environment texture in the scene.
  46959. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46960. *
  46961. * Remarks: Can be either a texture or a url.
  46962. */
  46963. environmentTexture: string | BaseTexture;
  46964. /**
  46965. * The value of the exposure to apply to the scene.
  46966. * 0.6 by default if setupImageProcessing is true.
  46967. */
  46968. cameraExposure: number;
  46969. /**
  46970. * The value of the contrast to apply to the scene.
  46971. * 1.6 by default if setupImageProcessing is true.
  46972. */
  46973. cameraContrast: number;
  46974. /**
  46975. * Specifies wether or not tonemapping should be enabled in the scene.
  46976. * true by default if setupImageProcessing is true.
  46977. */
  46978. toneMappingEnabled: boolean;
  46979. }
  46980. /**
  46981. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46982. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46983. * It also helps with the default setup of your imageProcessing configuration.
  46984. */
  46985. export class EnvironmentHelper {
  46986. /**
  46987. * Default ground texture URL.
  46988. */
  46989. private static _groundTextureCDNUrl;
  46990. /**
  46991. * Default skybox texture URL.
  46992. */
  46993. private static _skyboxTextureCDNUrl;
  46994. /**
  46995. * Default environment texture URL.
  46996. */
  46997. private static _environmentTextureCDNUrl;
  46998. /**
  46999. * Creates the default options for the helper.
  47000. */
  47001. private static _getDefaultOptions;
  47002. private _rootMesh;
  47003. /**
  47004. * Gets the root mesh created by the helper.
  47005. */
  47006. readonly rootMesh: Mesh;
  47007. private _skybox;
  47008. /**
  47009. * Gets the skybox created by the helper.
  47010. */
  47011. readonly skybox: Nullable<Mesh>;
  47012. private _skyboxTexture;
  47013. /**
  47014. * Gets the skybox texture created by the helper.
  47015. */
  47016. readonly skyboxTexture: Nullable<BaseTexture>;
  47017. private _skyboxMaterial;
  47018. /**
  47019. * Gets the skybox material created by the helper.
  47020. */
  47021. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47022. private _ground;
  47023. /**
  47024. * Gets the ground mesh created by the helper.
  47025. */
  47026. readonly ground: Nullable<Mesh>;
  47027. private _groundTexture;
  47028. /**
  47029. * Gets the ground texture created by the helper.
  47030. */
  47031. readonly groundTexture: Nullable<BaseTexture>;
  47032. private _groundMirror;
  47033. /**
  47034. * Gets the ground mirror created by the helper.
  47035. */
  47036. readonly groundMirror: Nullable<MirrorTexture>;
  47037. /**
  47038. * Gets the ground mirror render list to helps pushing the meshes
  47039. * you wish in the ground reflection.
  47040. */
  47041. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47042. private _groundMaterial;
  47043. /**
  47044. * Gets the ground material created by the helper.
  47045. */
  47046. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47047. /**
  47048. * Stores the creation options.
  47049. */
  47050. private readonly _scene;
  47051. private _options;
  47052. /**
  47053. * This observable will be notified with any error during the creation of the environment,
  47054. * mainly texture creation errors.
  47055. */
  47056. onErrorObservable: Observable<{
  47057. message?: string;
  47058. exception?: any;
  47059. }>;
  47060. /**
  47061. * constructor
  47062. * @param options Defines the options we want to customize the helper
  47063. * @param scene The scene to add the material to
  47064. */
  47065. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47066. /**
  47067. * Updates the background according to the new options
  47068. * @param options
  47069. */
  47070. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47071. /**
  47072. * Sets the primary color of all the available elements.
  47073. * @param color the main color to affect to the ground and the background
  47074. */
  47075. setMainColor(color: Color3): void;
  47076. /**
  47077. * Setup the image processing according to the specified options.
  47078. */
  47079. private _setupImageProcessing;
  47080. /**
  47081. * Setup the environment texture according to the specified options.
  47082. */
  47083. private _setupEnvironmentTexture;
  47084. /**
  47085. * Setup the background according to the specified options.
  47086. */
  47087. private _setupBackground;
  47088. /**
  47089. * Get the scene sizes according to the setup.
  47090. */
  47091. private _getSceneSize;
  47092. /**
  47093. * Setup the ground according to the specified options.
  47094. */
  47095. private _setupGround;
  47096. /**
  47097. * Setup the ground material according to the specified options.
  47098. */
  47099. private _setupGroundMaterial;
  47100. /**
  47101. * Setup the ground diffuse texture according to the specified options.
  47102. */
  47103. private _setupGroundDiffuseTexture;
  47104. /**
  47105. * Setup the ground mirror texture according to the specified options.
  47106. */
  47107. private _setupGroundMirrorTexture;
  47108. /**
  47109. * Setup the ground to receive the mirror texture.
  47110. */
  47111. private _setupMirrorInGroundMaterial;
  47112. /**
  47113. * Setup the skybox according to the specified options.
  47114. */
  47115. private _setupSkybox;
  47116. /**
  47117. * Setup the skybox material according to the specified options.
  47118. */
  47119. private _setupSkyboxMaterial;
  47120. /**
  47121. * Setup the skybox reflection texture according to the specified options.
  47122. */
  47123. private _setupSkyboxReflectionTexture;
  47124. private _errorHandler;
  47125. /**
  47126. * Dispose all the elements created by the Helper.
  47127. */
  47128. dispose(): void;
  47129. }
  47130. }
  47131. declare module "babylonjs/Helpers/photoDome" {
  47132. import { Observable } from "babylonjs/Misc/observable";
  47133. import { Nullable } from "babylonjs/types";
  47134. import { Scene } from "babylonjs/scene";
  47135. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47136. import { Mesh } from "babylonjs/Meshes/mesh";
  47137. import { Texture } from "babylonjs/Materials/Textures/texture";
  47138. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47139. import "babylonjs/Meshes/Builders/sphereBuilder";
  47140. /**
  47141. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47142. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47143. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47144. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47145. */
  47146. export class PhotoDome extends TransformNode {
  47147. /**
  47148. * Define the image as a Monoscopic panoramic 360 image.
  47149. */
  47150. static readonly MODE_MONOSCOPIC: number;
  47151. /**
  47152. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47153. */
  47154. static readonly MODE_TOPBOTTOM: number;
  47155. /**
  47156. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47157. */
  47158. static readonly MODE_SIDEBYSIDE: number;
  47159. private _useDirectMapping;
  47160. /**
  47161. * The texture being displayed on the sphere
  47162. */
  47163. protected _photoTexture: Texture;
  47164. /**
  47165. * Gets or sets the texture being displayed on the sphere
  47166. */
  47167. photoTexture: Texture;
  47168. /**
  47169. * Observable raised when an error occured while loading the 360 image
  47170. */
  47171. onLoadErrorObservable: Observable<string>;
  47172. /**
  47173. * The skybox material
  47174. */
  47175. protected _material: BackgroundMaterial;
  47176. /**
  47177. * The surface used for the skybox
  47178. */
  47179. protected _mesh: Mesh;
  47180. /**
  47181. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47182. * Also see the options.resolution property.
  47183. */
  47184. fovMultiplier: number;
  47185. private _imageMode;
  47186. /**
  47187. * Gets or set the current video mode for the video. It can be:
  47188. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47189. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47190. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47191. */
  47192. imageMode: number;
  47193. /**
  47194. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47195. * @param name Element's name, child elements will append suffixes for their own names.
  47196. * @param urlsOfPhoto defines the url of the photo to display
  47197. * @param options defines an object containing optional or exposed sub element properties
  47198. * @param onError defines a callback called when an error occured while loading the texture
  47199. */
  47200. constructor(name: string, urlOfPhoto: string, options: {
  47201. resolution?: number;
  47202. size?: number;
  47203. useDirectMapping?: boolean;
  47204. faceForward?: boolean;
  47205. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47206. private _onBeforeCameraRenderObserver;
  47207. private _changeImageMode;
  47208. /**
  47209. * Releases resources associated with this node.
  47210. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47211. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47212. */
  47213. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47214. }
  47215. }
  47216. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47218. /** @hidden */
  47219. export var rgbdDecodePixelShader: {
  47220. name: string;
  47221. shader: string;
  47222. };
  47223. }
  47224. declare module "babylonjs/Misc/brdfTextureTools" {
  47225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47226. import { Scene } from "babylonjs/scene";
  47227. import "babylonjs/Shaders/rgbdDecode.fragment";
  47228. /**
  47229. * Class used to host texture specific utilities
  47230. */
  47231. export class BRDFTextureTools {
  47232. /**
  47233. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  47234. * @param texture the texture to expand.
  47235. */
  47236. private static _ExpandDefaultBRDFTexture;
  47237. /**
  47238. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47239. * @param scene defines the hosting scene
  47240. * @returns the environment BRDF texture
  47241. */
  47242. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47243. private static _environmentBRDFBase64Texture;
  47244. }
  47245. }
  47246. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47247. import { Nullable } from "babylonjs/types";
  47248. import { Color3 } from "babylonjs/Maths/math.color";
  47249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47250. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47251. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47252. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47253. import { Engine } from "babylonjs/Engines/engine";
  47254. import { Scene } from "babylonjs/scene";
  47255. /**
  47256. * @hidden
  47257. */
  47258. export interface IMaterialClearCoatDefines {
  47259. CLEARCOAT: boolean;
  47260. CLEARCOAT_DEFAULTIOR: boolean;
  47261. CLEARCOAT_TEXTURE: boolean;
  47262. CLEARCOAT_TEXTUREDIRECTUV: number;
  47263. CLEARCOAT_BUMP: boolean;
  47264. CLEARCOAT_BUMPDIRECTUV: number;
  47265. CLEARCOAT_TINT: boolean;
  47266. CLEARCOAT_TINT_TEXTURE: boolean;
  47267. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47268. /** @hidden */
  47269. _areTexturesDirty: boolean;
  47270. }
  47271. /**
  47272. * Define the code related to the clear coat parameters of the pbr material.
  47273. */
  47274. export class PBRClearCoatConfiguration {
  47275. /**
  47276. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47277. * The default fits with a polyurethane material.
  47278. */
  47279. private static readonly _DefaultIndexOfRefraction;
  47280. private _isEnabled;
  47281. /**
  47282. * Defines if the clear coat is enabled in the material.
  47283. */
  47284. isEnabled: boolean;
  47285. /**
  47286. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47287. */
  47288. intensity: number;
  47289. /**
  47290. * Defines the clear coat layer roughness.
  47291. */
  47292. roughness: number;
  47293. private _indexOfRefraction;
  47294. /**
  47295. * Defines the index of refraction of the clear coat.
  47296. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47297. * The default fits with a polyurethane material.
  47298. * Changing the default value is more performance intensive.
  47299. */
  47300. indexOfRefraction: number;
  47301. private _texture;
  47302. /**
  47303. * Stores the clear coat values in a texture.
  47304. */
  47305. texture: Nullable<BaseTexture>;
  47306. private _bumpTexture;
  47307. /**
  47308. * Define the clear coat specific bump texture.
  47309. */
  47310. bumpTexture: Nullable<BaseTexture>;
  47311. private _isTintEnabled;
  47312. /**
  47313. * Defines if the clear coat tint is enabled in the material.
  47314. */
  47315. isTintEnabled: boolean;
  47316. /**
  47317. * Defines the clear coat tint of the material.
  47318. * This is only use if tint is enabled
  47319. */
  47320. tintColor: Color3;
  47321. /**
  47322. * Defines the distance at which the tint color should be found in the
  47323. * clear coat media.
  47324. * This is only use if tint is enabled
  47325. */
  47326. tintColorAtDistance: number;
  47327. /**
  47328. * Defines the clear coat layer thickness.
  47329. * This is only use if tint is enabled
  47330. */
  47331. tintThickness: number;
  47332. private _tintTexture;
  47333. /**
  47334. * Stores the clear tint values in a texture.
  47335. * rgb is tint
  47336. * a is a thickness factor
  47337. */
  47338. tintTexture: Nullable<BaseTexture>;
  47339. /** @hidden */
  47340. private _internalMarkAllSubMeshesAsTexturesDirty;
  47341. /** @hidden */
  47342. _markAllSubMeshesAsTexturesDirty(): void;
  47343. /**
  47344. * Instantiate a new istance of clear coat configuration.
  47345. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47346. */
  47347. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47348. /**
  47349. * Gets wehter the submesh is ready to be used or not.
  47350. * @param defines the list of "defines" to update.
  47351. * @param scene defines the scene the material belongs to.
  47352. * @param engine defines the engine the material belongs to.
  47353. * @param disableBumpMap defines wether the material disables bump or not.
  47354. * @returns - boolean indicating that the submesh is ready or not.
  47355. */
  47356. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47357. /**
  47358. * Checks to see if a texture is used in the material.
  47359. * @param defines the list of "defines" to update.
  47360. * @param scene defines the scene to the material belongs to.
  47361. */
  47362. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47363. /**
  47364. * Binds the material data.
  47365. * @param uniformBuffer defines the Uniform buffer to fill in.
  47366. * @param scene defines the scene the material belongs to.
  47367. * @param engine defines the engine the material belongs to.
  47368. * @param disableBumpMap defines wether the material disables bump or not.
  47369. * @param isFrozen defines wether the material is frozen or not.
  47370. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47371. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47372. */
  47373. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47374. /**
  47375. * Checks to see if a texture is used in the material.
  47376. * @param texture - Base texture to use.
  47377. * @returns - Boolean specifying if a texture is used in the material.
  47378. */
  47379. hasTexture(texture: BaseTexture): boolean;
  47380. /**
  47381. * Returns an array of the actively used textures.
  47382. * @param activeTextures Array of BaseTextures
  47383. */
  47384. getActiveTextures(activeTextures: BaseTexture[]): void;
  47385. /**
  47386. * Returns the animatable textures.
  47387. * @param animatables Array of animatable textures.
  47388. */
  47389. getAnimatables(animatables: IAnimatable[]): void;
  47390. /**
  47391. * Disposes the resources of the material.
  47392. * @param forceDisposeTextures - Forces the disposal of all textures.
  47393. */
  47394. dispose(forceDisposeTextures?: boolean): void;
  47395. /**
  47396. * Get the current class name of the texture useful for serialization or dynamic coding.
  47397. * @returns "PBRClearCoatConfiguration"
  47398. */
  47399. getClassName(): string;
  47400. /**
  47401. * Add fallbacks to the effect fallbacks list.
  47402. * @param defines defines the Base texture to use.
  47403. * @param fallbacks defines the current fallback list.
  47404. * @param currentRank defines the current fallback rank.
  47405. * @returns the new fallback rank.
  47406. */
  47407. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47408. /**
  47409. * Add the required uniforms to the current list.
  47410. * @param uniforms defines the current uniform list.
  47411. */
  47412. static AddUniforms(uniforms: string[]): void;
  47413. /**
  47414. * Add the required samplers to the current list.
  47415. * @param samplers defines the current sampler list.
  47416. */
  47417. static AddSamplers(samplers: string[]): void;
  47418. /**
  47419. * Add the required uniforms to the current buffer.
  47420. * @param uniformBuffer defines the current uniform buffer.
  47421. */
  47422. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47423. /**
  47424. * Makes a duplicate of the current configuration into another one.
  47425. * @param clearCoatConfiguration define the config where to copy the info
  47426. */
  47427. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47428. /**
  47429. * Serializes this clear coat configuration.
  47430. * @returns - An object with the serialized config.
  47431. */
  47432. serialize(): any;
  47433. /**
  47434. * Parses a anisotropy Configuration from a serialized object.
  47435. * @param source - Serialized object.
  47436. * @param scene Defines the scene we are parsing for
  47437. * @param rootUrl Defines the rootUrl to load from
  47438. */
  47439. parse(source: any, scene: Scene, rootUrl: string): void;
  47440. }
  47441. }
  47442. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47443. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47444. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47446. import { Vector2 } from "babylonjs/Maths/math.vector";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47449. import { Nullable } from "babylonjs/types";
  47450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47451. /**
  47452. * @hidden
  47453. */
  47454. export interface IMaterialAnisotropicDefines {
  47455. ANISOTROPIC: boolean;
  47456. ANISOTROPIC_TEXTURE: boolean;
  47457. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47458. MAINUV1: boolean;
  47459. _areTexturesDirty: boolean;
  47460. _needUVs: boolean;
  47461. }
  47462. /**
  47463. * Define the code related to the anisotropic parameters of the pbr material.
  47464. */
  47465. export class PBRAnisotropicConfiguration {
  47466. private _isEnabled;
  47467. /**
  47468. * Defines if the anisotropy is enabled in the material.
  47469. */
  47470. isEnabled: boolean;
  47471. /**
  47472. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47473. */
  47474. intensity: number;
  47475. /**
  47476. * Defines if the effect is along the tangents, bitangents or in between.
  47477. * By default, the effect is "strectching" the highlights along the tangents.
  47478. */
  47479. direction: Vector2;
  47480. private _texture;
  47481. /**
  47482. * Stores the anisotropy values in a texture.
  47483. * rg is direction (like normal from -1 to 1)
  47484. * b is a intensity
  47485. */
  47486. texture: Nullable<BaseTexture>;
  47487. /** @hidden */
  47488. private _internalMarkAllSubMeshesAsTexturesDirty;
  47489. /** @hidden */
  47490. _markAllSubMeshesAsTexturesDirty(): void;
  47491. /**
  47492. * Instantiate a new istance of anisotropy configuration.
  47493. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47494. */
  47495. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47496. /**
  47497. * Specifies that the submesh is ready to be used.
  47498. * @param defines the list of "defines" to update.
  47499. * @param scene defines the scene the material belongs to.
  47500. * @returns - boolean indicating that the submesh is ready or not.
  47501. */
  47502. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47503. /**
  47504. * Checks to see if a texture is used in the material.
  47505. * @param defines the list of "defines" to update.
  47506. * @param mesh the mesh we are preparing the defines for.
  47507. * @param scene defines the scene the material belongs to.
  47508. */
  47509. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47510. /**
  47511. * Binds the material data.
  47512. * @param uniformBuffer defines the Uniform buffer to fill in.
  47513. * @param scene defines the scene the material belongs to.
  47514. * @param isFrozen defines wether the material is frozen or not.
  47515. */
  47516. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47517. /**
  47518. * Checks to see if a texture is used in the material.
  47519. * @param texture - Base texture to use.
  47520. * @returns - Boolean specifying if a texture is used in the material.
  47521. */
  47522. hasTexture(texture: BaseTexture): boolean;
  47523. /**
  47524. * Returns an array of the actively used textures.
  47525. * @param activeTextures Array of BaseTextures
  47526. */
  47527. getActiveTextures(activeTextures: BaseTexture[]): void;
  47528. /**
  47529. * Returns the animatable textures.
  47530. * @param animatables Array of animatable textures.
  47531. */
  47532. getAnimatables(animatables: IAnimatable[]): void;
  47533. /**
  47534. * Disposes the resources of the material.
  47535. * @param forceDisposeTextures - Forces the disposal of all textures.
  47536. */
  47537. dispose(forceDisposeTextures?: boolean): void;
  47538. /**
  47539. * Get the current class name of the texture useful for serialization or dynamic coding.
  47540. * @returns "PBRAnisotropicConfiguration"
  47541. */
  47542. getClassName(): string;
  47543. /**
  47544. * Add fallbacks to the effect fallbacks list.
  47545. * @param defines defines the Base texture to use.
  47546. * @param fallbacks defines the current fallback list.
  47547. * @param currentRank defines the current fallback rank.
  47548. * @returns the new fallback rank.
  47549. */
  47550. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47551. /**
  47552. * Add the required uniforms to the current list.
  47553. * @param uniforms defines the current uniform list.
  47554. */
  47555. static AddUniforms(uniforms: string[]): void;
  47556. /**
  47557. * Add the required uniforms to the current buffer.
  47558. * @param uniformBuffer defines the current uniform buffer.
  47559. */
  47560. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47561. /**
  47562. * Add the required samplers to the current list.
  47563. * @param samplers defines the current sampler list.
  47564. */
  47565. static AddSamplers(samplers: string[]): void;
  47566. /**
  47567. * Makes a duplicate of the current configuration into another one.
  47568. * @param anisotropicConfiguration define the config where to copy the info
  47569. */
  47570. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47571. /**
  47572. * Serializes this anisotropy configuration.
  47573. * @returns - An object with the serialized config.
  47574. */
  47575. serialize(): any;
  47576. /**
  47577. * Parses a anisotropy Configuration from a serialized object.
  47578. * @param source - Serialized object.
  47579. * @param scene Defines the scene we are parsing for
  47580. * @param rootUrl Defines the rootUrl to load from
  47581. */
  47582. parse(source: any, scene: Scene, rootUrl: string): void;
  47583. }
  47584. }
  47585. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47586. import { Scene } from "babylonjs/scene";
  47587. /**
  47588. * @hidden
  47589. */
  47590. export interface IMaterialBRDFDefines {
  47591. BRDF_V_HEIGHT_CORRELATED: boolean;
  47592. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47593. SPHERICAL_HARMONICS: boolean;
  47594. /** @hidden */
  47595. _areMiscDirty: boolean;
  47596. }
  47597. /**
  47598. * Define the code related to the BRDF parameters of the pbr material.
  47599. */
  47600. export class PBRBRDFConfiguration {
  47601. /**
  47602. * Default value used for the energy conservation.
  47603. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47604. */
  47605. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47606. /**
  47607. * Default value used for the Smith Visibility Height Correlated mode.
  47608. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47609. */
  47610. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47611. /**
  47612. * Default value used for the IBL diffuse part.
  47613. * This can help switching back to the polynomials mode globally which is a tiny bit
  47614. * less GPU intensive at the drawback of a lower quality.
  47615. */
  47616. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47617. private _useEnergyConservation;
  47618. /**
  47619. * Defines if the material uses energy conservation.
  47620. */
  47621. useEnergyConservation: boolean;
  47622. private _useSmithVisibilityHeightCorrelated;
  47623. /**
  47624. * LEGACY Mode set to false
  47625. * Defines if the material uses height smith correlated visibility term.
  47626. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47627. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47628. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47629. * Not relying on height correlated will also disable energy conservation.
  47630. */
  47631. useSmithVisibilityHeightCorrelated: boolean;
  47632. private _useSphericalHarmonics;
  47633. /**
  47634. * LEGACY Mode set to false
  47635. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47636. * diffuse part of the IBL.
  47637. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47638. * to the ground truth.
  47639. */
  47640. useSphericalHarmonics: boolean;
  47641. /** @hidden */
  47642. private _internalMarkAllSubMeshesAsMiscDirty;
  47643. /** @hidden */
  47644. _markAllSubMeshesAsMiscDirty(): void;
  47645. /**
  47646. * Instantiate a new istance of clear coat configuration.
  47647. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47648. */
  47649. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47650. /**
  47651. * Checks to see if a texture is used in the material.
  47652. * @param defines the list of "defines" to update.
  47653. */
  47654. prepareDefines(defines: IMaterialBRDFDefines): void;
  47655. /**
  47656. * Get the current class name of the texture useful for serialization or dynamic coding.
  47657. * @returns "PBRClearCoatConfiguration"
  47658. */
  47659. getClassName(): string;
  47660. /**
  47661. * Makes a duplicate of the current configuration into another one.
  47662. * @param brdfConfiguration define the config where to copy the info
  47663. */
  47664. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47665. /**
  47666. * Serializes this BRDF configuration.
  47667. * @returns - An object with the serialized config.
  47668. */
  47669. serialize(): any;
  47670. /**
  47671. * Parses a anisotropy Configuration from a serialized object.
  47672. * @param source - Serialized object.
  47673. * @param scene Defines the scene we are parsing for
  47674. * @param rootUrl Defines the rootUrl to load from
  47675. */
  47676. parse(source: any, scene: Scene, rootUrl: string): void;
  47677. }
  47678. }
  47679. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47680. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47681. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47682. import { Color3 } from "babylonjs/Maths/math.color";
  47683. import { Scene } from "babylonjs/scene";
  47684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47685. import { Nullable } from "babylonjs/types";
  47686. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47687. /**
  47688. * @hidden
  47689. */
  47690. export interface IMaterialSheenDefines {
  47691. SHEEN: boolean;
  47692. SHEEN_TEXTURE: boolean;
  47693. SHEEN_TEXTUREDIRECTUV: number;
  47694. SHEEN_LINKWITHALBEDO: boolean;
  47695. /** @hidden */
  47696. _areTexturesDirty: boolean;
  47697. }
  47698. /**
  47699. * Define the code related to the Sheen parameters of the pbr material.
  47700. */
  47701. export class PBRSheenConfiguration {
  47702. private _isEnabled;
  47703. /**
  47704. * Defines if the material uses sheen.
  47705. */
  47706. isEnabled: boolean;
  47707. private _linkSheenWithAlbedo;
  47708. /**
  47709. * Defines if the sheen is linked to the sheen color.
  47710. */
  47711. linkSheenWithAlbedo: boolean;
  47712. /**
  47713. * Defines the sheen intensity.
  47714. */
  47715. intensity: number;
  47716. /**
  47717. * Defines the sheen color.
  47718. */
  47719. color: Color3;
  47720. private _texture;
  47721. /**
  47722. * Stores the sheen tint values in a texture.
  47723. * rgb is tint
  47724. * a is a intensity
  47725. */
  47726. texture: Nullable<BaseTexture>;
  47727. /** @hidden */
  47728. private _internalMarkAllSubMeshesAsTexturesDirty;
  47729. /** @hidden */
  47730. _markAllSubMeshesAsTexturesDirty(): void;
  47731. /**
  47732. * Instantiate a new istance of clear coat configuration.
  47733. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47734. */
  47735. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47736. /**
  47737. * Specifies that the submesh is ready to be used.
  47738. * @param defines the list of "defines" to update.
  47739. * @param scene defines the scene the material belongs to.
  47740. * @returns - boolean indicating that the submesh is ready or not.
  47741. */
  47742. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47743. /**
  47744. * Checks to see if a texture is used in the material.
  47745. * @param defines the list of "defines" to update.
  47746. * @param scene defines the scene the material belongs to.
  47747. */
  47748. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47749. /**
  47750. * Binds the material data.
  47751. * @param uniformBuffer defines the Uniform buffer to fill in.
  47752. * @param scene defines the scene the material belongs to.
  47753. * @param isFrozen defines wether the material is frozen or not.
  47754. */
  47755. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47756. /**
  47757. * Checks to see if a texture is used in the material.
  47758. * @param texture - Base texture to use.
  47759. * @returns - Boolean specifying if a texture is used in the material.
  47760. */
  47761. hasTexture(texture: BaseTexture): boolean;
  47762. /**
  47763. * Returns an array of the actively used textures.
  47764. * @param activeTextures Array of BaseTextures
  47765. */
  47766. getActiveTextures(activeTextures: BaseTexture[]): void;
  47767. /**
  47768. * Returns the animatable textures.
  47769. * @param animatables Array of animatable textures.
  47770. */
  47771. getAnimatables(animatables: IAnimatable[]): void;
  47772. /**
  47773. * Disposes the resources of the material.
  47774. * @param forceDisposeTextures - Forces the disposal of all textures.
  47775. */
  47776. dispose(forceDisposeTextures?: boolean): void;
  47777. /**
  47778. * Get the current class name of the texture useful for serialization or dynamic coding.
  47779. * @returns "PBRSheenConfiguration"
  47780. */
  47781. getClassName(): string;
  47782. /**
  47783. * Add fallbacks to the effect fallbacks list.
  47784. * @param defines defines the Base texture to use.
  47785. * @param fallbacks defines the current fallback list.
  47786. * @param currentRank defines the current fallback rank.
  47787. * @returns the new fallback rank.
  47788. */
  47789. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47790. /**
  47791. * Add the required uniforms to the current list.
  47792. * @param uniforms defines the current uniform list.
  47793. */
  47794. static AddUniforms(uniforms: string[]): void;
  47795. /**
  47796. * Add the required uniforms to the current buffer.
  47797. * @param uniformBuffer defines the current uniform buffer.
  47798. */
  47799. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47800. /**
  47801. * Add the required samplers to the current list.
  47802. * @param samplers defines the current sampler list.
  47803. */
  47804. static AddSamplers(samplers: string[]): void;
  47805. /**
  47806. * Makes a duplicate of the current configuration into another one.
  47807. * @param sheenConfiguration define the config where to copy the info
  47808. */
  47809. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47810. /**
  47811. * Serializes this BRDF configuration.
  47812. * @returns - An object with the serialized config.
  47813. */
  47814. serialize(): any;
  47815. /**
  47816. * Parses a anisotropy Configuration from a serialized object.
  47817. * @param source - Serialized object.
  47818. * @param scene Defines the scene we are parsing for
  47819. * @param rootUrl Defines the rootUrl to load from
  47820. */
  47821. parse(source: any, scene: Scene, rootUrl: string): void;
  47822. }
  47823. }
  47824. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47825. import { Nullable } from "babylonjs/types";
  47826. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47827. import { Color3 } from "babylonjs/Maths/math.color";
  47828. import { SmartArray } from "babylonjs/Misc/smartArray";
  47829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47831. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47833. import { Engine } from "babylonjs/Engines/engine";
  47834. import { Scene } from "babylonjs/scene";
  47835. /**
  47836. * @hidden
  47837. */
  47838. export interface IMaterialSubSurfaceDefines {
  47839. SUBSURFACE: boolean;
  47840. SS_REFRACTION: boolean;
  47841. SS_TRANSLUCENCY: boolean;
  47842. SS_SCATERRING: boolean;
  47843. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47844. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47845. SS_REFRACTIONMAP_3D: boolean;
  47846. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47847. SS_LODINREFRACTIONALPHA: boolean;
  47848. SS_GAMMAREFRACTION: boolean;
  47849. SS_RGBDREFRACTION: boolean;
  47850. SS_LINEARSPECULARREFRACTION: boolean;
  47851. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47852. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47853. /** @hidden */
  47854. _areTexturesDirty: boolean;
  47855. }
  47856. /**
  47857. * Define the code related to the sub surface parameters of the pbr material.
  47858. */
  47859. export class PBRSubSurfaceConfiguration {
  47860. private _isRefractionEnabled;
  47861. /**
  47862. * Defines if the refraction is enabled in the material.
  47863. */
  47864. isRefractionEnabled: boolean;
  47865. private _isTranslucencyEnabled;
  47866. /**
  47867. * Defines if the translucency is enabled in the material.
  47868. */
  47869. isTranslucencyEnabled: boolean;
  47870. private _isScatteringEnabled;
  47871. /**
  47872. * Defines the refraction intensity of the material.
  47873. * The refraction when enabled replaces the Diffuse part of the material.
  47874. * The intensity helps transitionning between diffuse and refraction.
  47875. */
  47876. refractionIntensity: number;
  47877. /**
  47878. * Defines the translucency intensity of the material.
  47879. * When translucency has been enabled, this defines how much of the "translucency"
  47880. * is addded to the diffuse part of the material.
  47881. */
  47882. translucencyIntensity: number;
  47883. /**
  47884. * Defines the scattering intensity of the material.
  47885. * When scattering has been enabled, this defines how much of the "scattered light"
  47886. * is addded to the diffuse part of the material.
  47887. */
  47888. scatteringIntensity: number;
  47889. private _thicknessTexture;
  47890. /**
  47891. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47892. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47893. * 0 would mean minimumThickness
  47894. * 1 would mean maximumThickness
  47895. * The other channels might be use as a mask to vary the different effects intensity.
  47896. */
  47897. thicknessTexture: Nullable<BaseTexture>;
  47898. private _refractionTexture;
  47899. /**
  47900. * Defines the texture to use for refraction.
  47901. */
  47902. refractionTexture: Nullable<BaseTexture>;
  47903. private _indexOfRefraction;
  47904. /**
  47905. * Defines the index of refraction used in the material.
  47906. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47907. */
  47908. indexOfRefraction: number;
  47909. private _invertRefractionY;
  47910. /**
  47911. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47912. */
  47913. invertRefractionY: boolean;
  47914. private _linkRefractionWithTransparency;
  47915. /**
  47916. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47917. * Materials half opaque for instance using refraction could benefit from this control.
  47918. */
  47919. linkRefractionWithTransparency: boolean;
  47920. /**
  47921. * Defines the minimum thickness stored in the thickness map.
  47922. * If no thickness map is defined, this value will be used to simulate thickness.
  47923. */
  47924. minimumThickness: number;
  47925. /**
  47926. * Defines the maximum thickness stored in the thickness map.
  47927. */
  47928. maximumThickness: number;
  47929. /**
  47930. * Defines the volume tint of the material.
  47931. * This is used for both translucency and scattering.
  47932. */
  47933. tintColor: Color3;
  47934. /**
  47935. * Defines the distance at which the tint color should be found in the media.
  47936. * This is used for refraction only.
  47937. */
  47938. tintColorAtDistance: number;
  47939. /**
  47940. * Defines how far each channel transmit through the media.
  47941. * It is defined as a color to simplify it selection.
  47942. */
  47943. diffusionDistance: Color3;
  47944. private _useMaskFromThicknessTexture;
  47945. /**
  47946. * Stores the intensity of the different subsurface effects in the thickness texture.
  47947. * * the green channel is the translucency intensity.
  47948. * * the blue channel is the scattering intensity.
  47949. * * the alpha channel is the refraction intensity.
  47950. */
  47951. useMaskFromThicknessTexture: boolean;
  47952. /** @hidden */
  47953. private _internalMarkAllSubMeshesAsTexturesDirty;
  47954. /** @hidden */
  47955. _markAllSubMeshesAsTexturesDirty(): void;
  47956. /**
  47957. * Instantiate a new istance of sub surface configuration.
  47958. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47959. */
  47960. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47961. /**
  47962. * Gets wehter the submesh is ready to be used or not.
  47963. * @param defines the list of "defines" to update.
  47964. * @param scene defines the scene the material belongs to.
  47965. * @returns - boolean indicating that the submesh is ready or not.
  47966. */
  47967. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47968. /**
  47969. * Checks to see if a texture is used in the material.
  47970. * @param defines the list of "defines" to update.
  47971. * @param scene defines the scene to the material belongs to.
  47972. */
  47973. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47974. /**
  47975. * Binds the material data.
  47976. * @param uniformBuffer defines the Uniform buffer to fill in.
  47977. * @param scene defines the scene the material belongs to.
  47978. * @param engine defines the engine the material belongs to.
  47979. * @param isFrozen defines wether the material is frozen or not.
  47980. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47981. */
  47982. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47983. /**
  47984. * Unbinds the material from the mesh.
  47985. * @param activeEffect defines the effect that should be unbound from.
  47986. * @returns true if unbound, otherwise false
  47987. */
  47988. unbind(activeEffect: Effect): boolean;
  47989. /**
  47990. * Returns the texture used for refraction or null if none is used.
  47991. * @param scene defines the scene the material belongs to.
  47992. * @returns - Refraction texture if present. If no refraction texture and refraction
  47993. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47994. */
  47995. private _getRefractionTexture;
  47996. /**
  47997. * Returns true if alpha blending should be disabled.
  47998. */
  47999. readonly disableAlphaBlending: boolean;
  48000. /**
  48001. * Fills the list of render target textures.
  48002. * @param renderTargets the list of render targets to update
  48003. */
  48004. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48005. /**
  48006. * Checks to see if a texture is used in the material.
  48007. * @param texture - Base texture to use.
  48008. * @returns - Boolean specifying if a texture is used in the material.
  48009. */
  48010. hasTexture(texture: BaseTexture): boolean;
  48011. /**
  48012. * Gets a boolean indicating that current material needs to register RTT
  48013. * @returns true if this uses a render target otherwise false.
  48014. */
  48015. hasRenderTargetTextures(): boolean;
  48016. /**
  48017. * Returns an array of the actively used textures.
  48018. * @param activeTextures Array of BaseTextures
  48019. */
  48020. getActiveTextures(activeTextures: BaseTexture[]): void;
  48021. /**
  48022. * Returns the animatable textures.
  48023. * @param animatables Array of animatable textures.
  48024. */
  48025. getAnimatables(animatables: IAnimatable[]): void;
  48026. /**
  48027. * Disposes the resources of the material.
  48028. * @param forceDisposeTextures - Forces the disposal of all textures.
  48029. */
  48030. dispose(forceDisposeTextures?: boolean): void;
  48031. /**
  48032. * Get the current class name of the texture useful for serialization or dynamic coding.
  48033. * @returns "PBRSubSurfaceConfiguration"
  48034. */
  48035. getClassName(): string;
  48036. /**
  48037. * Add fallbacks to the effect fallbacks list.
  48038. * @param defines defines the Base texture to use.
  48039. * @param fallbacks defines the current fallback list.
  48040. * @param currentRank defines the current fallback rank.
  48041. * @returns the new fallback rank.
  48042. */
  48043. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48044. /**
  48045. * Add the required uniforms to the current list.
  48046. * @param uniforms defines the current uniform list.
  48047. */
  48048. static AddUniforms(uniforms: string[]): void;
  48049. /**
  48050. * Add the required samplers to the current list.
  48051. * @param samplers defines the current sampler list.
  48052. */
  48053. static AddSamplers(samplers: string[]): void;
  48054. /**
  48055. * Add the required uniforms to the current buffer.
  48056. * @param uniformBuffer defines the current uniform buffer.
  48057. */
  48058. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48059. /**
  48060. * Makes a duplicate of the current configuration into another one.
  48061. * @param configuration define the config where to copy the info
  48062. */
  48063. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48064. /**
  48065. * Serializes this Sub Surface configuration.
  48066. * @returns - An object with the serialized config.
  48067. */
  48068. serialize(): any;
  48069. /**
  48070. * Parses a anisotropy Configuration from a serialized object.
  48071. * @param source - Serialized object.
  48072. * @param scene Defines the scene we are parsing for
  48073. * @param rootUrl Defines the rootUrl to load from
  48074. */
  48075. parse(source: any, scene: Scene, rootUrl: string): void;
  48076. }
  48077. }
  48078. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48079. /** @hidden */
  48080. export var pbrFragmentDeclaration: {
  48081. name: string;
  48082. shader: string;
  48083. };
  48084. }
  48085. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48086. /** @hidden */
  48087. export var pbrUboDeclaration: {
  48088. name: string;
  48089. shader: string;
  48090. };
  48091. }
  48092. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48093. /** @hidden */
  48094. export var pbrFragmentExtraDeclaration: {
  48095. name: string;
  48096. shader: string;
  48097. };
  48098. }
  48099. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48100. /** @hidden */
  48101. export var pbrFragmentSamplersDeclaration: {
  48102. name: string;
  48103. shader: string;
  48104. };
  48105. }
  48106. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48107. /** @hidden */
  48108. export var pbrHelperFunctions: {
  48109. name: string;
  48110. shader: string;
  48111. };
  48112. }
  48113. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48114. /** @hidden */
  48115. export var harmonicsFunctions: {
  48116. name: string;
  48117. shader: string;
  48118. };
  48119. }
  48120. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48121. /** @hidden */
  48122. export var pbrDirectLightingSetupFunctions: {
  48123. name: string;
  48124. shader: string;
  48125. };
  48126. }
  48127. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48128. /** @hidden */
  48129. export var pbrDirectLightingFalloffFunctions: {
  48130. name: string;
  48131. shader: string;
  48132. };
  48133. }
  48134. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48135. /** @hidden */
  48136. export var pbrBRDFFunctions: {
  48137. name: string;
  48138. shader: string;
  48139. };
  48140. }
  48141. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48142. /** @hidden */
  48143. export var pbrDirectLightingFunctions: {
  48144. name: string;
  48145. shader: string;
  48146. };
  48147. }
  48148. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48149. /** @hidden */
  48150. export var pbrIBLFunctions: {
  48151. name: string;
  48152. shader: string;
  48153. };
  48154. }
  48155. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48156. /** @hidden */
  48157. export var pbrDebug: {
  48158. name: string;
  48159. shader: string;
  48160. };
  48161. }
  48162. declare module "babylonjs/Shaders/pbr.fragment" {
  48163. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48164. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48165. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48166. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48167. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48168. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48169. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48170. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48171. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48172. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48173. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48174. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48175. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48176. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48177. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48178. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48179. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48180. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48181. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48182. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48183. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48184. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48185. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48186. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48187. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48188. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48189. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48190. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48191. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48192. /** @hidden */
  48193. export var pbrPixelShader: {
  48194. name: string;
  48195. shader: string;
  48196. };
  48197. }
  48198. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48199. /** @hidden */
  48200. export var pbrVertexDeclaration: {
  48201. name: string;
  48202. shader: string;
  48203. };
  48204. }
  48205. declare module "babylonjs/Shaders/pbr.vertex" {
  48206. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48207. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48209. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48210. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48211. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48212. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48213. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48214. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48215. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48216. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48217. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48219. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48220. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48221. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48222. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48223. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48224. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48225. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48226. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48227. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48228. /** @hidden */
  48229. export var pbrVertexShader: {
  48230. name: string;
  48231. shader: string;
  48232. };
  48233. }
  48234. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48235. import { Nullable } from "babylonjs/types";
  48236. import { Scene } from "babylonjs/scene";
  48237. import { Matrix } from "babylonjs/Maths/math.vector";
  48238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48240. import { Mesh } from "babylonjs/Meshes/mesh";
  48241. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48242. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48243. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48244. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48245. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48246. import { Color3 } from "babylonjs/Maths/math.color";
  48247. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48248. import { Material } from "babylonjs/Materials/material";
  48249. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48250. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48252. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48253. import "babylonjs/Shaders/pbr.fragment";
  48254. import "babylonjs/Shaders/pbr.vertex";
  48255. /**
  48256. * Manages the defines for the PBR Material.
  48257. * @hidden
  48258. */
  48259. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48260. PBR: boolean;
  48261. MAINUV1: boolean;
  48262. MAINUV2: boolean;
  48263. UV1: boolean;
  48264. UV2: boolean;
  48265. ALBEDO: boolean;
  48266. ALBEDODIRECTUV: number;
  48267. VERTEXCOLOR: boolean;
  48268. AMBIENT: boolean;
  48269. AMBIENTDIRECTUV: number;
  48270. AMBIENTINGRAYSCALE: boolean;
  48271. OPACITY: boolean;
  48272. VERTEXALPHA: boolean;
  48273. OPACITYDIRECTUV: number;
  48274. OPACITYRGB: boolean;
  48275. ALPHATEST: boolean;
  48276. DEPTHPREPASS: boolean;
  48277. ALPHABLEND: boolean;
  48278. ALPHAFROMALBEDO: boolean;
  48279. ALPHATESTVALUE: string;
  48280. SPECULAROVERALPHA: boolean;
  48281. RADIANCEOVERALPHA: boolean;
  48282. ALPHAFRESNEL: boolean;
  48283. LINEARALPHAFRESNEL: boolean;
  48284. PREMULTIPLYALPHA: boolean;
  48285. EMISSIVE: boolean;
  48286. EMISSIVEDIRECTUV: number;
  48287. REFLECTIVITY: boolean;
  48288. REFLECTIVITYDIRECTUV: number;
  48289. SPECULARTERM: boolean;
  48290. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48291. MICROSURFACEAUTOMATIC: boolean;
  48292. LODBASEDMICROSFURACE: boolean;
  48293. MICROSURFACEMAP: boolean;
  48294. MICROSURFACEMAPDIRECTUV: number;
  48295. METALLICWORKFLOW: boolean;
  48296. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48297. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48298. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48299. AOSTOREINMETALMAPRED: boolean;
  48300. ENVIRONMENTBRDF: boolean;
  48301. ENVIRONMENTBRDF_RGBD: boolean;
  48302. NORMAL: boolean;
  48303. TANGENT: boolean;
  48304. BUMP: boolean;
  48305. BUMPDIRECTUV: number;
  48306. OBJECTSPACE_NORMALMAP: boolean;
  48307. PARALLAX: boolean;
  48308. PARALLAXOCCLUSION: boolean;
  48309. NORMALXYSCALE: boolean;
  48310. LIGHTMAP: boolean;
  48311. LIGHTMAPDIRECTUV: number;
  48312. USELIGHTMAPASSHADOWMAP: boolean;
  48313. GAMMALIGHTMAP: boolean;
  48314. REFLECTION: boolean;
  48315. REFLECTIONMAP_3D: boolean;
  48316. REFLECTIONMAP_SPHERICAL: boolean;
  48317. REFLECTIONMAP_PLANAR: boolean;
  48318. REFLECTIONMAP_CUBIC: boolean;
  48319. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48320. REFLECTIONMAP_PROJECTION: boolean;
  48321. REFLECTIONMAP_SKYBOX: boolean;
  48322. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48323. REFLECTIONMAP_EXPLICIT: boolean;
  48324. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48325. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48326. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48327. INVERTCUBICMAP: boolean;
  48328. USESPHERICALFROMREFLECTIONMAP: boolean;
  48329. USEIRRADIANCEMAP: boolean;
  48330. SPHERICAL_HARMONICS: boolean;
  48331. USESPHERICALINVERTEX: boolean;
  48332. REFLECTIONMAP_OPPOSITEZ: boolean;
  48333. LODINREFLECTIONALPHA: boolean;
  48334. GAMMAREFLECTION: boolean;
  48335. RGBDREFLECTION: boolean;
  48336. LINEARSPECULARREFLECTION: boolean;
  48337. RADIANCEOCCLUSION: boolean;
  48338. HORIZONOCCLUSION: boolean;
  48339. INSTANCES: boolean;
  48340. NUM_BONE_INFLUENCERS: number;
  48341. BonesPerMesh: number;
  48342. BONETEXTURE: boolean;
  48343. NONUNIFORMSCALING: boolean;
  48344. MORPHTARGETS: boolean;
  48345. MORPHTARGETS_NORMAL: boolean;
  48346. MORPHTARGETS_TANGENT: boolean;
  48347. MORPHTARGETS_UV: boolean;
  48348. NUM_MORPH_INFLUENCERS: number;
  48349. IMAGEPROCESSING: boolean;
  48350. VIGNETTE: boolean;
  48351. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48352. VIGNETTEBLENDMODEOPAQUE: boolean;
  48353. TONEMAPPING: boolean;
  48354. TONEMAPPING_ACES: boolean;
  48355. CONTRAST: boolean;
  48356. COLORCURVES: boolean;
  48357. COLORGRADING: boolean;
  48358. COLORGRADING3D: boolean;
  48359. SAMPLER3DGREENDEPTH: boolean;
  48360. SAMPLER3DBGRMAP: boolean;
  48361. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48362. EXPOSURE: boolean;
  48363. MULTIVIEW: boolean;
  48364. USEPHYSICALLIGHTFALLOFF: boolean;
  48365. USEGLTFLIGHTFALLOFF: boolean;
  48366. TWOSIDEDLIGHTING: boolean;
  48367. SHADOWFLOAT: boolean;
  48368. CLIPPLANE: boolean;
  48369. CLIPPLANE2: boolean;
  48370. CLIPPLANE3: boolean;
  48371. CLIPPLANE4: boolean;
  48372. POINTSIZE: boolean;
  48373. FOG: boolean;
  48374. LOGARITHMICDEPTH: boolean;
  48375. FORCENORMALFORWARD: boolean;
  48376. SPECULARAA: boolean;
  48377. CLEARCOAT: boolean;
  48378. CLEARCOAT_DEFAULTIOR: boolean;
  48379. CLEARCOAT_TEXTURE: boolean;
  48380. CLEARCOAT_TEXTUREDIRECTUV: number;
  48381. CLEARCOAT_BUMP: boolean;
  48382. CLEARCOAT_BUMPDIRECTUV: number;
  48383. CLEARCOAT_TINT: boolean;
  48384. CLEARCOAT_TINT_TEXTURE: boolean;
  48385. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48386. ANISOTROPIC: boolean;
  48387. ANISOTROPIC_TEXTURE: boolean;
  48388. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48389. BRDF_V_HEIGHT_CORRELATED: boolean;
  48390. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48391. SHEEN: boolean;
  48392. SHEEN_TEXTURE: boolean;
  48393. SHEEN_TEXTUREDIRECTUV: number;
  48394. SHEEN_LINKWITHALBEDO: boolean;
  48395. SUBSURFACE: boolean;
  48396. SS_REFRACTION: boolean;
  48397. SS_TRANSLUCENCY: boolean;
  48398. SS_SCATERRING: boolean;
  48399. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48400. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48401. SS_REFRACTIONMAP_3D: boolean;
  48402. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48403. SS_LODINREFRACTIONALPHA: boolean;
  48404. SS_GAMMAREFRACTION: boolean;
  48405. SS_RGBDREFRACTION: boolean;
  48406. SS_LINEARSPECULARREFRACTION: boolean;
  48407. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48408. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48409. UNLIT: boolean;
  48410. DEBUGMODE: number;
  48411. /**
  48412. * Initializes the PBR Material defines.
  48413. */
  48414. constructor();
  48415. /**
  48416. * Resets the PBR Material defines.
  48417. */
  48418. reset(): void;
  48419. }
  48420. /**
  48421. * The Physically based material base class of BJS.
  48422. *
  48423. * This offers the main features of a standard PBR material.
  48424. * For more information, please refer to the documentation :
  48425. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48426. */
  48427. export abstract class PBRBaseMaterial extends PushMaterial {
  48428. /**
  48429. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48430. */
  48431. static readonly PBRMATERIAL_OPAQUE: number;
  48432. /**
  48433. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48434. */
  48435. static readonly PBRMATERIAL_ALPHATEST: number;
  48436. /**
  48437. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48438. */
  48439. static readonly PBRMATERIAL_ALPHABLEND: number;
  48440. /**
  48441. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48442. * They are also discarded below the alpha cutoff threshold to improve performances.
  48443. */
  48444. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48445. /**
  48446. * Defines the default value of how much AO map is occluding the analytical lights
  48447. * (point spot...).
  48448. */
  48449. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48450. /**
  48451. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48452. */
  48453. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48454. /**
  48455. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48456. * to enhance interoperability with other engines.
  48457. */
  48458. static readonly LIGHTFALLOFF_GLTF: number;
  48459. /**
  48460. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48461. * to enhance interoperability with other materials.
  48462. */
  48463. static readonly LIGHTFALLOFF_STANDARD: number;
  48464. /**
  48465. * Intensity of the direct lights e.g. the four lights available in your scene.
  48466. * This impacts both the direct diffuse and specular highlights.
  48467. */
  48468. protected _directIntensity: number;
  48469. /**
  48470. * Intensity of the emissive part of the material.
  48471. * This helps controlling the emissive effect without modifying the emissive color.
  48472. */
  48473. protected _emissiveIntensity: number;
  48474. /**
  48475. * Intensity of the environment e.g. how much the environment will light the object
  48476. * either through harmonics for rough material or through the refelction for shiny ones.
  48477. */
  48478. protected _environmentIntensity: number;
  48479. /**
  48480. * This is a special control allowing the reduction of the specular highlights coming from the
  48481. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48482. */
  48483. protected _specularIntensity: number;
  48484. /**
  48485. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48486. */
  48487. private _lightingInfos;
  48488. /**
  48489. * Debug Control allowing disabling the bump map on this material.
  48490. */
  48491. protected _disableBumpMap: boolean;
  48492. /**
  48493. * AKA Diffuse Texture in standard nomenclature.
  48494. */
  48495. protected _albedoTexture: Nullable<BaseTexture>;
  48496. /**
  48497. * AKA Occlusion Texture in other nomenclature.
  48498. */
  48499. protected _ambientTexture: Nullable<BaseTexture>;
  48500. /**
  48501. * AKA Occlusion Texture Intensity in other nomenclature.
  48502. */
  48503. protected _ambientTextureStrength: number;
  48504. /**
  48505. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48506. * 1 means it completely occludes it
  48507. * 0 mean it has no impact
  48508. */
  48509. protected _ambientTextureImpactOnAnalyticalLights: number;
  48510. /**
  48511. * Stores the alpha values in a texture.
  48512. */
  48513. protected _opacityTexture: Nullable<BaseTexture>;
  48514. /**
  48515. * Stores the reflection values in a texture.
  48516. */
  48517. protected _reflectionTexture: Nullable<BaseTexture>;
  48518. /**
  48519. * Stores the emissive values in a texture.
  48520. */
  48521. protected _emissiveTexture: Nullable<BaseTexture>;
  48522. /**
  48523. * AKA Specular texture in other nomenclature.
  48524. */
  48525. protected _reflectivityTexture: Nullable<BaseTexture>;
  48526. /**
  48527. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48528. */
  48529. protected _metallicTexture: Nullable<BaseTexture>;
  48530. /**
  48531. * Specifies the metallic scalar of the metallic/roughness workflow.
  48532. * Can also be used to scale the metalness values of the metallic texture.
  48533. */
  48534. protected _metallic: Nullable<number>;
  48535. /**
  48536. * Specifies the roughness scalar of the metallic/roughness workflow.
  48537. * Can also be used to scale the roughness values of the metallic texture.
  48538. */
  48539. protected _roughness: Nullable<number>;
  48540. /**
  48541. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48542. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48543. */
  48544. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48545. /**
  48546. * Stores surface normal data used to displace a mesh in a texture.
  48547. */
  48548. protected _bumpTexture: Nullable<BaseTexture>;
  48549. /**
  48550. * Stores the pre-calculated light information of a mesh in a texture.
  48551. */
  48552. protected _lightmapTexture: Nullable<BaseTexture>;
  48553. /**
  48554. * The color of a material in ambient lighting.
  48555. */
  48556. protected _ambientColor: Color3;
  48557. /**
  48558. * AKA Diffuse Color in other nomenclature.
  48559. */
  48560. protected _albedoColor: Color3;
  48561. /**
  48562. * AKA Specular Color in other nomenclature.
  48563. */
  48564. protected _reflectivityColor: Color3;
  48565. /**
  48566. * The color applied when light is reflected from a material.
  48567. */
  48568. protected _reflectionColor: Color3;
  48569. /**
  48570. * The color applied when light is emitted from a material.
  48571. */
  48572. protected _emissiveColor: Color3;
  48573. /**
  48574. * AKA Glossiness in other nomenclature.
  48575. */
  48576. protected _microSurface: number;
  48577. /**
  48578. * Specifies that the material will use the light map as a show map.
  48579. */
  48580. protected _useLightmapAsShadowmap: boolean;
  48581. /**
  48582. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48583. * makes the reflect vector face the model (under horizon).
  48584. */
  48585. protected _useHorizonOcclusion: boolean;
  48586. /**
  48587. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48588. * too much the area relying on ambient texture to define their ambient occlusion.
  48589. */
  48590. protected _useRadianceOcclusion: boolean;
  48591. /**
  48592. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48593. */
  48594. protected _useAlphaFromAlbedoTexture: boolean;
  48595. /**
  48596. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48597. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48598. */
  48599. protected _useSpecularOverAlpha: boolean;
  48600. /**
  48601. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48602. */
  48603. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48604. /**
  48605. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48606. */
  48607. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48608. /**
  48609. * Specifies if the metallic texture contains the roughness information in its green channel.
  48610. */
  48611. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48612. /**
  48613. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48614. */
  48615. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48616. /**
  48617. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48618. */
  48619. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48620. /**
  48621. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48622. */
  48623. protected _useAmbientInGrayScale: boolean;
  48624. /**
  48625. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48626. * The material will try to infer what glossiness each pixel should be.
  48627. */
  48628. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48629. /**
  48630. * Defines the falloff type used in this material.
  48631. * It by default is Physical.
  48632. */
  48633. protected _lightFalloff: number;
  48634. /**
  48635. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48636. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48637. */
  48638. protected _useRadianceOverAlpha: boolean;
  48639. /**
  48640. * Allows using an object space normal map (instead of tangent space).
  48641. */
  48642. protected _useObjectSpaceNormalMap: boolean;
  48643. /**
  48644. * Allows using the bump map in parallax mode.
  48645. */
  48646. protected _useParallax: boolean;
  48647. /**
  48648. * Allows using the bump map in parallax occlusion mode.
  48649. */
  48650. protected _useParallaxOcclusion: boolean;
  48651. /**
  48652. * Controls the scale bias of the parallax mode.
  48653. */
  48654. protected _parallaxScaleBias: number;
  48655. /**
  48656. * If sets to true, disables all the lights affecting the material.
  48657. */
  48658. protected _disableLighting: boolean;
  48659. /**
  48660. * Number of Simultaneous lights allowed on the material.
  48661. */
  48662. protected _maxSimultaneousLights: number;
  48663. /**
  48664. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48665. */
  48666. protected _invertNormalMapX: boolean;
  48667. /**
  48668. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48669. */
  48670. protected _invertNormalMapY: boolean;
  48671. /**
  48672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48673. */
  48674. protected _twoSidedLighting: boolean;
  48675. /**
  48676. * Defines the alpha limits in alpha test mode.
  48677. */
  48678. protected _alphaCutOff: number;
  48679. /**
  48680. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48681. */
  48682. protected _forceAlphaTest: boolean;
  48683. /**
  48684. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48685. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48686. */
  48687. protected _useAlphaFresnel: boolean;
  48688. /**
  48689. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48690. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48691. */
  48692. protected _useLinearAlphaFresnel: boolean;
  48693. /**
  48694. * The transparency mode of the material.
  48695. */
  48696. protected _transparencyMode: Nullable<number>;
  48697. /**
  48698. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48699. * from cos thetav and roughness:
  48700. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48701. */
  48702. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48703. /**
  48704. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48705. */
  48706. protected _forceIrradianceInFragment: boolean;
  48707. /**
  48708. * Force normal to face away from face.
  48709. */
  48710. protected _forceNormalForward: boolean;
  48711. /**
  48712. * Enables specular anti aliasing in the PBR shader.
  48713. * It will both interacts on the Geometry for analytical and IBL lighting.
  48714. * It also prefilter the roughness map based on the bump values.
  48715. */
  48716. protected _enableSpecularAntiAliasing: boolean;
  48717. /**
  48718. * Default configuration related to image processing available in the PBR Material.
  48719. */
  48720. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48721. /**
  48722. * Keep track of the image processing observer to allow dispose and replace.
  48723. */
  48724. private _imageProcessingObserver;
  48725. /**
  48726. * Attaches a new image processing configuration to the PBR Material.
  48727. * @param configuration
  48728. */
  48729. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48730. /**
  48731. * Stores the available render targets.
  48732. */
  48733. private _renderTargets;
  48734. /**
  48735. * Sets the global ambient color for the material used in lighting calculations.
  48736. */
  48737. private _globalAmbientColor;
  48738. /**
  48739. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48740. */
  48741. private _useLogarithmicDepth;
  48742. /**
  48743. * If set to true, no lighting calculations will be applied.
  48744. */
  48745. private _unlit;
  48746. private _debugMode;
  48747. /**
  48748. * @hidden
  48749. * This is reserved for the inspector.
  48750. * Defines the material debug mode.
  48751. * It helps seeing only some components of the material while troubleshooting.
  48752. */
  48753. debugMode: number;
  48754. /**
  48755. * @hidden
  48756. * This is reserved for the inspector.
  48757. * Specify from where on screen the debug mode should start.
  48758. * The value goes from -1 (full screen) to 1 (not visible)
  48759. * It helps with side by side comparison against the final render
  48760. * This defaults to -1
  48761. */
  48762. private debugLimit;
  48763. /**
  48764. * @hidden
  48765. * This is reserved for the inspector.
  48766. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48767. * You can use the factor to better multiply the final value.
  48768. */
  48769. private debugFactor;
  48770. /**
  48771. * Defines the clear coat layer parameters for the material.
  48772. */
  48773. readonly clearCoat: PBRClearCoatConfiguration;
  48774. /**
  48775. * Defines the anisotropic parameters for the material.
  48776. */
  48777. readonly anisotropy: PBRAnisotropicConfiguration;
  48778. /**
  48779. * Defines the BRDF parameters for the material.
  48780. */
  48781. readonly brdf: PBRBRDFConfiguration;
  48782. /**
  48783. * Defines the Sheen parameters for the material.
  48784. */
  48785. readonly sheen: PBRSheenConfiguration;
  48786. /**
  48787. * Defines the SubSurface parameters for the material.
  48788. */
  48789. readonly subSurface: PBRSubSurfaceConfiguration;
  48790. /**
  48791. * Custom callback helping to override the default shader used in the material.
  48792. */
  48793. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48794. /**
  48795. * Instantiates a new PBRMaterial instance.
  48796. *
  48797. * @param name The material name
  48798. * @param scene The scene the material will be use in.
  48799. */
  48800. constructor(name: string, scene: Scene);
  48801. /**
  48802. * Gets a boolean indicating that current material needs to register RTT
  48803. */
  48804. readonly hasRenderTargetTextures: boolean;
  48805. /**
  48806. * Gets the name of the material class.
  48807. */
  48808. getClassName(): string;
  48809. /**
  48810. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48811. */
  48812. /**
  48813. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48814. */
  48815. useLogarithmicDepth: boolean;
  48816. /**
  48817. * Gets the current transparency mode.
  48818. */
  48819. /**
  48820. * Sets the transparency mode of the material.
  48821. *
  48822. * | Value | Type | Description |
  48823. * | ----- | ----------------------------------- | ----------- |
  48824. * | 0 | OPAQUE | |
  48825. * | 1 | ALPHATEST | |
  48826. * | 2 | ALPHABLEND | |
  48827. * | 3 | ALPHATESTANDBLEND | |
  48828. *
  48829. */
  48830. transparencyMode: Nullable<number>;
  48831. /**
  48832. * Returns true if alpha blending should be disabled.
  48833. */
  48834. private readonly _disableAlphaBlending;
  48835. /**
  48836. * Specifies whether or not this material should be rendered in alpha blend mode.
  48837. */
  48838. needAlphaBlending(): boolean;
  48839. /**
  48840. * Specifies if the mesh will require alpha blending.
  48841. * @param mesh - BJS mesh.
  48842. */
  48843. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48844. /**
  48845. * Specifies whether or not this material should be rendered in alpha test mode.
  48846. */
  48847. needAlphaTesting(): boolean;
  48848. /**
  48849. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48850. */
  48851. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48852. /**
  48853. * Gets the texture used for the alpha test.
  48854. */
  48855. getAlphaTestTexture(): Nullable<BaseTexture>;
  48856. /**
  48857. * Specifies that the submesh is ready to be used.
  48858. * @param mesh - BJS mesh.
  48859. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48860. * @param useInstances - Specifies that instances should be used.
  48861. * @returns - boolean indicating that the submesh is ready or not.
  48862. */
  48863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48864. /**
  48865. * Specifies if the material uses metallic roughness workflow.
  48866. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48867. */
  48868. isMetallicWorkflow(): boolean;
  48869. private _prepareEffect;
  48870. private _prepareDefines;
  48871. /**
  48872. * Force shader compilation
  48873. */
  48874. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48875. clipPlane: boolean;
  48876. }>): void;
  48877. /**
  48878. * Initializes the uniform buffer layout for the shader.
  48879. */
  48880. buildUniformLayout(): void;
  48881. /**
  48882. * Unbinds the material from the mesh
  48883. */
  48884. unbind(): void;
  48885. /**
  48886. * Binds the submesh data.
  48887. * @param world - The world matrix.
  48888. * @param mesh - The BJS mesh.
  48889. * @param subMesh - A submesh of the BJS mesh.
  48890. */
  48891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48892. /**
  48893. * Returns the animatable textures.
  48894. * @returns - Array of animatable textures.
  48895. */
  48896. getAnimatables(): IAnimatable[];
  48897. /**
  48898. * Returns the texture used for reflections.
  48899. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48900. */
  48901. private _getReflectionTexture;
  48902. /**
  48903. * Returns an array of the actively used textures.
  48904. * @returns - Array of BaseTextures
  48905. */
  48906. getActiveTextures(): BaseTexture[];
  48907. /**
  48908. * Checks to see if a texture is used in the material.
  48909. * @param texture - Base texture to use.
  48910. * @returns - Boolean specifying if a texture is used in the material.
  48911. */
  48912. hasTexture(texture: BaseTexture): boolean;
  48913. /**
  48914. * Disposes the resources of the material.
  48915. * @param forceDisposeEffect - Forces the disposal of effects.
  48916. * @param forceDisposeTextures - Forces the disposal of all textures.
  48917. */
  48918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48919. }
  48920. }
  48921. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48922. import { Nullable } from "babylonjs/types";
  48923. import { Scene } from "babylonjs/scene";
  48924. import { Color3 } from "babylonjs/Maths/math.color";
  48925. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48926. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48928. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48929. /**
  48930. * The Physically based material of BJS.
  48931. *
  48932. * This offers the main features of a standard PBR material.
  48933. * For more information, please refer to the documentation :
  48934. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48935. */
  48936. export class PBRMaterial extends PBRBaseMaterial {
  48937. /**
  48938. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48939. */
  48940. static readonly PBRMATERIAL_OPAQUE: number;
  48941. /**
  48942. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48943. */
  48944. static readonly PBRMATERIAL_ALPHATEST: number;
  48945. /**
  48946. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48947. */
  48948. static readonly PBRMATERIAL_ALPHABLEND: number;
  48949. /**
  48950. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48951. * They are also discarded below the alpha cutoff threshold to improve performances.
  48952. */
  48953. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48954. /**
  48955. * Defines the default value of how much AO map is occluding the analytical lights
  48956. * (point spot...).
  48957. */
  48958. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48959. /**
  48960. * Intensity of the direct lights e.g. the four lights available in your scene.
  48961. * This impacts both the direct diffuse and specular highlights.
  48962. */
  48963. directIntensity: number;
  48964. /**
  48965. * Intensity of the emissive part of the material.
  48966. * This helps controlling the emissive effect without modifying the emissive color.
  48967. */
  48968. emissiveIntensity: number;
  48969. /**
  48970. * Intensity of the environment e.g. how much the environment will light the object
  48971. * either through harmonics for rough material or through the refelction for shiny ones.
  48972. */
  48973. environmentIntensity: number;
  48974. /**
  48975. * This is a special control allowing the reduction of the specular highlights coming from the
  48976. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48977. */
  48978. specularIntensity: number;
  48979. /**
  48980. * Debug Control allowing disabling the bump map on this material.
  48981. */
  48982. disableBumpMap: boolean;
  48983. /**
  48984. * AKA Diffuse Texture in standard nomenclature.
  48985. */
  48986. albedoTexture: BaseTexture;
  48987. /**
  48988. * AKA Occlusion Texture in other nomenclature.
  48989. */
  48990. ambientTexture: BaseTexture;
  48991. /**
  48992. * AKA Occlusion Texture Intensity in other nomenclature.
  48993. */
  48994. ambientTextureStrength: number;
  48995. /**
  48996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48997. * 1 means it completely occludes it
  48998. * 0 mean it has no impact
  48999. */
  49000. ambientTextureImpactOnAnalyticalLights: number;
  49001. /**
  49002. * Stores the alpha values in a texture.
  49003. */
  49004. opacityTexture: BaseTexture;
  49005. /**
  49006. * Stores the reflection values in a texture.
  49007. */
  49008. reflectionTexture: Nullable<BaseTexture>;
  49009. /**
  49010. * Stores the emissive values in a texture.
  49011. */
  49012. emissiveTexture: BaseTexture;
  49013. /**
  49014. * AKA Specular texture in other nomenclature.
  49015. */
  49016. reflectivityTexture: BaseTexture;
  49017. /**
  49018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49019. */
  49020. metallicTexture: BaseTexture;
  49021. /**
  49022. * Specifies the metallic scalar of the metallic/roughness workflow.
  49023. * Can also be used to scale the metalness values of the metallic texture.
  49024. */
  49025. metallic: Nullable<number>;
  49026. /**
  49027. * Specifies the roughness scalar of the metallic/roughness workflow.
  49028. * Can also be used to scale the roughness values of the metallic texture.
  49029. */
  49030. roughness: Nullable<number>;
  49031. /**
  49032. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49033. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49034. */
  49035. microSurfaceTexture: BaseTexture;
  49036. /**
  49037. * Stores surface normal data used to displace a mesh in a texture.
  49038. */
  49039. bumpTexture: BaseTexture;
  49040. /**
  49041. * Stores the pre-calculated light information of a mesh in a texture.
  49042. */
  49043. lightmapTexture: BaseTexture;
  49044. /**
  49045. * Stores the refracted light information in a texture.
  49046. */
  49047. refractionTexture: Nullable<BaseTexture>;
  49048. /**
  49049. * The color of a material in ambient lighting.
  49050. */
  49051. ambientColor: Color3;
  49052. /**
  49053. * AKA Diffuse Color in other nomenclature.
  49054. */
  49055. albedoColor: Color3;
  49056. /**
  49057. * AKA Specular Color in other nomenclature.
  49058. */
  49059. reflectivityColor: Color3;
  49060. /**
  49061. * The color reflected from the material.
  49062. */
  49063. reflectionColor: Color3;
  49064. /**
  49065. * The color emitted from the material.
  49066. */
  49067. emissiveColor: Color3;
  49068. /**
  49069. * AKA Glossiness in other nomenclature.
  49070. */
  49071. microSurface: number;
  49072. /**
  49073. * source material index of refraction (IOR)' / 'destination material IOR.
  49074. */
  49075. indexOfRefraction: number;
  49076. /**
  49077. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49078. */
  49079. invertRefractionY: boolean;
  49080. /**
  49081. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49082. * Materials half opaque for instance using refraction could benefit from this control.
  49083. */
  49084. linkRefractionWithTransparency: boolean;
  49085. /**
  49086. * If true, the light map contains occlusion information instead of lighting info.
  49087. */
  49088. useLightmapAsShadowmap: boolean;
  49089. /**
  49090. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49091. */
  49092. useAlphaFromAlbedoTexture: boolean;
  49093. /**
  49094. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49095. */
  49096. forceAlphaTest: boolean;
  49097. /**
  49098. * Defines the alpha limits in alpha test mode.
  49099. */
  49100. alphaCutOff: number;
  49101. /**
  49102. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49103. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49104. */
  49105. useSpecularOverAlpha: boolean;
  49106. /**
  49107. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49108. */
  49109. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49110. /**
  49111. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49112. */
  49113. useRoughnessFromMetallicTextureAlpha: boolean;
  49114. /**
  49115. * Specifies if the metallic texture contains the roughness information in its green channel.
  49116. */
  49117. useRoughnessFromMetallicTextureGreen: boolean;
  49118. /**
  49119. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49120. */
  49121. useMetallnessFromMetallicTextureBlue: boolean;
  49122. /**
  49123. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49124. */
  49125. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49126. /**
  49127. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49128. */
  49129. useAmbientInGrayScale: boolean;
  49130. /**
  49131. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49132. * The material will try to infer what glossiness each pixel should be.
  49133. */
  49134. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49135. /**
  49136. * BJS is using an harcoded light falloff based on a manually sets up range.
  49137. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49138. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49139. */
  49140. /**
  49141. * BJS is using an harcoded light falloff based on a manually sets up range.
  49142. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49143. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49144. */
  49145. usePhysicalLightFalloff: boolean;
  49146. /**
  49147. * In order to support the falloff compatibility with gltf, a special mode has been added
  49148. * to reproduce the gltf light falloff.
  49149. */
  49150. /**
  49151. * In order to support the falloff compatibility with gltf, a special mode has been added
  49152. * to reproduce the gltf light falloff.
  49153. */
  49154. useGLTFLightFalloff: boolean;
  49155. /**
  49156. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49157. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49158. */
  49159. useRadianceOverAlpha: boolean;
  49160. /**
  49161. * Allows using an object space normal map (instead of tangent space).
  49162. */
  49163. useObjectSpaceNormalMap: boolean;
  49164. /**
  49165. * Allows using the bump map in parallax mode.
  49166. */
  49167. useParallax: boolean;
  49168. /**
  49169. * Allows using the bump map in parallax occlusion mode.
  49170. */
  49171. useParallaxOcclusion: boolean;
  49172. /**
  49173. * Controls the scale bias of the parallax mode.
  49174. */
  49175. parallaxScaleBias: number;
  49176. /**
  49177. * If sets to true, disables all the lights affecting the material.
  49178. */
  49179. disableLighting: boolean;
  49180. /**
  49181. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49182. */
  49183. forceIrradianceInFragment: boolean;
  49184. /**
  49185. * Number of Simultaneous lights allowed on the material.
  49186. */
  49187. maxSimultaneousLights: number;
  49188. /**
  49189. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49190. */
  49191. invertNormalMapX: boolean;
  49192. /**
  49193. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49194. */
  49195. invertNormalMapY: boolean;
  49196. /**
  49197. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49198. */
  49199. twoSidedLighting: boolean;
  49200. /**
  49201. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49202. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49203. */
  49204. useAlphaFresnel: boolean;
  49205. /**
  49206. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49207. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49208. */
  49209. useLinearAlphaFresnel: boolean;
  49210. /**
  49211. * Let user defines the brdf lookup texture used for IBL.
  49212. * A default 8bit version is embedded but you could point at :
  49213. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49214. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49215. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49216. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49217. */
  49218. environmentBRDFTexture: Nullable<BaseTexture>;
  49219. /**
  49220. * Force normal to face away from face.
  49221. */
  49222. forceNormalForward: boolean;
  49223. /**
  49224. * Enables specular anti aliasing in the PBR shader.
  49225. * It will both interacts on the Geometry for analytical and IBL lighting.
  49226. * It also prefilter the roughness map based on the bump values.
  49227. */
  49228. enableSpecularAntiAliasing: boolean;
  49229. /**
  49230. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49231. * makes the reflect vector face the model (under horizon).
  49232. */
  49233. useHorizonOcclusion: boolean;
  49234. /**
  49235. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49236. * too much the area relying on ambient texture to define their ambient occlusion.
  49237. */
  49238. useRadianceOcclusion: boolean;
  49239. /**
  49240. * If set to true, no lighting calculations will be applied.
  49241. */
  49242. unlit: boolean;
  49243. /**
  49244. * Gets the image processing configuration used either in this material.
  49245. */
  49246. /**
  49247. * Sets the Default image processing configuration used either in the this material.
  49248. *
  49249. * If sets to null, the scene one is in use.
  49250. */
  49251. imageProcessingConfiguration: ImageProcessingConfiguration;
  49252. /**
  49253. * Gets wether the color curves effect is enabled.
  49254. */
  49255. /**
  49256. * Sets wether the color curves effect is enabled.
  49257. */
  49258. cameraColorCurvesEnabled: boolean;
  49259. /**
  49260. * Gets wether the color grading effect is enabled.
  49261. */
  49262. /**
  49263. * Gets wether the color grading effect is enabled.
  49264. */
  49265. cameraColorGradingEnabled: boolean;
  49266. /**
  49267. * Gets wether tonemapping is enabled or not.
  49268. */
  49269. /**
  49270. * Sets wether tonemapping is enabled or not
  49271. */
  49272. cameraToneMappingEnabled: boolean;
  49273. /**
  49274. * The camera exposure used on this material.
  49275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49276. * This corresponds to a photographic exposure.
  49277. */
  49278. /**
  49279. * The camera exposure used on this material.
  49280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49281. * This corresponds to a photographic exposure.
  49282. */
  49283. cameraExposure: number;
  49284. /**
  49285. * Gets The camera contrast used on this material.
  49286. */
  49287. /**
  49288. * Sets The camera contrast used on this material.
  49289. */
  49290. cameraContrast: number;
  49291. /**
  49292. * Gets the Color Grading 2D Lookup Texture.
  49293. */
  49294. /**
  49295. * Sets the Color Grading 2D Lookup Texture.
  49296. */
  49297. cameraColorGradingTexture: Nullable<BaseTexture>;
  49298. /**
  49299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49301. * 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;
  49302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49303. */
  49304. /**
  49305. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49306. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49307. * 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;
  49308. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49309. */
  49310. cameraColorCurves: Nullable<ColorCurves>;
  49311. /**
  49312. * Instantiates a new PBRMaterial instance.
  49313. *
  49314. * @param name The material name
  49315. * @param scene The scene the material will be use in.
  49316. */
  49317. constructor(name: string, scene: Scene);
  49318. /**
  49319. * Returns the name of this material class.
  49320. */
  49321. getClassName(): string;
  49322. /**
  49323. * Makes a duplicate of the current material.
  49324. * @param name - name to use for the new material.
  49325. */
  49326. clone(name: string): PBRMaterial;
  49327. /**
  49328. * Serializes this PBR Material.
  49329. * @returns - An object with the serialized material.
  49330. */
  49331. serialize(): any;
  49332. /**
  49333. * Parses a PBR Material from a serialized object.
  49334. * @param source - Serialized object.
  49335. * @param scene - BJS scene instance.
  49336. * @param rootUrl - url for the scene object
  49337. * @returns - PBRMaterial
  49338. */
  49339. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49340. }
  49341. }
  49342. declare module "babylonjs/Misc/dds" {
  49343. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49344. import { Engine } from "babylonjs/Engines/engine";
  49345. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49346. import { Nullable } from "babylonjs/types";
  49347. import { Scene } from "babylonjs/scene";
  49348. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49349. /**
  49350. * Direct draw surface info
  49351. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49352. */
  49353. export interface DDSInfo {
  49354. /**
  49355. * Width of the texture
  49356. */
  49357. width: number;
  49358. /**
  49359. * Width of the texture
  49360. */
  49361. height: number;
  49362. /**
  49363. * Number of Mipmaps for the texture
  49364. * @see https://en.wikipedia.org/wiki/Mipmap
  49365. */
  49366. mipmapCount: number;
  49367. /**
  49368. * If the textures format is a known fourCC format
  49369. * @see https://www.fourcc.org/
  49370. */
  49371. isFourCC: boolean;
  49372. /**
  49373. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49374. */
  49375. isRGB: boolean;
  49376. /**
  49377. * If the texture is a lumincance format
  49378. */
  49379. isLuminance: boolean;
  49380. /**
  49381. * If this is a cube texture
  49382. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49383. */
  49384. isCube: boolean;
  49385. /**
  49386. * If the texture is a compressed format eg. FOURCC_DXT1
  49387. */
  49388. isCompressed: boolean;
  49389. /**
  49390. * The dxgiFormat of the texture
  49391. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49392. */
  49393. dxgiFormat: number;
  49394. /**
  49395. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49396. */
  49397. textureType: number;
  49398. /**
  49399. * Sphericle polynomial created for the dds texture
  49400. */
  49401. sphericalPolynomial?: SphericalPolynomial;
  49402. }
  49403. /**
  49404. * Class used to provide DDS decompression tools
  49405. */
  49406. export class DDSTools {
  49407. /**
  49408. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49409. */
  49410. static StoreLODInAlphaChannel: boolean;
  49411. /**
  49412. * Gets DDS information from an array buffer
  49413. * @param arrayBuffer defines the array buffer to read data from
  49414. * @returns the DDS information
  49415. */
  49416. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49417. private static _FloatView;
  49418. private static _Int32View;
  49419. private static _ToHalfFloat;
  49420. private static _FromHalfFloat;
  49421. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49422. private static _GetHalfFloatRGBAArrayBuffer;
  49423. private static _GetFloatRGBAArrayBuffer;
  49424. private static _GetFloatAsUIntRGBAArrayBuffer;
  49425. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49426. private static _GetRGBAArrayBuffer;
  49427. private static _ExtractLongWordOrder;
  49428. private static _GetRGBArrayBuffer;
  49429. private static _GetLuminanceArrayBuffer;
  49430. /**
  49431. * Uploads DDS Levels to a Babylon Texture
  49432. * @hidden
  49433. */
  49434. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49435. }
  49436. module "babylonjs/Engines/engine" {
  49437. interface Engine {
  49438. /**
  49439. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49440. * @param rootUrl defines the url where the file to load is located
  49441. * @param scene defines the current scene
  49442. * @param lodScale defines scale to apply to the mip map selection
  49443. * @param lodOffset defines offset to apply to the mip map selection
  49444. * @param onLoad defines an optional callback raised when the texture is loaded
  49445. * @param onError defines an optional callback raised if there is an issue to load the texture
  49446. * @param format defines the format of the data
  49447. * @param forcedExtension defines the extension to use to pick the right loader
  49448. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49449. * @returns the cube texture as an InternalTexture
  49450. */
  49451. 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;
  49452. }
  49453. }
  49454. }
  49455. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49456. import { Nullable } from "babylonjs/types";
  49457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49458. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49459. /**
  49460. * Implementation of the DDS Texture Loader.
  49461. * @hidden
  49462. */
  49463. export class _DDSTextureLoader implements IInternalTextureLoader {
  49464. /**
  49465. * Defines wether the loader supports cascade loading the different faces.
  49466. */
  49467. readonly supportCascades: boolean;
  49468. /**
  49469. * This returns if the loader support the current file information.
  49470. * @param extension defines the file extension of the file being loaded
  49471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49472. * @param fallback defines the fallback internal texture if any
  49473. * @param isBase64 defines whether the texture is encoded as a base64
  49474. * @param isBuffer defines whether the texture data are stored as a buffer
  49475. * @returns true if the loader can load the specified file
  49476. */
  49477. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49478. /**
  49479. * Transform the url before loading if required.
  49480. * @param rootUrl the url of the texture
  49481. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49482. * @returns the transformed texture
  49483. */
  49484. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49485. /**
  49486. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49487. * @param rootUrl the url of the texture
  49488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49489. * @returns the fallback texture
  49490. */
  49491. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49492. /**
  49493. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49494. * @param data contains the texture data
  49495. * @param texture defines the BabylonJS internal texture
  49496. * @param createPolynomials will be true if polynomials have been requested
  49497. * @param onLoad defines the callback to trigger once the texture is ready
  49498. * @param onError defines the callback to trigger in case of error
  49499. */
  49500. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49501. /**
  49502. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49503. * @param data contains the texture data
  49504. * @param texture defines the BabylonJS internal texture
  49505. * @param callback defines the method to call once ready to upload
  49506. */
  49507. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49508. }
  49509. }
  49510. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49512. /** @hidden */
  49513. export var rgbdEncodePixelShader: {
  49514. name: string;
  49515. shader: string;
  49516. };
  49517. }
  49518. declare module "babylonjs/Misc/environmentTextureTools" {
  49519. import { Nullable } from "babylonjs/types";
  49520. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49522. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49523. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49524. import "babylonjs/Shaders/rgbdEncode.fragment";
  49525. import "babylonjs/Shaders/rgbdDecode.fragment";
  49526. /**
  49527. * Raw texture data and descriptor sufficient for WebGL texture upload
  49528. */
  49529. export interface EnvironmentTextureInfo {
  49530. /**
  49531. * Version of the environment map
  49532. */
  49533. version: number;
  49534. /**
  49535. * Width of image
  49536. */
  49537. width: number;
  49538. /**
  49539. * Irradiance information stored in the file.
  49540. */
  49541. irradiance: any;
  49542. /**
  49543. * Specular information stored in the file.
  49544. */
  49545. specular: any;
  49546. }
  49547. /**
  49548. * Sets of helpers addressing the serialization and deserialization of environment texture
  49549. * stored in a BabylonJS env file.
  49550. * Those files are usually stored as .env files.
  49551. */
  49552. export class EnvironmentTextureTools {
  49553. /**
  49554. * Magic number identifying the env file.
  49555. */
  49556. private static _MagicBytes;
  49557. /**
  49558. * Gets the environment info from an env file.
  49559. * @param data The array buffer containing the .env bytes.
  49560. * @returns the environment file info (the json header) if successfully parsed.
  49561. */
  49562. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49563. /**
  49564. * Creates an environment texture from a loaded cube texture.
  49565. * @param texture defines the cube texture to convert in env file
  49566. * @return a promise containing the environment data if succesfull.
  49567. */
  49568. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49569. /**
  49570. * Creates a JSON representation of the spherical data.
  49571. * @param texture defines the texture containing the polynomials
  49572. * @return the JSON representation of the spherical info
  49573. */
  49574. private static _CreateEnvTextureIrradiance;
  49575. /**
  49576. * Uploads the texture info contained in the env file to the GPU.
  49577. * @param texture defines the internal texture to upload to
  49578. * @param arrayBuffer defines the buffer cotaining the data to load
  49579. * @param info defines the texture info retrieved through the GetEnvInfo method
  49580. * @returns a promise
  49581. */
  49582. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49583. /**
  49584. * Uploads the levels of image data to the GPU.
  49585. * @param texture defines the internal texture to upload to
  49586. * @param imageData defines the array buffer views of image data [mipmap][face]
  49587. * @returns a promise
  49588. */
  49589. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49590. /**
  49591. * Uploads spherical polynomials information to the texture.
  49592. * @param texture defines the texture we are trying to upload the information to
  49593. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49594. */
  49595. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49596. /** @hidden */
  49597. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49598. }
  49599. }
  49600. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49601. import { Nullable } from "babylonjs/types";
  49602. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49603. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49604. /**
  49605. * Implementation of the ENV Texture Loader.
  49606. * @hidden
  49607. */
  49608. export class _ENVTextureLoader implements IInternalTextureLoader {
  49609. /**
  49610. * Defines wether the loader supports cascade loading the different faces.
  49611. */
  49612. readonly supportCascades: boolean;
  49613. /**
  49614. * This returns if the loader support the current file information.
  49615. * @param extension defines the file extension of the file being loaded
  49616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49617. * @param fallback defines the fallback internal texture if any
  49618. * @param isBase64 defines whether the texture is encoded as a base64
  49619. * @param isBuffer defines whether the texture data are stored as a buffer
  49620. * @returns true if the loader can load the specified file
  49621. */
  49622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49623. /**
  49624. * Transform the url before loading if required.
  49625. * @param rootUrl the url of the texture
  49626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49627. * @returns the transformed texture
  49628. */
  49629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49630. /**
  49631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49632. * @param rootUrl the url of the texture
  49633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49634. * @returns the fallback texture
  49635. */
  49636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49637. /**
  49638. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49639. * @param data contains the texture data
  49640. * @param texture defines the BabylonJS internal texture
  49641. * @param createPolynomials will be true if polynomials have been requested
  49642. * @param onLoad defines the callback to trigger once the texture is ready
  49643. * @param onError defines the callback to trigger in case of error
  49644. */
  49645. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49646. /**
  49647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49648. * @param data contains the texture data
  49649. * @param texture defines the BabylonJS internal texture
  49650. * @param callback defines the method to call once ready to upload
  49651. */
  49652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49653. }
  49654. }
  49655. declare module "babylonjs/Misc/khronosTextureContainer" {
  49656. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49657. /**
  49658. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49659. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49660. */
  49661. export class KhronosTextureContainer {
  49662. /** contents of the KTX container file */
  49663. arrayBuffer: any;
  49664. private static HEADER_LEN;
  49665. private static COMPRESSED_2D;
  49666. private static COMPRESSED_3D;
  49667. private static TEX_2D;
  49668. private static TEX_3D;
  49669. /**
  49670. * Gets the openGL type
  49671. */
  49672. glType: number;
  49673. /**
  49674. * Gets the openGL type size
  49675. */
  49676. glTypeSize: number;
  49677. /**
  49678. * Gets the openGL format
  49679. */
  49680. glFormat: number;
  49681. /**
  49682. * Gets the openGL internal format
  49683. */
  49684. glInternalFormat: number;
  49685. /**
  49686. * Gets the base internal format
  49687. */
  49688. glBaseInternalFormat: number;
  49689. /**
  49690. * Gets image width in pixel
  49691. */
  49692. pixelWidth: number;
  49693. /**
  49694. * Gets image height in pixel
  49695. */
  49696. pixelHeight: number;
  49697. /**
  49698. * Gets image depth in pixels
  49699. */
  49700. pixelDepth: number;
  49701. /**
  49702. * Gets the number of array elements
  49703. */
  49704. numberOfArrayElements: number;
  49705. /**
  49706. * Gets the number of faces
  49707. */
  49708. numberOfFaces: number;
  49709. /**
  49710. * Gets the number of mipmap levels
  49711. */
  49712. numberOfMipmapLevels: number;
  49713. /**
  49714. * Gets the bytes of key value data
  49715. */
  49716. bytesOfKeyValueData: number;
  49717. /**
  49718. * Gets the load type
  49719. */
  49720. loadType: number;
  49721. /**
  49722. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49723. */
  49724. isInvalid: boolean;
  49725. /**
  49726. * Creates a new KhronosTextureContainer
  49727. * @param arrayBuffer contents of the KTX container file
  49728. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49729. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49730. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49731. */
  49732. constructor(
  49733. /** contents of the KTX container file */
  49734. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49735. /**
  49736. * Uploads KTX content to a Babylon Texture.
  49737. * It is assumed that the texture has already been created & is currently bound
  49738. * @hidden
  49739. */
  49740. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49741. private _upload2DCompressedLevels;
  49742. }
  49743. }
  49744. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49745. import { Nullable } from "babylonjs/types";
  49746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49747. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49748. /**
  49749. * Implementation of the KTX Texture Loader.
  49750. * @hidden
  49751. */
  49752. export class _KTXTextureLoader implements IInternalTextureLoader {
  49753. /**
  49754. * Defines wether the loader supports cascade loading the different faces.
  49755. */
  49756. readonly supportCascades: boolean;
  49757. /**
  49758. * This returns if the loader support the current file information.
  49759. * @param extension defines the file extension of the file being loaded
  49760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49761. * @param fallback defines the fallback internal texture if any
  49762. * @param isBase64 defines whether the texture is encoded as a base64
  49763. * @param isBuffer defines whether the texture data are stored as a buffer
  49764. * @returns true if the loader can load the specified file
  49765. */
  49766. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49767. /**
  49768. * Transform the url before loading if required.
  49769. * @param rootUrl the url of the texture
  49770. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49771. * @returns the transformed texture
  49772. */
  49773. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49774. /**
  49775. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49776. * @param rootUrl the url of the texture
  49777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49778. * @returns the fallback texture
  49779. */
  49780. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49781. /**
  49782. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49783. * @param data contains the texture data
  49784. * @param texture defines the BabylonJS internal texture
  49785. * @param createPolynomials will be true if polynomials have been requested
  49786. * @param onLoad defines the callback to trigger once the texture is ready
  49787. * @param onError defines the callback to trigger in case of error
  49788. */
  49789. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49790. /**
  49791. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49792. * @param data contains the texture data
  49793. * @param texture defines the BabylonJS internal texture
  49794. * @param callback defines the method to call once ready to upload
  49795. */
  49796. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49797. }
  49798. }
  49799. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49800. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49801. import { Scene } from "babylonjs/scene";
  49802. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49803. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49804. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49805. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49806. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49807. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49809. /**
  49810. * Options for the default xr helper
  49811. */
  49812. export class WebXRDefaultExperienceOptions {
  49813. /**
  49814. * Floor meshes that should be used for teleporting
  49815. */
  49816. floorMeshes: Array<AbstractMesh>;
  49817. }
  49818. /**
  49819. * Default experience which provides a similar setup to the previous webVRExperience
  49820. */
  49821. export class WebXRDefaultExperience {
  49822. /**
  49823. * Base experience
  49824. */
  49825. baseExperience: WebXRExperienceHelper;
  49826. /**
  49827. * Input experience extension
  49828. */
  49829. input: WebXRInput;
  49830. /**
  49831. * Loads the controller models
  49832. */
  49833. controllerModelLoader: WebXRControllerModelLoader;
  49834. /**
  49835. * Enables laser pointer and selection
  49836. */
  49837. pointerSelection: WebXRControllerPointerSelection;
  49838. /**
  49839. * Enables teleportation
  49840. */
  49841. teleportation: WebXRControllerTeleportation;
  49842. /**
  49843. * Enables ui for enetering/exiting xr
  49844. */
  49845. enterExitUI: WebXREnterExitUI;
  49846. /**
  49847. * Default output canvas xr should render to
  49848. */
  49849. outputCanvas: WebXRManagedOutputCanvas;
  49850. /**
  49851. * Creates the default xr experience
  49852. * @param scene scene
  49853. * @param options options for basic configuration
  49854. * @returns resulting WebXRDefaultExperience
  49855. */
  49856. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49857. private constructor();
  49858. /**
  49859. * DIsposes of the experience helper
  49860. */
  49861. dispose(): void;
  49862. }
  49863. }
  49864. declare module "babylonjs/Helpers/sceneHelpers" {
  49865. import { Nullable } from "babylonjs/types";
  49866. import { Mesh } from "babylonjs/Meshes/mesh";
  49867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49868. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49869. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49870. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49871. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49872. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49873. import "babylonjs/Meshes/Builders/boxBuilder";
  49874. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49875. /** @hidden */
  49876. export var _forceSceneHelpersToBundle: boolean;
  49877. module "babylonjs/scene" {
  49878. interface Scene {
  49879. /**
  49880. * Creates a default light for the scene.
  49881. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49882. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49883. */
  49884. createDefaultLight(replace?: boolean): void;
  49885. /**
  49886. * Creates a default camera for the scene.
  49887. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49888. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49889. * @param replace has default false, when true replaces the active camera in the scene
  49890. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49891. */
  49892. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49893. /**
  49894. * Creates a default camera and a default light.
  49895. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49896. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49897. * @param replace has the default false, when true replaces the active camera/light in the scene
  49898. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49899. */
  49900. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49901. /**
  49902. * Creates a new sky box
  49903. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49904. * @param environmentTexture defines the texture to use as environment texture
  49905. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49906. * @param scale defines the overall scale of the skybox
  49907. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49908. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49909. * @returns a new mesh holding the sky box
  49910. */
  49911. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49912. /**
  49913. * Creates a new environment
  49914. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49915. * @param options defines the options you can use to configure the environment
  49916. * @returns the new EnvironmentHelper
  49917. */
  49918. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49919. /**
  49920. * Creates a new VREXperienceHelper
  49921. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49922. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49923. * @returns a new VREXperienceHelper
  49924. */
  49925. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49926. /**
  49927. * Creates a new WebXRDefaultExperience
  49928. * @see http://doc.babylonjs.com/how_to/webxr
  49929. * @param options experience options
  49930. * @returns a promise for a new WebXRDefaultExperience
  49931. */
  49932. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49933. }
  49934. }
  49935. }
  49936. declare module "babylonjs/Helpers/videoDome" {
  49937. import { Scene } from "babylonjs/scene";
  49938. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49939. import { Mesh } from "babylonjs/Meshes/mesh";
  49940. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49941. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49942. import "babylonjs/Meshes/Builders/sphereBuilder";
  49943. /**
  49944. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49945. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49946. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49947. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49948. */
  49949. export class VideoDome extends TransformNode {
  49950. /**
  49951. * Define the video source as a Monoscopic panoramic 360 video.
  49952. */
  49953. static readonly MODE_MONOSCOPIC: number;
  49954. /**
  49955. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49956. */
  49957. static readonly MODE_TOPBOTTOM: number;
  49958. /**
  49959. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49960. */
  49961. static readonly MODE_SIDEBYSIDE: number;
  49962. private _useDirectMapping;
  49963. /**
  49964. * The video texture being displayed on the sphere
  49965. */
  49966. protected _videoTexture: VideoTexture;
  49967. /**
  49968. * Gets the video texture being displayed on the sphere
  49969. */
  49970. readonly videoTexture: VideoTexture;
  49971. /**
  49972. * The skybox material
  49973. */
  49974. protected _material: BackgroundMaterial;
  49975. /**
  49976. * The surface used for the skybox
  49977. */
  49978. protected _mesh: Mesh;
  49979. /**
  49980. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49981. * Also see the options.resolution property.
  49982. */
  49983. fovMultiplier: number;
  49984. private _videoMode;
  49985. /**
  49986. * Gets or set the current video mode for the video. It can be:
  49987. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49988. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49989. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49990. */
  49991. videoMode: number;
  49992. /**
  49993. * Oberserver used in Stereoscopic VR Mode.
  49994. */
  49995. private _onBeforeCameraRenderObserver;
  49996. /**
  49997. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49998. * @param name Element's name, child elements will append suffixes for their own names.
  49999. * @param urlsOrVideo defines the url(s) or the video element to use
  50000. * @param options An object containing optional or exposed sub element properties
  50001. */
  50002. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50003. resolution?: number;
  50004. clickToPlay?: boolean;
  50005. autoPlay?: boolean;
  50006. loop?: boolean;
  50007. size?: number;
  50008. poster?: string;
  50009. faceForward?: boolean;
  50010. useDirectMapping?: boolean;
  50011. }, scene: Scene);
  50012. private _changeVideoMode;
  50013. /**
  50014. * Releases resources associated with this node.
  50015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50017. */
  50018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50019. }
  50020. }
  50021. declare module "babylonjs/Helpers/index" {
  50022. export * from "babylonjs/Helpers/environmentHelper";
  50023. export * from "babylonjs/Helpers/photoDome";
  50024. export * from "babylonjs/Helpers/sceneHelpers";
  50025. export * from "babylonjs/Helpers/videoDome";
  50026. }
  50027. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50028. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50029. import { IDisposable } from "babylonjs/scene";
  50030. import { Engine } from "babylonjs/Engines/engine";
  50031. /**
  50032. * This class can be used to get instrumentation data from a Babylon engine
  50033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50034. */
  50035. export class EngineInstrumentation implements IDisposable {
  50036. /**
  50037. * Define the instrumented engine.
  50038. */
  50039. engine: Engine;
  50040. private _captureGPUFrameTime;
  50041. private _gpuFrameTimeToken;
  50042. private _gpuFrameTime;
  50043. private _captureShaderCompilationTime;
  50044. private _shaderCompilationTime;
  50045. private _onBeginFrameObserver;
  50046. private _onEndFrameObserver;
  50047. private _onBeforeShaderCompilationObserver;
  50048. private _onAfterShaderCompilationObserver;
  50049. /**
  50050. * Gets the perf counter used for GPU frame time
  50051. */
  50052. readonly gpuFrameTimeCounter: PerfCounter;
  50053. /**
  50054. * Gets the GPU frame time capture status
  50055. */
  50056. /**
  50057. * Enable or disable the GPU frame time capture
  50058. */
  50059. captureGPUFrameTime: boolean;
  50060. /**
  50061. * Gets the perf counter used for shader compilation time
  50062. */
  50063. readonly shaderCompilationTimeCounter: PerfCounter;
  50064. /**
  50065. * Gets the shader compilation time capture status
  50066. */
  50067. /**
  50068. * Enable or disable the shader compilation time capture
  50069. */
  50070. captureShaderCompilationTime: boolean;
  50071. /**
  50072. * Instantiates a new engine instrumentation.
  50073. * This class can be used to get instrumentation data from a Babylon engine
  50074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50075. * @param engine Defines the engine to instrument
  50076. */
  50077. constructor(
  50078. /**
  50079. * Define the instrumented engine.
  50080. */
  50081. engine: Engine);
  50082. /**
  50083. * Dispose and release associated resources.
  50084. */
  50085. dispose(): void;
  50086. }
  50087. }
  50088. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50089. import { Scene, IDisposable } from "babylonjs/scene";
  50090. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50091. /**
  50092. * This class can be used to get instrumentation data from a Babylon engine
  50093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50094. */
  50095. export class SceneInstrumentation implements IDisposable {
  50096. /**
  50097. * Defines the scene to instrument
  50098. */
  50099. scene: Scene;
  50100. private _captureActiveMeshesEvaluationTime;
  50101. private _activeMeshesEvaluationTime;
  50102. private _captureRenderTargetsRenderTime;
  50103. private _renderTargetsRenderTime;
  50104. private _captureFrameTime;
  50105. private _frameTime;
  50106. private _captureRenderTime;
  50107. private _renderTime;
  50108. private _captureInterFrameTime;
  50109. private _interFrameTime;
  50110. private _captureParticlesRenderTime;
  50111. private _particlesRenderTime;
  50112. private _captureSpritesRenderTime;
  50113. private _spritesRenderTime;
  50114. private _capturePhysicsTime;
  50115. private _physicsTime;
  50116. private _captureAnimationsTime;
  50117. private _animationsTime;
  50118. private _captureCameraRenderTime;
  50119. private _cameraRenderTime;
  50120. private _onBeforeActiveMeshesEvaluationObserver;
  50121. private _onAfterActiveMeshesEvaluationObserver;
  50122. private _onBeforeRenderTargetsRenderObserver;
  50123. private _onAfterRenderTargetsRenderObserver;
  50124. private _onAfterRenderObserver;
  50125. private _onBeforeDrawPhaseObserver;
  50126. private _onAfterDrawPhaseObserver;
  50127. private _onBeforeAnimationsObserver;
  50128. private _onBeforeParticlesRenderingObserver;
  50129. private _onAfterParticlesRenderingObserver;
  50130. private _onBeforeSpritesRenderingObserver;
  50131. private _onAfterSpritesRenderingObserver;
  50132. private _onBeforePhysicsObserver;
  50133. private _onAfterPhysicsObserver;
  50134. private _onAfterAnimationsObserver;
  50135. private _onBeforeCameraRenderObserver;
  50136. private _onAfterCameraRenderObserver;
  50137. /**
  50138. * Gets the perf counter used for active meshes evaluation time
  50139. */
  50140. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50141. /**
  50142. * Gets the active meshes evaluation time capture status
  50143. */
  50144. /**
  50145. * Enable or disable the active meshes evaluation time capture
  50146. */
  50147. captureActiveMeshesEvaluationTime: boolean;
  50148. /**
  50149. * Gets the perf counter used for render targets render time
  50150. */
  50151. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50152. /**
  50153. * Gets the render targets render time capture status
  50154. */
  50155. /**
  50156. * Enable or disable the render targets render time capture
  50157. */
  50158. captureRenderTargetsRenderTime: boolean;
  50159. /**
  50160. * Gets the perf counter used for particles render time
  50161. */
  50162. readonly particlesRenderTimeCounter: PerfCounter;
  50163. /**
  50164. * Gets the particles render time capture status
  50165. */
  50166. /**
  50167. * Enable or disable the particles render time capture
  50168. */
  50169. captureParticlesRenderTime: boolean;
  50170. /**
  50171. * Gets the perf counter used for sprites render time
  50172. */
  50173. readonly spritesRenderTimeCounter: PerfCounter;
  50174. /**
  50175. * Gets the sprites render time capture status
  50176. */
  50177. /**
  50178. * Enable or disable the sprites render time capture
  50179. */
  50180. captureSpritesRenderTime: boolean;
  50181. /**
  50182. * Gets the perf counter used for physics time
  50183. */
  50184. readonly physicsTimeCounter: PerfCounter;
  50185. /**
  50186. * Gets the physics time capture status
  50187. */
  50188. /**
  50189. * Enable or disable the physics time capture
  50190. */
  50191. capturePhysicsTime: boolean;
  50192. /**
  50193. * Gets the perf counter used for animations time
  50194. */
  50195. readonly animationsTimeCounter: PerfCounter;
  50196. /**
  50197. * Gets the animations time capture status
  50198. */
  50199. /**
  50200. * Enable or disable the animations time capture
  50201. */
  50202. captureAnimationsTime: boolean;
  50203. /**
  50204. * Gets the perf counter used for frame time capture
  50205. */
  50206. readonly frameTimeCounter: PerfCounter;
  50207. /**
  50208. * Gets the frame time capture status
  50209. */
  50210. /**
  50211. * Enable or disable the frame time capture
  50212. */
  50213. captureFrameTime: boolean;
  50214. /**
  50215. * Gets the perf counter used for inter-frames time capture
  50216. */
  50217. readonly interFrameTimeCounter: PerfCounter;
  50218. /**
  50219. * Gets the inter-frames time capture status
  50220. */
  50221. /**
  50222. * Enable or disable the inter-frames time capture
  50223. */
  50224. captureInterFrameTime: boolean;
  50225. /**
  50226. * Gets the perf counter used for render time capture
  50227. */
  50228. readonly renderTimeCounter: PerfCounter;
  50229. /**
  50230. * Gets the render time capture status
  50231. */
  50232. /**
  50233. * Enable or disable the render time capture
  50234. */
  50235. captureRenderTime: boolean;
  50236. /**
  50237. * Gets the perf counter used for camera render time capture
  50238. */
  50239. readonly cameraRenderTimeCounter: PerfCounter;
  50240. /**
  50241. * Gets the camera render time capture status
  50242. */
  50243. /**
  50244. * Enable or disable the camera render time capture
  50245. */
  50246. captureCameraRenderTime: boolean;
  50247. /**
  50248. * Gets the perf counter used for draw calls
  50249. */
  50250. readonly drawCallsCounter: PerfCounter;
  50251. /**
  50252. * Instantiates a new scene instrumentation.
  50253. * This class can be used to get instrumentation data from a Babylon engine
  50254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50255. * @param scene Defines the scene to instrument
  50256. */
  50257. constructor(
  50258. /**
  50259. * Defines the scene to instrument
  50260. */
  50261. scene: Scene);
  50262. /**
  50263. * Dispose and release associated resources.
  50264. */
  50265. dispose(): void;
  50266. }
  50267. }
  50268. declare module "babylonjs/Instrumentation/index" {
  50269. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50270. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50271. export * from "babylonjs/Instrumentation/timeToken";
  50272. }
  50273. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50274. /** @hidden */
  50275. export var glowMapGenerationPixelShader: {
  50276. name: string;
  50277. shader: string;
  50278. };
  50279. }
  50280. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50281. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50282. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50283. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50284. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50286. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50287. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50288. /** @hidden */
  50289. export var glowMapGenerationVertexShader: {
  50290. name: string;
  50291. shader: string;
  50292. };
  50293. }
  50294. declare module "babylonjs/Layers/effectLayer" {
  50295. import { Observable } from "babylonjs/Misc/observable";
  50296. import { Nullable } from "babylonjs/types";
  50297. import { Camera } from "babylonjs/Cameras/camera";
  50298. import { Scene } from "babylonjs/scene";
  50299. import { ISize } from "babylonjs/Maths/math.size";
  50300. import { Color4 } from "babylonjs/Maths/math.color";
  50301. import { Engine } from "babylonjs/Engines/engine";
  50302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50304. import { Mesh } from "babylonjs/Meshes/mesh";
  50305. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50308. import { Effect } from "babylonjs/Materials/effect";
  50309. import { Material } from "babylonjs/Materials/material";
  50310. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50311. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50312. /**
  50313. * Effect layer options. This helps customizing the behaviour
  50314. * of the effect layer.
  50315. */
  50316. export interface IEffectLayerOptions {
  50317. /**
  50318. * Multiplication factor apply to the canvas size to compute the render target size
  50319. * used to generated the objects (the smaller the faster).
  50320. */
  50321. mainTextureRatio: number;
  50322. /**
  50323. * Enforces a fixed size texture to ensure effect stability across devices.
  50324. */
  50325. mainTextureFixedSize?: number;
  50326. /**
  50327. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50328. */
  50329. alphaBlendingMode: number;
  50330. /**
  50331. * The camera attached to the layer.
  50332. */
  50333. camera: Nullable<Camera>;
  50334. /**
  50335. * The rendering group to draw the layer in.
  50336. */
  50337. renderingGroupId: number;
  50338. }
  50339. /**
  50340. * The effect layer Helps adding post process effect blended with the main pass.
  50341. *
  50342. * This can be for instance use to generate glow or higlight effects on the scene.
  50343. *
  50344. * The effect layer class can not be used directly and is intented to inherited from to be
  50345. * customized per effects.
  50346. */
  50347. export abstract class EffectLayer {
  50348. private _vertexBuffers;
  50349. private _indexBuffer;
  50350. private _cachedDefines;
  50351. private _effectLayerMapGenerationEffect;
  50352. private _effectLayerOptions;
  50353. private _mergeEffect;
  50354. protected _scene: Scene;
  50355. protected _engine: Engine;
  50356. protected _maxSize: number;
  50357. protected _mainTextureDesiredSize: ISize;
  50358. protected _mainTexture: RenderTargetTexture;
  50359. protected _shouldRender: boolean;
  50360. protected _postProcesses: PostProcess[];
  50361. protected _textures: BaseTexture[];
  50362. protected _emissiveTextureAndColor: {
  50363. texture: Nullable<BaseTexture>;
  50364. color: Color4;
  50365. };
  50366. /**
  50367. * The name of the layer
  50368. */
  50369. name: string;
  50370. /**
  50371. * The clear color of the texture used to generate the glow map.
  50372. */
  50373. neutralColor: Color4;
  50374. /**
  50375. * Specifies wether the highlight layer is enabled or not.
  50376. */
  50377. isEnabled: boolean;
  50378. /**
  50379. * Gets the camera attached to the layer.
  50380. */
  50381. readonly camera: Nullable<Camera>;
  50382. /**
  50383. * Gets the rendering group id the layer should render in.
  50384. */
  50385. renderingGroupId: number;
  50386. /**
  50387. * An event triggered when the effect layer has been disposed.
  50388. */
  50389. onDisposeObservable: Observable<EffectLayer>;
  50390. /**
  50391. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50392. */
  50393. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50394. /**
  50395. * An event triggered when the generated texture is being merged in the scene.
  50396. */
  50397. onBeforeComposeObservable: Observable<EffectLayer>;
  50398. /**
  50399. * An event triggered when the generated texture has been merged in the scene.
  50400. */
  50401. onAfterComposeObservable: Observable<EffectLayer>;
  50402. /**
  50403. * An event triggered when the efffect layer changes its size.
  50404. */
  50405. onSizeChangedObservable: Observable<EffectLayer>;
  50406. /** @hidden */
  50407. static _SceneComponentInitialization: (scene: Scene) => void;
  50408. /**
  50409. * Instantiates a new effect Layer and references it in the scene.
  50410. * @param name The name of the layer
  50411. * @param scene The scene to use the layer in
  50412. */
  50413. constructor(
  50414. /** The Friendly of the effect in the scene */
  50415. name: string, scene: Scene);
  50416. /**
  50417. * Get the effect name of the layer.
  50418. * @return The effect name
  50419. */
  50420. abstract getEffectName(): string;
  50421. /**
  50422. * Checks for the readiness of the element composing the layer.
  50423. * @param subMesh the mesh to check for
  50424. * @param useInstances specify wether or not to use instances to render the mesh
  50425. * @return true if ready otherwise, false
  50426. */
  50427. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50428. /**
  50429. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50430. * @returns true if the effect requires stencil during the main canvas render pass.
  50431. */
  50432. abstract needStencil(): boolean;
  50433. /**
  50434. * Create the merge effect. This is the shader use to blit the information back
  50435. * to the main canvas at the end of the scene rendering.
  50436. * @returns The effect containing the shader used to merge the effect on the main canvas
  50437. */
  50438. protected abstract _createMergeEffect(): Effect;
  50439. /**
  50440. * Creates the render target textures and post processes used in the effect layer.
  50441. */
  50442. protected abstract _createTextureAndPostProcesses(): void;
  50443. /**
  50444. * Implementation specific of rendering the generating effect on the main canvas.
  50445. * @param effect The effect used to render through
  50446. */
  50447. protected abstract _internalRender(effect: Effect): void;
  50448. /**
  50449. * Sets the required values for both the emissive texture and and the main color.
  50450. */
  50451. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50452. /**
  50453. * Free any resources and references associated to a mesh.
  50454. * Internal use
  50455. * @param mesh The mesh to free.
  50456. */
  50457. abstract _disposeMesh(mesh: Mesh): void;
  50458. /**
  50459. * Serializes this layer (Glow or Highlight for example)
  50460. * @returns a serialized layer object
  50461. */
  50462. abstract serialize?(): any;
  50463. /**
  50464. * Initializes the effect layer with the required options.
  50465. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50466. */
  50467. protected _init(options: Partial<IEffectLayerOptions>): void;
  50468. /**
  50469. * Generates the index buffer of the full screen quad blending to the main canvas.
  50470. */
  50471. private _generateIndexBuffer;
  50472. /**
  50473. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50474. */
  50475. private _generateVertexBuffer;
  50476. /**
  50477. * Sets the main texture desired size which is the closest power of two
  50478. * of the engine canvas size.
  50479. */
  50480. private _setMainTextureSize;
  50481. /**
  50482. * Creates the main texture for the effect layer.
  50483. */
  50484. protected _createMainTexture(): void;
  50485. /**
  50486. * Adds specific effects defines.
  50487. * @param defines The defines to add specifics to.
  50488. */
  50489. protected _addCustomEffectDefines(defines: string[]): void;
  50490. /**
  50491. * Checks for the readiness of the element composing the layer.
  50492. * @param subMesh the mesh to check for
  50493. * @param useInstances specify wether or not to use instances to render the mesh
  50494. * @param emissiveTexture the associated emissive texture used to generate the glow
  50495. * @return true if ready otherwise, false
  50496. */
  50497. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50498. /**
  50499. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50500. */
  50501. render(): void;
  50502. /**
  50503. * Determine if a given mesh will be used in the current effect.
  50504. * @param mesh mesh to test
  50505. * @returns true if the mesh will be used
  50506. */
  50507. hasMesh(mesh: AbstractMesh): boolean;
  50508. /**
  50509. * Returns true if the layer contains information to display, otherwise false.
  50510. * @returns true if the glow layer should be rendered
  50511. */
  50512. shouldRender(): boolean;
  50513. /**
  50514. * Returns true if the mesh should render, otherwise false.
  50515. * @param mesh The mesh to render
  50516. * @returns true if it should render otherwise false
  50517. */
  50518. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50519. /**
  50520. * Returns true if the mesh can be rendered, otherwise false.
  50521. * @param mesh The mesh to render
  50522. * @param material The material used on the mesh
  50523. * @returns true if it can be rendered otherwise false
  50524. */
  50525. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50526. /**
  50527. * Returns true if the mesh should render, otherwise false.
  50528. * @param mesh The mesh to render
  50529. * @returns true if it should render otherwise false
  50530. */
  50531. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50532. /**
  50533. * Renders the submesh passed in parameter to the generation map.
  50534. */
  50535. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50536. /**
  50537. * Rebuild the required buffers.
  50538. * @hidden Internal use only.
  50539. */
  50540. _rebuild(): void;
  50541. /**
  50542. * Dispose only the render target textures and post process.
  50543. */
  50544. private _disposeTextureAndPostProcesses;
  50545. /**
  50546. * Dispose the highlight layer and free resources.
  50547. */
  50548. dispose(): void;
  50549. /**
  50550. * Gets the class name of the effect layer
  50551. * @returns the string with the class name of the effect layer
  50552. */
  50553. getClassName(): string;
  50554. /**
  50555. * Creates an effect layer from parsed effect layer data
  50556. * @param parsedEffectLayer defines effect layer data
  50557. * @param scene defines the current scene
  50558. * @param rootUrl defines the root URL containing the effect layer information
  50559. * @returns a parsed effect Layer
  50560. */
  50561. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50562. }
  50563. }
  50564. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50565. import { Scene } from "babylonjs/scene";
  50566. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50567. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50568. import { AbstractScene } from "babylonjs/abstractScene";
  50569. module "babylonjs/abstractScene" {
  50570. interface AbstractScene {
  50571. /**
  50572. * The list of effect layers (highlights/glow) added to the scene
  50573. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50574. * @see http://doc.babylonjs.com/how_to/glow_layer
  50575. */
  50576. effectLayers: Array<EffectLayer>;
  50577. /**
  50578. * Removes the given effect layer from this scene.
  50579. * @param toRemove defines the effect layer to remove
  50580. * @returns the index of the removed effect layer
  50581. */
  50582. removeEffectLayer(toRemove: EffectLayer): number;
  50583. /**
  50584. * Adds the given effect layer to this scene
  50585. * @param newEffectLayer defines the effect layer to add
  50586. */
  50587. addEffectLayer(newEffectLayer: EffectLayer): void;
  50588. }
  50589. }
  50590. /**
  50591. * Defines the layer scene component responsible to manage any effect layers
  50592. * in a given scene.
  50593. */
  50594. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50595. /**
  50596. * The component name helpfull to identify the component in the list of scene components.
  50597. */
  50598. readonly name: string;
  50599. /**
  50600. * The scene the component belongs to.
  50601. */
  50602. scene: Scene;
  50603. private _engine;
  50604. private _renderEffects;
  50605. private _needStencil;
  50606. private _previousStencilState;
  50607. /**
  50608. * Creates a new instance of the component for the given scene
  50609. * @param scene Defines the scene to register the component in
  50610. */
  50611. constructor(scene: Scene);
  50612. /**
  50613. * Registers the component in a given scene
  50614. */
  50615. register(): void;
  50616. /**
  50617. * Rebuilds the elements related to this component in case of
  50618. * context lost for instance.
  50619. */
  50620. rebuild(): void;
  50621. /**
  50622. * Serializes the component data to the specified json object
  50623. * @param serializationObject The object to serialize to
  50624. */
  50625. serialize(serializationObject: any): void;
  50626. /**
  50627. * Adds all the elements from the container to the scene
  50628. * @param container the container holding the elements
  50629. */
  50630. addFromContainer(container: AbstractScene): void;
  50631. /**
  50632. * Removes all the elements in the container from the scene
  50633. * @param container contains the elements to remove
  50634. * @param dispose if the removed element should be disposed (default: false)
  50635. */
  50636. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50637. /**
  50638. * Disposes the component and the associated ressources.
  50639. */
  50640. dispose(): void;
  50641. private _isReadyForMesh;
  50642. private _renderMainTexture;
  50643. private _setStencil;
  50644. private _setStencilBack;
  50645. private _draw;
  50646. private _drawCamera;
  50647. private _drawRenderingGroup;
  50648. }
  50649. }
  50650. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50651. /** @hidden */
  50652. export var glowMapMergePixelShader: {
  50653. name: string;
  50654. shader: string;
  50655. };
  50656. }
  50657. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50658. /** @hidden */
  50659. export var glowMapMergeVertexShader: {
  50660. name: string;
  50661. shader: string;
  50662. };
  50663. }
  50664. declare module "babylonjs/Layers/glowLayer" {
  50665. import { Nullable } from "babylonjs/types";
  50666. import { Camera } from "babylonjs/Cameras/camera";
  50667. import { Scene } from "babylonjs/scene";
  50668. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50670. import { Mesh } from "babylonjs/Meshes/mesh";
  50671. import { Texture } from "babylonjs/Materials/Textures/texture";
  50672. import { Effect } from "babylonjs/Materials/effect";
  50673. import { Material } from "babylonjs/Materials/material";
  50674. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50675. import { Color4 } from "babylonjs/Maths/math.color";
  50676. import "babylonjs/Shaders/glowMapMerge.fragment";
  50677. import "babylonjs/Shaders/glowMapMerge.vertex";
  50678. import "babylonjs/Layers/effectLayerSceneComponent";
  50679. module "babylonjs/abstractScene" {
  50680. interface AbstractScene {
  50681. /**
  50682. * Return a the first highlight layer of the scene with a given name.
  50683. * @param name The name of the highlight layer to look for.
  50684. * @return The highlight layer if found otherwise null.
  50685. */
  50686. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50687. }
  50688. }
  50689. /**
  50690. * Glow layer options. This helps customizing the behaviour
  50691. * of the glow layer.
  50692. */
  50693. export interface IGlowLayerOptions {
  50694. /**
  50695. * Multiplication factor apply to the canvas size to compute the render target size
  50696. * used to generated the glowing objects (the smaller the faster).
  50697. */
  50698. mainTextureRatio: number;
  50699. /**
  50700. * Enforces a fixed size texture to ensure resize independant blur.
  50701. */
  50702. mainTextureFixedSize?: number;
  50703. /**
  50704. * How big is the kernel of the blur texture.
  50705. */
  50706. blurKernelSize: number;
  50707. /**
  50708. * The camera attached to the layer.
  50709. */
  50710. camera: Nullable<Camera>;
  50711. /**
  50712. * Enable MSAA by chosing the number of samples.
  50713. */
  50714. mainTextureSamples?: number;
  50715. /**
  50716. * The rendering group to draw the layer in.
  50717. */
  50718. renderingGroupId: number;
  50719. }
  50720. /**
  50721. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50722. *
  50723. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50724. * glowy meshes to your scene.
  50725. *
  50726. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50727. */
  50728. export class GlowLayer extends EffectLayer {
  50729. /**
  50730. * Effect Name of the layer.
  50731. */
  50732. static readonly EffectName: string;
  50733. /**
  50734. * The default blur kernel size used for the glow.
  50735. */
  50736. static DefaultBlurKernelSize: number;
  50737. /**
  50738. * The default texture size ratio used for the glow.
  50739. */
  50740. static DefaultTextureRatio: number;
  50741. /**
  50742. * Sets the kernel size of the blur.
  50743. */
  50744. /**
  50745. * Gets the kernel size of the blur.
  50746. */
  50747. blurKernelSize: number;
  50748. /**
  50749. * Sets the glow intensity.
  50750. */
  50751. /**
  50752. * Gets the glow intensity.
  50753. */
  50754. intensity: number;
  50755. private _options;
  50756. private _intensity;
  50757. private _horizontalBlurPostprocess1;
  50758. private _verticalBlurPostprocess1;
  50759. private _horizontalBlurPostprocess2;
  50760. private _verticalBlurPostprocess2;
  50761. private _blurTexture1;
  50762. private _blurTexture2;
  50763. private _postProcesses1;
  50764. private _postProcesses2;
  50765. private _includedOnlyMeshes;
  50766. private _excludedMeshes;
  50767. /**
  50768. * Callback used to let the user override the color selection on a per mesh basis
  50769. */
  50770. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50771. /**
  50772. * Callback used to let the user override the texture selection on a per mesh basis
  50773. */
  50774. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50775. /**
  50776. * Instantiates a new glow Layer and references it to the scene.
  50777. * @param name The name of the layer
  50778. * @param scene The scene to use the layer in
  50779. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50780. */
  50781. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50782. /**
  50783. * Get the effect name of the layer.
  50784. * @return The effect name
  50785. */
  50786. getEffectName(): string;
  50787. /**
  50788. * Create the merge effect. This is the shader use to blit the information back
  50789. * to the main canvas at the end of the scene rendering.
  50790. */
  50791. protected _createMergeEffect(): Effect;
  50792. /**
  50793. * Creates the render target textures and post processes used in the glow layer.
  50794. */
  50795. protected _createTextureAndPostProcesses(): void;
  50796. /**
  50797. * Checks for the readiness of the element composing the layer.
  50798. * @param subMesh the mesh to check for
  50799. * @param useInstances specify wether or not to use instances to render the mesh
  50800. * @param emissiveTexture the associated emissive texture used to generate the glow
  50801. * @return true if ready otherwise, false
  50802. */
  50803. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50804. /**
  50805. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50806. */
  50807. needStencil(): boolean;
  50808. /**
  50809. * Returns true if the mesh can be rendered, otherwise false.
  50810. * @param mesh The mesh to render
  50811. * @param material The material used on the mesh
  50812. * @returns true if it can be rendered otherwise false
  50813. */
  50814. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50815. /**
  50816. * Implementation specific of rendering the generating effect on the main canvas.
  50817. * @param effect The effect used to render through
  50818. */
  50819. protected _internalRender(effect: Effect): void;
  50820. /**
  50821. * Sets the required values for both the emissive texture and and the main color.
  50822. */
  50823. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50824. /**
  50825. * Returns true if the mesh should render, otherwise false.
  50826. * @param mesh The mesh to render
  50827. * @returns true if it should render otherwise false
  50828. */
  50829. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50830. /**
  50831. * Adds specific effects defines.
  50832. * @param defines The defines to add specifics to.
  50833. */
  50834. protected _addCustomEffectDefines(defines: string[]): void;
  50835. /**
  50836. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50837. * @param mesh The mesh to exclude from the glow layer
  50838. */
  50839. addExcludedMesh(mesh: Mesh): void;
  50840. /**
  50841. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50842. * @param mesh The mesh to remove
  50843. */
  50844. removeExcludedMesh(mesh: Mesh): void;
  50845. /**
  50846. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50847. * @param mesh The mesh to include in the glow layer
  50848. */
  50849. addIncludedOnlyMesh(mesh: Mesh): void;
  50850. /**
  50851. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50852. * @param mesh The mesh to remove
  50853. */
  50854. removeIncludedOnlyMesh(mesh: Mesh): void;
  50855. /**
  50856. * Determine if a given mesh will be used in the glow layer
  50857. * @param mesh The mesh to test
  50858. * @returns true if the mesh will be highlighted by the current glow layer
  50859. */
  50860. hasMesh(mesh: AbstractMesh): boolean;
  50861. /**
  50862. * Free any resources and references associated to a mesh.
  50863. * Internal use
  50864. * @param mesh The mesh to free.
  50865. * @hidden
  50866. */
  50867. _disposeMesh(mesh: Mesh): void;
  50868. /**
  50869. * Gets the class name of the effect layer
  50870. * @returns the string with the class name of the effect layer
  50871. */
  50872. getClassName(): string;
  50873. /**
  50874. * Serializes this glow layer
  50875. * @returns a serialized glow layer object
  50876. */
  50877. serialize(): any;
  50878. /**
  50879. * Creates a Glow Layer from parsed glow layer data
  50880. * @param parsedGlowLayer defines glow layer data
  50881. * @param scene defines the current scene
  50882. * @param rootUrl defines the root URL containing the glow layer information
  50883. * @returns a parsed Glow Layer
  50884. */
  50885. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50886. }
  50887. }
  50888. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50889. /** @hidden */
  50890. export var glowBlurPostProcessPixelShader: {
  50891. name: string;
  50892. shader: string;
  50893. };
  50894. }
  50895. declare module "babylonjs/Layers/highlightLayer" {
  50896. import { Observable } from "babylonjs/Misc/observable";
  50897. import { Nullable } from "babylonjs/types";
  50898. import { Camera } from "babylonjs/Cameras/camera";
  50899. import { Scene } from "babylonjs/scene";
  50900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50902. import { Mesh } from "babylonjs/Meshes/mesh";
  50903. import { Effect } from "babylonjs/Materials/effect";
  50904. import { Material } from "babylonjs/Materials/material";
  50905. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50906. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50907. import "babylonjs/Shaders/glowMapMerge.fragment";
  50908. import "babylonjs/Shaders/glowMapMerge.vertex";
  50909. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50910. module "babylonjs/abstractScene" {
  50911. interface AbstractScene {
  50912. /**
  50913. * Return a the first highlight layer of the scene with a given name.
  50914. * @param name The name of the highlight layer to look for.
  50915. * @return The highlight layer if found otherwise null.
  50916. */
  50917. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50918. }
  50919. }
  50920. /**
  50921. * Highlight layer options. This helps customizing the behaviour
  50922. * of the highlight layer.
  50923. */
  50924. export interface IHighlightLayerOptions {
  50925. /**
  50926. * Multiplication factor apply to the canvas size to compute the render target size
  50927. * used to generated the glowing objects (the smaller the faster).
  50928. */
  50929. mainTextureRatio: number;
  50930. /**
  50931. * Enforces a fixed size texture to ensure resize independant blur.
  50932. */
  50933. mainTextureFixedSize?: number;
  50934. /**
  50935. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50936. * of the picture to blur (the smaller the faster).
  50937. */
  50938. blurTextureSizeRatio: number;
  50939. /**
  50940. * How big in texel of the blur texture is the vertical blur.
  50941. */
  50942. blurVerticalSize: number;
  50943. /**
  50944. * How big in texel of the blur texture is the horizontal blur.
  50945. */
  50946. blurHorizontalSize: number;
  50947. /**
  50948. * Alpha blending mode used to apply the blur. Default is combine.
  50949. */
  50950. alphaBlendingMode: number;
  50951. /**
  50952. * The camera attached to the layer.
  50953. */
  50954. camera: Nullable<Camera>;
  50955. /**
  50956. * Should we display highlight as a solid stroke?
  50957. */
  50958. isStroke?: boolean;
  50959. /**
  50960. * The rendering group to draw the layer in.
  50961. */
  50962. renderingGroupId: number;
  50963. }
  50964. /**
  50965. * The highlight layer Helps adding a glow effect around a mesh.
  50966. *
  50967. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50968. * glowy meshes to your scene.
  50969. *
  50970. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50971. */
  50972. export class HighlightLayer extends EffectLayer {
  50973. name: string;
  50974. /**
  50975. * Effect Name of the highlight layer.
  50976. */
  50977. static readonly EffectName: string;
  50978. /**
  50979. * The neutral color used during the preparation of the glow effect.
  50980. * This is black by default as the blend operation is a blend operation.
  50981. */
  50982. static NeutralColor: Color4;
  50983. /**
  50984. * Stencil value used for glowing meshes.
  50985. */
  50986. static GlowingMeshStencilReference: number;
  50987. /**
  50988. * Stencil value used for the other meshes in the scene.
  50989. */
  50990. static NormalMeshStencilReference: number;
  50991. /**
  50992. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50993. */
  50994. innerGlow: boolean;
  50995. /**
  50996. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50997. */
  50998. outerGlow: boolean;
  50999. /**
  51000. * Specifies the horizontal size of the blur.
  51001. */
  51002. /**
  51003. * Gets the horizontal size of the blur.
  51004. */
  51005. blurHorizontalSize: number;
  51006. /**
  51007. * Specifies the vertical size of the blur.
  51008. */
  51009. /**
  51010. * Gets the vertical size of the blur.
  51011. */
  51012. blurVerticalSize: number;
  51013. /**
  51014. * An event triggered when the highlight layer is being blurred.
  51015. */
  51016. onBeforeBlurObservable: Observable<HighlightLayer>;
  51017. /**
  51018. * An event triggered when the highlight layer has been blurred.
  51019. */
  51020. onAfterBlurObservable: Observable<HighlightLayer>;
  51021. private _instanceGlowingMeshStencilReference;
  51022. private _options;
  51023. private _downSamplePostprocess;
  51024. private _horizontalBlurPostprocess;
  51025. private _verticalBlurPostprocess;
  51026. private _blurTexture;
  51027. private _meshes;
  51028. private _excludedMeshes;
  51029. /**
  51030. * Instantiates a new highlight Layer and references it to the scene..
  51031. * @param name The name of the layer
  51032. * @param scene The scene to use the layer in
  51033. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51034. */
  51035. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51036. /**
  51037. * Get the effect name of the layer.
  51038. * @return The effect name
  51039. */
  51040. getEffectName(): string;
  51041. /**
  51042. * Create the merge effect. This is the shader use to blit the information back
  51043. * to the main canvas at the end of the scene rendering.
  51044. */
  51045. protected _createMergeEffect(): Effect;
  51046. /**
  51047. * Creates the render target textures and post processes used in the highlight layer.
  51048. */
  51049. protected _createTextureAndPostProcesses(): void;
  51050. /**
  51051. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51052. */
  51053. needStencil(): boolean;
  51054. /**
  51055. * Checks for the readiness of the element composing the layer.
  51056. * @param subMesh the mesh to check for
  51057. * @param useInstances specify wether or not to use instances to render the mesh
  51058. * @param emissiveTexture the associated emissive texture used to generate the glow
  51059. * @return true if ready otherwise, false
  51060. */
  51061. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51062. /**
  51063. * Implementation specific of rendering the generating effect on the main canvas.
  51064. * @param effect The effect used to render through
  51065. */
  51066. protected _internalRender(effect: Effect): void;
  51067. /**
  51068. * Returns true if the layer contains information to display, otherwise false.
  51069. */
  51070. shouldRender(): boolean;
  51071. /**
  51072. * Returns true if the mesh should render, otherwise false.
  51073. * @param mesh The mesh to render
  51074. * @returns true if it should render otherwise false
  51075. */
  51076. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51077. /**
  51078. * Sets the required values for both the emissive texture and and the main color.
  51079. */
  51080. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51081. /**
  51082. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51083. * @param mesh The mesh to exclude from the highlight layer
  51084. */
  51085. addExcludedMesh(mesh: Mesh): void;
  51086. /**
  51087. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51088. * @param mesh The mesh to highlight
  51089. */
  51090. removeExcludedMesh(mesh: Mesh): void;
  51091. /**
  51092. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51093. * @param mesh mesh to test
  51094. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51095. */
  51096. hasMesh(mesh: AbstractMesh): boolean;
  51097. /**
  51098. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51099. * @param mesh The mesh to highlight
  51100. * @param color The color of the highlight
  51101. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51102. */
  51103. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51104. /**
  51105. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51106. * @param mesh The mesh to highlight
  51107. */
  51108. removeMesh(mesh: Mesh): void;
  51109. /**
  51110. * Force the stencil to the normal expected value for none glowing parts
  51111. */
  51112. private _defaultStencilReference;
  51113. /**
  51114. * Free any resources and references associated to a mesh.
  51115. * Internal use
  51116. * @param mesh The mesh to free.
  51117. * @hidden
  51118. */
  51119. _disposeMesh(mesh: Mesh): void;
  51120. /**
  51121. * Dispose the highlight layer and free resources.
  51122. */
  51123. dispose(): void;
  51124. /**
  51125. * Gets the class name of the effect layer
  51126. * @returns the string with the class name of the effect layer
  51127. */
  51128. getClassName(): string;
  51129. /**
  51130. * Serializes this Highlight layer
  51131. * @returns a serialized Highlight layer object
  51132. */
  51133. serialize(): any;
  51134. /**
  51135. * Creates a Highlight layer from parsed Highlight layer data
  51136. * @param parsedHightlightLayer defines the Highlight layer data
  51137. * @param scene defines the current scene
  51138. * @param rootUrl defines the root URL containing the Highlight layer information
  51139. * @returns a parsed Highlight layer
  51140. */
  51141. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51142. }
  51143. }
  51144. declare module "babylonjs/Layers/layerSceneComponent" {
  51145. import { Scene } from "babylonjs/scene";
  51146. import { ISceneComponent } from "babylonjs/sceneComponent";
  51147. import { Layer } from "babylonjs/Layers/layer";
  51148. import { AbstractScene } from "babylonjs/abstractScene";
  51149. module "babylonjs/abstractScene" {
  51150. interface AbstractScene {
  51151. /**
  51152. * The list of layers (background and foreground) of the scene
  51153. */
  51154. layers: Array<Layer>;
  51155. }
  51156. }
  51157. /**
  51158. * Defines the layer scene component responsible to manage any layers
  51159. * in a given scene.
  51160. */
  51161. export class LayerSceneComponent implements ISceneComponent {
  51162. /**
  51163. * The component name helpfull to identify the component in the list of scene components.
  51164. */
  51165. readonly name: string;
  51166. /**
  51167. * The scene the component belongs to.
  51168. */
  51169. scene: Scene;
  51170. private _engine;
  51171. /**
  51172. * Creates a new instance of the component for the given scene
  51173. * @param scene Defines the scene to register the component in
  51174. */
  51175. constructor(scene: Scene);
  51176. /**
  51177. * Registers the component in a given scene
  51178. */
  51179. register(): void;
  51180. /**
  51181. * Rebuilds the elements related to this component in case of
  51182. * context lost for instance.
  51183. */
  51184. rebuild(): void;
  51185. /**
  51186. * Disposes the component and the associated ressources.
  51187. */
  51188. dispose(): void;
  51189. private _draw;
  51190. private _drawCameraPredicate;
  51191. private _drawCameraBackground;
  51192. private _drawCameraForeground;
  51193. private _drawRenderTargetPredicate;
  51194. private _drawRenderTargetBackground;
  51195. private _drawRenderTargetForeground;
  51196. /**
  51197. * Adds all the elements from the container to the scene
  51198. * @param container the container holding the elements
  51199. */
  51200. addFromContainer(container: AbstractScene): void;
  51201. /**
  51202. * Removes all the elements in the container from the scene
  51203. * @param container contains the elements to remove
  51204. * @param dispose if the removed element should be disposed (default: false)
  51205. */
  51206. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51207. }
  51208. }
  51209. declare module "babylonjs/Shaders/layer.fragment" {
  51210. /** @hidden */
  51211. export var layerPixelShader: {
  51212. name: string;
  51213. shader: string;
  51214. };
  51215. }
  51216. declare module "babylonjs/Shaders/layer.vertex" {
  51217. /** @hidden */
  51218. export var layerVertexShader: {
  51219. name: string;
  51220. shader: string;
  51221. };
  51222. }
  51223. declare module "babylonjs/Layers/layer" {
  51224. import { Observable } from "babylonjs/Misc/observable";
  51225. import { Nullable } from "babylonjs/types";
  51226. import { Scene } from "babylonjs/scene";
  51227. import { Vector2 } from "babylonjs/Maths/math.vector";
  51228. import { Color4 } from "babylonjs/Maths/math.color";
  51229. import { Texture } from "babylonjs/Materials/Textures/texture";
  51230. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51231. import "babylonjs/Shaders/layer.fragment";
  51232. import "babylonjs/Shaders/layer.vertex";
  51233. /**
  51234. * This represents a full screen 2d layer.
  51235. * This can be useful to display a picture in the background of your scene for instance.
  51236. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51237. */
  51238. export class Layer {
  51239. /**
  51240. * Define the name of the layer.
  51241. */
  51242. name: string;
  51243. /**
  51244. * Define the texture the layer should display.
  51245. */
  51246. texture: Nullable<Texture>;
  51247. /**
  51248. * Is the layer in background or foreground.
  51249. */
  51250. isBackground: boolean;
  51251. /**
  51252. * Define the color of the layer (instead of texture).
  51253. */
  51254. color: Color4;
  51255. /**
  51256. * Define the scale of the layer in order to zoom in out of the texture.
  51257. */
  51258. scale: Vector2;
  51259. /**
  51260. * Define an offset for the layer in order to shift the texture.
  51261. */
  51262. offset: Vector2;
  51263. /**
  51264. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51265. */
  51266. alphaBlendingMode: number;
  51267. /**
  51268. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51269. * Alpha test will not mix with the background color in case of transparency.
  51270. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51271. */
  51272. alphaTest: boolean;
  51273. /**
  51274. * Define a mask to restrict the layer to only some of the scene cameras.
  51275. */
  51276. layerMask: number;
  51277. /**
  51278. * Define the list of render target the layer is visible into.
  51279. */
  51280. renderTargetTextures: RenderTargetTexture[];
  51281. /**
  51282. * Define if the layer is only used in renderTarget or if it also
  51283. * renders in the main frame buffer of the canvas.
  51284. */
  51285. renderOnlyInRenderTargetTextures: boolean;
  51286. private _scene;
  51287. private _vertexBuffers;
  51288. private _indexBuffer;
  51289. private _effect;
  51290. private _alphaTestEffect;
  51291. /**
  51292. * An event triggered when the layer is disposed.
  51293. */
  51294. onDisposeObservable: Observable<Layer>;
  51295. private _onDisposeObserver;
  51296. /**
  51297. * Back compatibility with callback before the onDisposeObservable existed.
  51298. * The set callback will be triggered when the layer has been disposed.
  51299. */
  51300. onDispose: () => void;
  51301. /**
  51302. * An event triggered before rendering the scene
  51303. */
  51304. onBeforeRenderObservable: Observable<Layer>;
  51305. private _onBeforeRenderObserver;
  51306. /**
  51307. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51308. * The set callback will be triggered just before rendering the layer.
  51309. */
  51310. onBeforeRender: () => void;
  51311. /**
  51312. * An event triggered after rendering the scene
  51313. */
  51314. onAfterRenderObservable: Observable<Layer>;
  51315. private _onAfterRenderObserver;
  51316. /**
  51317. * Back compatibility with callback before the onAfterRenderObservable existed.
  51318. * The set callback will be triggered just after rendering the layer.
  51319. */
  51320. onAfterRender: () => void;
  51321. /**
  51322. * Instantiates a new layer.
  51323. * This represents a full screen 2d layer.
  51324. * This can be useful to display a picture in the background of your scene for instance.
  51325. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51326. * @param name Define the name of the layer in the scene
  51327. * @param imgUrl Define the url of the texture to display in the layer
  51328. * @param scene Define the scene the layer belongs to
  51329. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51330. * @param color Defines a color for the layer
  51331. */
  51332. constructor(
  51333. /**
  51334. * Define the name of the layer.
  51335. */
  51336. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51337. private _createIndexBuffer;
  51338. /** @hidden */
  51339. _rebuild(): void;
  51340. /**
  51341. * Renders the layer in the scene.
  51342. */
  51343. render(): void;
  51344. /**
  51345. * Disposes and releases the associated ressources.
  51346. */
  51347. dispose(): void;
  51348. }
  51349. }
  51350. declare module "babylonjs/Layers/index" {
  51351. export * from "babylonjs/Layers/effectLayer";
  51352. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51353. export * from "babylonjs/Layers/glowLayer";
  51354. export * from "babylonjs/Layers/highlightLayer";
  51355. export * from "babylonjs/Layers/layer";
  51356. export * from "babylonjs/Layers/layerSceneComponent";
  51357. }
  51358. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51359. /** @hidden */
  51360. export var lensFlarePixelShader: {
  51361. name: string;
  51362. shader: string;
  51363. };
  51364. }
  51365. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51366. /** @hidden */
  51367. export var lensFlareVertexShader: {
  51368. name: string;
  51369. shader: string;
  51370. };
  51371. }
  51372. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51373. import { Scene } from "babylonjs/scene";
  51374. import { Vector3 } from "babylonjs/Maths/math.vector";
  51375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51376. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51377. import "babylonjs/Shaders/lensFlare.fragment";
  51378. import "babylonjs/Shaders/lensFlare.vertex";
  51379. import { Viewport } from "babylonjs/Maths/math.viewport";
  51380. /**
  51381. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51382. * It is usually composed of several `lensFlare`.
  51383. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51384. */
  51385. export class LensFlareSystem {
  51386. /**
  51387. * Define the name of the lens flare system
  51388. */
  51389. name: string;
  51390. /**
  51391. * List of lens flares used in this system.
  51392. */
  51393. lensFlares: LensFlare[];
  51394. /**
  51395. * Define a limit from the border the lens flare can be visible.
  51396. */
  51397. borderLimit: number;
  51398. /**
  51399. * Define a viewport border we do not want to see the lens flare in.
  51400. */
  51401. viewportBorder: number;
  51402. /**
  51403. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51404. */
  51405. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51406. /**
  51407. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51408. */
  51409. layerMask: number;
  51410. /**
  51411. * Define the id of the lens flare system in the scene.
  51412. * (equal to name by default)
  51413. */
  51414. id: string;
  51415. private _scene;
  51416. private _emitter;
  51417. private _vertexBuffers;
  51418. private _indexBuffer;
  51419. private _effect;
  51420. private _positionX;
  51421. private _positionY;
  51422. private _isEnabled;
  51423. /** @hidden */
  51424. static _SceneComponentInitialization: (scene: Scene) => void;
  51425. /**
  51426. * Instantiates a lens flare system.
  51427. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51428. * It is usually composed of several `lensFlare`.
  51429. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51430. * @param name Define the name of the lens flare system in the scene
  51431. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51432. * @param scene Define the scene the lens flare system belongs to
  51433. */
  51434. constructor(
  51435. /**
  51436. * Define the name of the lens flare system
  51437. */
  51438. name: string, emitter: any, scene: Scene);
  51439. /**
  51440. * Define if the lens flare system is enabled.
  51441. */
  51442. isEnabled: boolean;
  51443. /**
  51444. * Get the scene the effects belongs to.
  51445. * @returns the scene holding the lens flare system
  51446. */
  51447. getScene(): Scene;
  51448. /**
  51449. * Get the emitter of the lens flare system.
  51450. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51451. * @returns the emitter of the lens flare system
  51452. */
  51453. getEmitter(): any;
  51454. /**
  51455. * Set the emitter of the lens flare system.
  51456. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51457. * @param newEmitter Define the new emitter of the system
  51458. */
  51459. setEmitter(newEmitter: any): void;
  51460. /**
  51461. * Get the lens flare system emitter position.
  51462. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51463. * @returns the position
  51464. */
  51465. getEmitterPosition(): Vector3;
  51466. /**
  51467. * @hidden
  51468. */
  51469. computeEffectivePosition(globalViewport: Viewport): boolean;
  51470. /** @hidden */
  51471. _isVisible(): boolean;
  51472. /**
  51473. * @hidden
  51474. */
  51475. render(): boolean;
  51476. /**
  51477. * Dispose and release the lens flare with its associated resources.
  51478. */
  51479. dispose(): void;
  51480. /**
  51481. * Parse a lens flare system from a JSON repressentation
  51482. * @param parsedLensFlareSystem Define the JSON to parse
  51483. * @param scene Define the scene the parsed system should be instantiated in
  51484. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51485. * @returns the parsed system
  51486. */
  51487. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51488. /**
  51489. * Serialize the current Lens Flare System into a JSON representation.
  51490. * @returns the serialized JSON
  51491. */
  51492. serialize(): any;
  51493. }
  51494. }
  51495. declare module "babylonjs/LensFlares/lensFlare" {
  51496. import { Nullable } from "babylonjs/types";
  51497. import { Color3 } from "babylonjs/Maths/math.color";
  51498. import { Texture } from "babylonjs/Materials/Textures/texture";
  51499. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51500. /**
  51501. * This represents one of the lens effect in a `lensFlareSystem`.
  51502. * It controls one of the indiviual texture used in the effect.
  51503. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51504. */
  51505. export class LensFlare {
  51506. /**
  51507. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51508. */
  51509. size: number;
  51510. /**
  51511. * 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.
  51512. */
  51513. position: number;
  51514. /**
  51515. * Define the lens color.
  51516. */
  51517. color: Color3;
  51518. /**
  51519. * Define the lens texture.
  51520. */
  51521. texture: Nullable<Texture>;
  51522. /**
  51523. * Define the alpha mode to render this particular lens.
  51524. */
  51525. alphaMode: number;
  51526. private _system;
  51527. /**
  51528. * Creates a new Lens Flare.
  51529. * This represents one of the lens effect in a `lensFlareSystem`.
  51530. * It controls one of the indiviual texture used in the effect.
  51531. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51532. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51533. * @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.
  51534. * @param color Define the lens color
  51535. * @param imgUrl Define the lens texture url
  51536. * @param system Define the `lensFlareSystem` this flare is part of
  51537. * @returns The newly created Lens Flare
  51538. */
  51539. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51540. /**
  51541. * Instantiates a new Lens Flare.
  51542. * This represents one of the lens effect in a `lensFlareSystem`.
  51543. * It controls one of the indiviual texture used in the effect.
  51544. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51545. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51546. * @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.
  51547. * @param color Define the lens color
  51548. * @param imgUrl Define the lens texture url
  51549. * @param system Define the `lensFlareSystem` this flare is part of
  51550. */
  51551. constructor(
  51552. /**
  51553. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51554. */
  51555. size: number,
  51556. /**
  51557. * 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.
  51558. */
  51559. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51560. /**
  51561. * Dispose and release the lens flare with its associated resources.
  51562. */
  51563. dispose(): void;
  51564. }
  51565. }
  51566. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51567. import { Nullable } from "babylonjs/types";
  51568. import { Scene } from "babylonjs/scene";
  51569. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51570. import { AbstractScene } from "babylonjs/abstractScene";
  51571. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51572. module "babylonjs/abstractScene" {
  51573. interface AbstractScene {
  51574. /**
  51575. * The list of lens flare system added to the scene
  51576. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51577. */
  51578. lensFlareSystems: Array<LensFlareSystem>;
  51579. /**
  51580. * Removes the given lens flare system from this scene.
  51581. * @param toRemove The lens flare system to remove
  51582. * @returns The index of the removed lens flare system
  51583. */
  51584. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51585. /**
  51586. * Adds the given lens flare system to this scene
  51587. * @param newLensFlareSystem The lens flare system to add
  51588. */
  51589. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51590. /**
  51591. * Gets a lens flare system using its name
  51592. * @param name defines the name to look for
  51593. * @returns the lens flare system or null if not found
  51594. */
  51595. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51596. /**
  51597. * Gets a lens flare system using its id
  51598. * @param id defines the id to look for
  51599. * @returns the lens flare system or null if not found
  51600. */
  51601. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51602. }
  51603. }
  51604. /**
  51605. * Defines the lens flare scene component responsible to manage any lens flares
  51606. * in a given scene.
  51607. */
  51608. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51609. /**
  51610. * The component name helpfull to identify the component in the list of scene components.
  51611. */
  51612. readonly name: string;
  51613. /**
  51614. * The scene the component belongs to.
  51615. */
  51616. scene: Scene;
  51617. /**
  51618. * Creates a new instance of the component for the given scene
  51619. * @param scene Defines the scene to register the component in
  51620. */
  51621. constructor(scene: Scene);
  51622. /**
  51623. * Registers the component in a given scene
  51624. */
  51625. register(): void;
  51626. /**
  51627. * Rebuilds the elements related to this component in case of
  51628. * context lost for instance.
  51629. */
  51630. rebuild(): void;
  51631. /**
  51632. * Adds all the elements from the container to the scene
  51633. * @param container the container holding the elements
  51634. */
  51635. addFromContainer(container: AbstractScene): void;
  51636. /**
  51637. * Removes all the elements in the container from the scene
  51638. * @param container contains the elements to remove
  51639. * @param dispose if the removed element should be disposed (default: false)
  51640. */
  51641. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51642. /**
  51643. * Serializes the component data to the specified json object
  51644. * @param serializationObject The object to serialize to
  51645. */
  51646. serialize(serializationObject: any): void;
  51647. /**
  51648. * Disposes the component and the associated ressources.
  51649. */
  51650. dispose(): void;
  51651. private _draw;
  51652. }
  51653. }
  51654. declare module "babylonjs/LensFlares/index" {
  51655. export * from "babylonjs/LensFlares/lensFlare";
  51656. export * from "babylonjs/LensFlares/lensFlareSystem";
  51657. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51658. }
  51659. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51660. import { Scene } from "babylonjs/scene";
  51661. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51662. import { AbstractScene } from "babylonjs/abstractScene";
  51663. /**
  51664. * Defines the shadow generator component responsible to manage any shadow generators
  51665. * in a given scene.
  51666. */
  51667. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51668. /**
  51669. * The component name helpfull to identify the component in the list of scene components.
  51670. */
  51671. readonly name: string;
  51672. /**
  51673. * The scene the component belongs to.
  51674. */
  51675. scene: Scene;
  51676. /**
  51677. * Creates a new instance of the component for the given scene
  51678. * @param scene Defines the scene to register the component in
  51679. */
  51680. constructor(scene: Scene);
  51681. /**
  51682. * Registers the component in a given scene
  51683. */
  51684. register(): void;
  51685. /**
  51686. * Rebuilds the elements related to this component in case of
  51687. * context lost for instance.
  51688. */
  51689. rebuild(): void;
  51690. /**
  51691. * Serializes the component data to the specified json object
  51692. * @param serializationObject The object to serialize to
  51693. */
  51694. serialize(serializationObject: any): void;
  51695. /**
  51696. * Adds all the elements from the container to the scene
  51697. * @param container the container holding the elements
  51698. */
  51699. addFromContainer(container: AbstractScene): void;
  51700. /**
  51701. * Removes all the elements in the container from the scene
  51702. * @param container contains the elements to remove
  51703. * @param dispose if the removed element should be disposed (default: false)
  51704. */
  51705. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51706. /**
  51707. * Rebuilds the elements related to this component in case of
  51708. * context lost for instance.
  51709. */
  51710. dispose(): void;
  51711. private _gatherRenderTargets;
  51712. }
  51713. }
  51714. declare module "babylonjs/Lights/Shadows/index" {
  51715. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51716. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51717. }
  51718. declare module "babylonjs/Lights/pointLight" {
  51719. import { Scene } from "babylonjs/scene";
  51720. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51722. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51723. import { Effect } from "babylonjs/Materials/effect";
  51724. /**
  51725. * A point light is a light defined by an unique point in world space.
  51726. * The light is emitted in every direction from this point.
  51727. * A good example of a point light is a standard light bulb.
  51728. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51729. */
  51730. export class PointLight extends ShadowLight {
  51731. private _shadowAngle;
  51732. /**
  51733. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51734. * This specifies what angle the shadow will use to be created.
  51735. *
  51736. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51737. */
  51738. /**
  51739. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51740. * This specifies what angle the shadow will use to be created.
  51741. *
  51742. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51743. */
  51744. shadowAngle: number;
  51745. /**
  51746. * Gets the direction if it has been set.
  51747. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51748. */
  51749. /**
  51750. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51751. */
  51752. direction: Vector3;
  51753. /**
  51754. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51755. * A PointLight emits the light in every direction.
  51756. * It can cast shadows.
  51757. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51758. * ```javascript
  51759. * var pointLight = new PointLight("pl", camera.position, scene);
  51760. * ```
  51761. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51762. * @param name The light friendly name
  51763. * @param position The position of the point light in the scene
  51764. * @param scene The scene the lights belongs to
  51765. */
  51766. constructor(name: string, position: Vector3, scene: Scene);
  51767. /**
  51768. * Returns the string "PointLight"
  51769. * @returns the class name
  51770. */
  51771. getClassName(): string;
  51772. /**
  51773. * Returns the integer 0.
  51774. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51775. */
  51776. getTypeID(): number;
  51777. /**
  51778. * Specifies wether or not the shadowmap should be a cube texture.
  51779. * @returns true if the shadowmap needs to be a cube texture.
  51780. */
  51781. needCube(): boolean;
  51782. /**
  51783. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51784. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51785. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51786. */
  51787. getShadowDirection(faceIndex?: number): Vector3;
  51788. /**
  51789. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51790. * - fov = PI / 2
  51791. * - aspect ratio : 1.0
  51792. * - z-near and far equal to the active camera minZ and maxZ.
  51793. * Returns the PointLight.
  51794. */
  51795. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51796. protected _buildUniformLayout(): void;
  51797. /**
  51798. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51799. * @param effect The effect to update
  51800. * @param lightIndex The index of the light in the effect to update
  51801. * @returns The point light
  51802. */
  51803. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51804. /**
  51805. * Prepares the list of defines specific to the light type.
  51806. * @param defines the list of defines
  51807. * @param lightIndex defines the index of the light for the effect
  51808. */
  51809. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51810. }
  51811. }
  51812. declare module "babylonjs/Lights/index" {
  51813. export * from "babylonjs/Lights/light";
  51814. export * from "babylonjs/Lights/shadowLight";
  51815. export * from "babylonjs/Lights/Shadows/index";
  51816. export * from "babylonjs/Lights/directionalLight";
  51817. export * from "babylonjs/Lights/hemisphericLight";
  51818. export * from "babylonjs/Lights/pointLight";
  51819. export * from "babylonjs/Lights/spotLight";
  51820. }
  51821. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51822. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51823. /**
  51824. * Header information of HDR texture files.
  51825. */
  51826. export interface HDRInfo {
  51827. /**
  51828. * The height of the texture in pixels.
  51829. */
  51830. height: number;
  51831. /**
  51832. * The width of the texture in pixels.
  51833. */
  51834. width: number;
  51835. /**
  51836. * The index of the beginning of the data in the binary file.
  51837. */
  51838. dataPosition: number;
  51839. }
  51840. /**
  51841. * This groups tools to convert HDR texture to native colors array.
  51842. */
  51843. export class HDRTools {
  51844. private static Ldexp;
  51845. private static Rgbe2float;
  51846. private static readStringLine;
  51847. /**
  51848. * Reads header information from an RGBE texture stored in a native array.
  51849. * More information on this format are available here:
  51850. * https://en.wikipedia.org/wiki/RGBE_image_format
  51851. *
  51852. * @param uint8array The binary file stored in native array.
  51853. * @return The header information.
  51854. */
  51855. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51856. /**
  51857. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51858. * This RGBE texture needs to store the information as a panorama.
  51859. *
  51860. * More information on this format are available here:
  51861. * https://en.wikipedia.org/wiki/RGBE_image_format
  51862. *
  51863. * @param buffer The binary file stored in an array buffer.
  51864. * @param size The expected size of the extracted cubemap.
  51865. * @return The Cube Map information.
  51866. */
  51867. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51868. /**
  51869. * Returns the pixels data extracted from an RGBE texture.
  51870. * This pixels will be stored left to right up to down in the R G B order in one array.
  51871. *
  51872. * More information on this format are available here:
  51873. * https://en.wikipedia.org/wiki/RGBE_image_format
  51874. *
  51875. * @param uint8array The binary file stored in an array buffer.
  51876. * @param hdrInfo The header information of the file.
  51877. * @return The pixels data in RGB right to left up to down order.
  51878. */
  51879. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51880. private static RGBE_ReadPixels_RLE;
  51881. }
  51882. }
  51883. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51884. import { Nullable } from "babylonjs/types";
  51885. import { Scene } from "babylonjs/scene";
  51886. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51888. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51889. /**
  51890. * This represents a texture coming from an HDR input.
  51891. *
  51892. * The only supported format is currently panorama picture stored in RGBE format.
  51893. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51894. */
  51895. export class HDRCubeTexture extends BaseTexture {
  51896. private static _facesMapping;
  51897. private _generateHarmonics;
  51898. private _noMipmap;
  51899. private _textureMatrix;
  51900. private _size;
  51901. private _onLoad;
  51902. private _onError;
  51903. /**
  51904. * The texture URL.
  51905. */
  51906. url: string;
  51907. /**
  51908. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51909. */
  51910. coordinatesMode: number;
  51911. protected _isBlocking: boolean;
  51912. /**
  51913. * Sets wether or not the texture is blocking during loading.
  51914. */
  51915. /**
  51916. * Gets wether or not the texture is blocking during loading.
  51917. */
  51918. isBlocking: boolean;
  51919. protected _rotationY: number;
  51920. /**
  51921. * Sets texture matrix rotation angle around Y axis in radians.
  51922. */
  51923. /**
  51924. * Gets texture matrix rotation angle around Y axis radians.
  51925. */
  51926. rotationY: number;
  51927. /**
  51928. * Gets or sets the center of the bounding box associated with the cube texture
  51929. * It must define where the camera used to render the texture was set
  51930. */
  51931. boundingBoxPosition: Vector3;
  51932. private _boundingBoxSize;
  51933. /**
  51934. * Gets or sets the size of the bounding box associated with the cube texture
  51935. * When defined, the cubemap will switch to local mode
  51936. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51937. * @example https://www.babylonjs-playground.com/#RNASML
  51938. */
  51939. boundingBoxSize: Vector3;
  51940. /**
  51941. * Instantiates an HDRTexture from the following parameters.
  51942. *
  51943. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51944. * @param scene The scene the texture will be used in
  51945. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51946. * @param noMipmap Forces to not generate the mipmap if true
  51947. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51948. * @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)
  51949. * @param reserved Reserved flag for internal use.
  51950. */
  51951. 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>);
  51952. /**
  51953. * Get the current class name of the texture useful for serialization or dynamic coding.
  51954. * @returns "HDRCubeTexture"
  51955. */
  51956. getClassName(): string;
  51957. /**
  51958. * Occurs when the file is raw .hdr file.
  51959. */
  51960. private loadTexture;
  51961. clone(): HDRCubeTexture;
  51962. delayLoad(): void;
  51963. /**
  51964. * Get the texture reflection matrix used to rotate/transform the reflection.
  51965. * @returns the reflection matrix
  51966. */
  51967. getReflectionTextureMatrix(): Matrix;
  51968. /**
  51969. * Set the texture reflection matrix used to rotate/transform the reflection.
  51970. * @param value Define the reflection matrix to set
  51971. */
  51972. setReflectionTextureMatrix(value: Matrix): void;
  51973. /**
  51974. * Parses a JSON representation of an HDR Texture in order to create the texture
  51975. * @param parsedTexture Define the JSON representation
  51976. * @param scene Define the scene the texture should be created in
  51977. * @param rootUrl Define the root url in case we need to load relative dependencies
  51978. * @returns the newly created texture after parsing
  51979. */
  51980. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51981. serialize(): any;
  51982. }
  51983. }
  51984. declare module "babylonjs/Physics/physicsEngine" {
  51985. import { Nullable } from "babylonjs/types";
  51986. import { Vector3 } from "babylonjs/Maths/math.vector";
  51987. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51988. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51989. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51990. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51991. /**
  51992. * Class used to control physics engine
  51993. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51994. */
  51995. export class PhysicsEngine implements IPhysicsEngine {
  51996. private _physicsPlugin;
  51997. /**
  51998. * Global value used to control the smallest number supported by the simulation
  51999. */
  52000. static Epsilon: number;
  52001. private _impostors;
  52002. private _joints;
  52003. /**
  52004. * Gets the gravity vector used by the simulation
  52005. */
  52006. gravity: Vector3;
  52007. /**
  52008. * Factory used to create the default physics plugin.
  52009. * @returns The default physics plugin
  52010. */
  52011. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52012. /**
  52013. * Creates a new Physics Engine
  52014. * @param gravity defines the gravity vector used by the simulation
  52015. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52016. */
  52017. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52018. /**
  52019. * Sets the gravity vector used by the simulation
  52020. * @param gravity defines the gravity vector to use
  52021. */
  52022. setGravity(gravity: Vector3): void;
  52023. /**
  52024. * Set the time step of the physics engine.
  52025. * Default is 1/60.
  52026. * To slow it down, enter 1/600 for example.
  52027. * To speed it up, 1/30
  52028. * @param newTimeStep defines the new timestep to apply to this world.
  52029. */
  52030. setTimeStep(newTimeStep?: number): void;
  52031. /**
  52032. * Get the time step of the physics engine.
  52033. * @returns the current time step
  52034. */
  52035. getTimeStep(): number;
  52036. /**
  52037. * Release all resources
  52038. */
  52039. dispose(): void;
  52040. /**
  52041. * Gets the name of the current physics plugin
  52042. * @returns the name of the plugin
  52043. */
  52044. getPhysicsPluginName(): string;
  52045. /**
  52046. * Adding a new impostor for the impostor tracking.
  52047. * This will be done by the impostor itself.
  52048. * @param impostor the impostor to add
  52049. */
  52050. addImpostor(impostor: PhysicsImpostor): void;
  52051. /**
  52052. * Remove an impostor from the engine.
  52053. * This impostor and its mesh will not longer be updated by the physics engine.
  52054. * @param impostor the impostor to remove
  52055. */
  52056. removeImpostor(impostor: PhysicsImpostor): void;
  52057. /**
  52058. * Add a joint to the physics engine
  52059. * @param mainImpostor defines the main impostor to which the joint is added.
  52060. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52061. * @param joint defines the joint that will connect both impostors.
  52062. */
  52063. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52064. /**
  52065. * Removes a joint from the simulation
  52066. * @param mainImpostor defines the impostor used with the joint
  52067. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52068. * @param joint defines the joint to remove
  52069. */
  52070. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52071. /**
  52072. * Called by the scene. No need to call it.
  52073. * @param delta defines the timespam between frames
  52074. */
  52075. _step(delta: number): void;
  52076. /**
  52077. * Gets the current plugin used to run the simulation
  52078. * @returns current plugin
  52079. */
  52080. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52081. /**
  52082. * Gets the list of physic impostors
  52083. * @returns an array of PhysicsImpostor
  52084. */
  52085. getImpostors(): Array<PhysicsImpostor>;
  52086. /**
  52087. * Gets the impostor for a physics enabled object
  52088. * @param object defines the object impersonated by the impostor
  52089. * @returns the PhysicsImpostor or null if not found
  52090. */
  52091. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52092. /**
  52093. * Gets the impostor for a physics body object
  52094. * @param body defines physics body used by the impostor
  52095. * @returns the PhysicsImpostor or null if not found
  52096. */
  52097. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52098. /**
  52099. * Does a raycast in the physics world
  52100. * @param from when should the ray start?
  52101. * @param to when should the ray end?
  52102. * @returns PhysicsRaycastResult
  52103. */
  52104. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52105. }
  52106. }
  52107. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52108. import { Nullable } from "babylonjs/types";
  52109. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52111. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52112. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52113. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52114. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52115. /** @hidden */
  52116. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52117. private _useDeltaForWorldStep;
  52118. world: any;
  52119. name: string;
  52120. private _physicsMaterials;
  52121. private _fixedTimeStep;
  52122. private _cannonRaycastResult;
  52123. private _raycastResult;
  52124. private _physicsBodysToRemoveAfterStep;
  52125. BJSCANNON: any;
  52126. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52127. setGravity(gravity: Vector3): void;
  52128. setTimeStep(timeStep: number): void;
  52129. getTimeStep(): number;
  52130. executeStep(delta: number): void;
  52131. private _removeMarkedPhysicsBodiesFromWorld;
  52132. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52133. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52134. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52135. private _processChildMeshes;
  52136. removePhysicsBody(impostor: PhysicsImpostor): void;
  52137. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52138. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52139. private _addMaterial;
  52140. private _checkWithEpsilon;
  52141. private _createShape;
  52142. private _createHeightmap;
  52143. private _minus90X;
  52144. private _plus90X;
  52145. private _tmpPosition;
  52146. private _tmpDeltaPosition;
  52147. private _tmpUnityRotation;
  52148. private _updatePhysicsBodyTransformation;
  52149. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52150. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52151. isSupported(): boolean;
  52152. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52153. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52154. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52155. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52156. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52157. getBodyMass(impostor: PhysicsImpostor): number;
  52158. getBodyFriction(impostor: PhysicsImpostor): number;
  52159. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52160. getBodyRestitution(impostor: PhysicsImpostor): number;
  52161. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52162. sleepBody(impostor: PhysicsImpostor): void;
  52163. wakeUpBody(impostor: PhysicsImpostor): void;
  52164. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52165. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52166. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52167. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52168. getRadius(impostor: PhysicsImpostor): number;
  52169. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52170. dispose(): void;
  52171. private _extendNamespace;
  52172. /**
  52173. * Does a raycast in the physics world
  52174. * @param from when should the ray start?
  52175. * @param to when should the ray end?
  52176. * @returns PhysicsRaycastResult
  52177. */
  52178. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52179. }
  52180. }
  52181. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52182. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52183. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52184. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52186. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52187. import { Nullable } from "babylonjs/types";
  52188. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52189. /** @hidden */
  52190. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52191. world: any;
  52192. name: string;
  52193. BJSOIMO: any;
  52194. private _raycastResult;
  52195. constructor(iterations?: number, oimoInjection?: any);
  52196. setGravity(gravity: Vector3): void;
  52197. setTimeStep(timeStep: number): void;
  52198. getTimeStep(): number;
  52199. private _tmpImpostorsArray;
  52200. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52201. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52202. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52203. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52204. private _tmpPositionVector;
  52205. removePhysicsBody(impostor: PhysicsImpostor): void;
  52206. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52207. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52208. isSupported(): boolean;
  52209. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52210. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52211. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52212. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52213. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52214. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52215. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52216. getBodyMass(impostor: PhysicsImpostor): number;
  52217. getBodyFriction(impostor: PhysicsImpostor): number;
  52218. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52219. getBodyRestitution(impostor: PhysicsImpostor): number;
  52220. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52221. sleepBody(impostor: PhysicsImpostor): void;
  52222. wakeUpBody(impostor: PhysicsImpostor): void;
  52223. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52224. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52225. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52226. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52227. getRadius(impostor: PhysicsImpostor): number;
  52228. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52229. dispose(): void;
  52230. /**
  52231. * Does a raycast in the physics world
  52232. * @param from when should the ray start?
  52233. * @param to when should the ray end?
  52234. * @returns PhysicsRaycastResult
  52235. */
  52236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52237. }
  52238. }
  52239. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52240. import { Nullable } from "babylonjs/types";
  52241. import { Scene } from "babylonjs/scene";
  52242. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52243. import { Color4 } from "babylonjs/Maths/math.color";
  52244. import { Mesh } from "babylonjs/Meshes/mesh";
  52245. /**
  52246. * Class containing static functions to help procedurally build meshes
  52247. */
  52248. export class RibbonBuilder {
  52249. /**
  52250. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52251. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52252. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52253. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52254. * * 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
  52255. * * 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
  52256. * * 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
  52257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52258. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52259. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52260. * * 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
  52261. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52262. * * 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
  52263. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52265. * @param name defines the name of the mesh
  52266. * @param options defines the options used to create the mesh
  52267. * @param scene defines the hosting scene
  52268. * @returns the ribbon mesh
  52269. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52271. */
  52272. static CreateRibbon(name: string, options: {
  52273. pathArray: Vector3[][];
  52274. closeArray?: boolean;
  52275. closePath?: boolean;
  52276. offset?: number;
  52277. updatable?: boolean;
  52278. sideOrientation?: number;
  52279. frontUVs?: Vector4;
  52280. backUVs?: Vector4;
  52281. instance?: Mesh;
  52282. invertUV?: boolean;
  52283. uvs?: Vector2[];
  52284. colors?: Color4[];
  52285. }, scene?: Nullable<Scene>): Mesh;
  52286. }
  52287. }
  52288. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52289. import { Nullable } from "babylonjs/types";
  52290. import { Scene } from "babylonjs/scene";
  52291. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52292. import { Mesh } from "babylonjs/Meshes/mesh";
  52293. /**
  52294. * Class containing static functions to help procedurally build meshes
  52295. */
  52296. export class ShapeBuilder {
  52297. /**
  52298. * 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.
  52299. * * 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.
  52300. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52301. * * 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.
  52302. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52303. * * 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
  52304. * * 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
  52305. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52310. * @param name defines the name of the mesh
  52311. * @param options defines the options used to create the mesh
  52312. * @param scene defines the hosting scene
  52313. * @returns the extruded shape mesh
  52314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52316. */
  52317. static ExtrudeShape(name: string, options: {
  52318. shape: Vector3[];
  52319. path: Vector3[];
  52320. scale?: number;
  52321. rotation?: number;
  52322. cap?: number;
  52323. updatable?: boolean;
  52324. sideOrientation?: number;
  52325. frontUVs?: Vector4;
  52326. backUVs?: Vector4;
  52327. instance?: Mesh;
  52328. invertUV?: boolean;
  52329. }, scene?: Nullable<Scene>): Mesh;
  52330. /**
  52331. * Creates an custom extruded shape mesh.
  52332. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52333. * * 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.
  52334. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52335. * * 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
  52336. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52337. * * 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
  52338. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52339. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52340. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52341. * * 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
  52342. * * 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
  52343. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52348. * @param name defines the name of the mesh
  52349. * @param options defines the options used to create the mesh
  52350. * @param scene defines the hosting scene
  52351. * @returns the custom extruded shape mesh
  52352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52353. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52355. */
  52356. static ExtrudeShapeCustom(name: string, options: {
  52357. shape: Vector3[];
  52358. path: Vector3[];
  52359. scaleFunction?: any;
  52360. rotationFunction?: any;
  52361. ribbonCloseArray?: boolean;
  52362. ribbonClosePath?: boolean;
  52363. cap?: number;
  52364. updatable?: boolean;
  52365. sideOrientation?: number;
  52366. frontUVs?: Vector4;
  52367. backUVs?: Vector4;
  52368. instance?: Mesh;
  52369. invertUV?: boolean;
  52370. }, scene?: Nullable<Scene>): Mesh;
  52371. private static _ExtrudeShapeGeneric;
  52372. }
  52373. }
  52374. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52375. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52376. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52377. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52378. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52379. import { Nullable } from "babylonjs/types";
  52380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52381. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52382. /**
  52383. * AmmoJS Physics plugin
  52384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52385. * @see https://github.com/kripken/ammo.js/
  52386. */
  52387. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52388. private _useDeltaForWorldStep;
  52389. /**
  52390. * Reference to the Ammo library
  52391. */
  52392. bjsAMMO: any;
  52393. /**
  52394. * Created ammoJS world which physics bodies are added to
  52395. */
  52396. world: any;
  52397. /**
  52398. * Name of the plugin
  52399. */
  52400. name: string;
  52401. private _timeStep;
  52402. private _fixedTimeStep;
  52403. private _maxSteps;
  52404. private _tmpQuaternion;
  52405. private _tmpAmmoTransform;
  52406. private _tmpAmmoQuaternion;
  52407. private _tmpAmmoConcreteContactResultCallback;
  52408. private _collisionConfiguration;
  52409. private _dispatcher;
  52410. private _overlappingPairCache;
  52411. private _solver;
  52412. private _softBodySolver;
  52413. private _tmpAmmoVectorA;
  52414. private _tmpAmmoVectorB;
  52415. private _tmpAmmoVectorC;
  52416. private _tmpAmmoVectorD;
  52417. private _tmpContactCallbackResult;
  52418. private _tmpAmmoVectorRCA;
  52419. private _tmpAmmoVectorRCB;
  52420. private _raycastResult;
  52421. private static readonly DISABLE_COLLISION_FLAG;
  52422. private static readonly KINEMATIC_FLAG;
  52423. private static readonly DISABLE_DEACTIVATION_FLAG;
  52424. /**
  52425. * Initializes the ammoJS plugin
  52426. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52427. * @param ammoInjection can be used to inject your own ammo reference
  52428. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52429. */
  52430. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52431. /**
  52432. * Sets the gravity of the physics world (m/(s^2))
  52433. * @param gravity Gravity to set
  52434. */
  52435. setGravity(gravity: Vector3): void;
  52436. /**
  52437. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52438. * @param timeStep timestep to use in seconds
  52439. */
  52440. setTimeStep(timeStep: number): void;
  52441. /**
  52442. * 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)
  52443. * @param fixedTimeStep fixedTimeStep to use in seconds
  52444. */
  52445. setFixedTimeStep(fixedTimeStep: number): void;
  52446. /**
  52447. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52448. * @param maxSteps the maximum number of steps by the physics engine per frame
  52449. */
  52450. setMaxSteps(maxSteps: number): void;
  52451. /**
  52452. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52453. * @returns the current timestep in seconds
  52454. */
  52455. getTimeStep(): number;
  52456. private _isImpostorInContact;
  52457. private _isImpostorPairInContact;
  52458. private _stepSimulation;
  52459. /**
  52460. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52461. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52462. * After the step the babylon meshes are set to the position of the physics imposters
  52463. * @param delta amount of time to step forward
  52464. * @param impostors array of imposters to update before/after the step
  52465. */
  52466. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52467. /**
  52468. * Update babylon mesh to match physics world object
  52469. * @param impostor imposter to match
  52470. */
  52471. private _afterSoftStep;
  52472. /**
  52473. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52474. * @param impostor imposter to match
  52475. */
  52476. private _ropeStep;
  52477. /**
  52478. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52479. * @param impostor imposter to match
  52480. */
  52481. private _softbodyOrClothStep;
  52482. private _tmpVector;
  52483. private _tmpMatrix;
  52484. /**
  52485. * Applies an impulse on the imposter
  52486. * @param impostor imposter to apply impulse to
  52487. * @param force amount of force to be applied to the imposter
  52488. * @param contactPoint the location to apply the impulse on the imposter
  52489. */
  52490. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52491. /**
  52492. * Applies a force on the imposter
  52493. * @param impostor imposter to apply force
  52494. * @param force amount of force to be applied to the imposter
  52495. * @param contactPoint the location to apply the force on the imposter
  52496. */
  52497. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52498. /**
  52499. * Creates a physics body using the plugin
  52500. * @param impostor the imposter to create the physics body on
  52501. */
  52502. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52503. /**
  52504. * Removes the physics body from the imposter and disposes of the body's memory
  52505. * @param impostor imposter to remove the physics body from
  52506. */
  52507. removePhysicsBody(impostor: PhysicsImpostor): void;
  52508. /**
  52509. * Generates a joint
  52510. * @param impostorJoint the imposter joint to create the joint with
  52511. */
  52512. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52513. /**
  52514. * Removes a joint
  52515. * @param impostorJoint the imposter joint to remove the joint from
  52516. */
  52517. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52518. private _addMeshVerts;
  52519. /**
  52520. * Initialise the soft body vertices to match its object's (mesh) vertices
  52521. * Softbody vertices (nodes) are in world space and to match this
  52522. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52523. * @param impostor to create the softbody for
  52524. */
  52525. private _softVertexData;
  52526. /**
  52527. * Create an impostor's soft body
  52528. * @param impostor to create the softbody for
  52529. */
  52530. private _createSoftbody;
  52531. /**
  52532. * Create cloth for an impostor
  52533. * @param impostor to create the softbody for
  52534. */
  52535. private _createCloth;
  52536. /**
  52537. * Create rope for an impostor
  52538. * @param impostor to create the softbody for
  52539. */
  52540. private _createRope;
  52541. private _addHullVerts;
  52542. private _createShape;
  52543. /**
  52544. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52545. * @param impostor imposter containing the physics body and babylon object
  52546. */
  52547. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52548. /**
  52549. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52550. * @param impostor imposter containing the physics body and babylon object
  52551. * @param newPosition new position
  52552. * @param newRotation new rotation
  52553. */
  52554. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52555. /**
  52556. * If this plugin is supported
  52557. * @returns true if its supported
  52558. */
  52559. isSupported(): boolean;
  52560. /**
  52561. * Sets the linear velocity of the physics body
  52562. * @param impostor imposter to set the velocity on
  52563. * @param velocity velocity to set
  52564. */
  52565. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52566. /**
  52567. * Sets the angular velocity of the physics body
  52568. * @param impostor imposter to set the velocity on
  52569. * @param velocity velocity to set
  52570. */
  52571. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52572. /**
  52573. * gets the linear velocity
  52574. * @param impostor imposter to get linear velocity from
  52575. * @returns linear velocity
  52576. */
  52577. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52578. /**
  52579. * gets the angular velocity
  52580. * @param impostor imposter to get angular velocity from
  52581. * @returns angular velocity
  52582. */
  52583. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52584. /**
  52585. * Sets the mass of physics body
  52586. * @param impostor imposter to set the mass on
  52587. * @param mass mass to set
  52588. */
  52589. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52590. /**
  52591. * Gets the mass of the physics body
  52592. * @param impostor imposter to get the mass from
  52593. * @returns mass
  52594. */
  52595. getBodyMass(impostor: PhysicsImpostor): number;
  52596. /**
  52597. * Gets friction of the impostor
  52598. * @param impostor impostor to get friction from
  52599. * @returns friction value
  52600. */
  52601. getBodyFriction(impostor: PhysicsImpostor): number;
  52602. /**
  52603. * Sets friction of the impostor
  52604. * @param impostor impostor to set friction on
  52605. * @param friction friction value
  52606. */
  52607. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52608. /**
  52609. * Gets restitution of the impostor
  52610. * @param impostor impostor to get restitution from
  52611. * @returns restitution value
  52612. */
  52613. getBodyRestitution(impostor: PhysicsImpostor): number;
  52614. /**
  52615. * Sets resitution of the impostor
  52616. * @param impostor impostor to set resitution on
  52617. * @param restitution resitution value
  52618. */
  52619. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52620. /**
  52621. * Gets pressure inside the impostor
  52622. * @param impostor impostor to get pressure from
  52623. * @returns pressure value
  52624. */
  52625. getBodyPressure(impostor: PhysicsImpostor): number;
  52626. /**
  52627. * Sets pressure inside a soft body impostor
  52628. * Cloth and rope must remain 0 pressure
  52629. * @param impostor impostor to set pressure on
  52630. * @param pressure pressure value
  52631. */
  52632. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52633. /**
  52634. * Gets stiffness of the impostor
  52635. * @param impostor impostor to get stiffness from
  52636. * @returns pressure value
  52637. */
  52638. getBodyStiffness(impostor: PhysicsImpostor): number;
  52639. /**
  52640. * Sets stiffness of the impostor
  52641. * @param impostor impostor to set stiffness on
  52642. * @param stiffness stiffness value from 0 to 1
  52643. */
  52644. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52645. /**
  52646. * Gets velocityIterations of the impostor
  52647. * @param impostor impostor to get velocity iterations from
  52648. * @returns velocityIterations value
  52649. */
  52650. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52651. /**
  52652. * Sets velocityIterations of the impostor
  52653. * @param impostor impostor to set velocity iterations on
  52654. * @param velocityIterations velocityIterations value
  52655. */
  52656. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52657. /**
  52658. * Gets positionIterations of the impostor
  52659. * @param impostor impostor to get position iterations from
  52660. * @returns positionIterations value
  52661. */
  52662. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52663. /**
  52664. * Sets positionIterations of the impostor
  52665. * @param impostor impostor to set position on
  52666. * @param positionIterations positionIterations value
  52667. */
  52668. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52669. /**
  52670. * Append an anchor to a cloth object
  52671. * @param impostor is the cloth impostor to add anchor to
  52672. * @param otherImpostor is the rigid impostor to anchor to
  52673. * @param width ratio across width from 0 to 1
  52674. * @param height ratio up height from 0 to 1
  52675. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52676. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52677. */
  52678. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52679. /**
  52680. * Append an hook to a rope object
  52681. * @param impostor is the rope impostor to add hook to
  52682. * @param otherImpostor is the rigid impostor to hook to
  52683. * @param length ratio along the rope from 0 to 1
  52684. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52685. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52686. */
  52687. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52688. /**
  52689. * Sleeps the physics body and stops it from being active
  52690. * @param impostor impostor to sleep
  52691. */
  52692. sleepBody(impostor: PhysicsImpostor): void;
  52693. /**
  52694. * Activates the physics body
  52695. * @param impostor impostor to activate
  52696. */
  52697. wakeUpBody(impostor: PhysicsImpostor): void;
  52698. /**
  52699. * Updates the distance parameters of the joint
  52700. * @param joint joint to update
  52701. * @param maxDistance maximum distance of the joint
  52702. * @param minDistance minimum distance of the joint
  52703. */
  52704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52705. /**
  52706. * Sets a motor on the joint
  52707. * @param joint joint to set motor on
  52708. * @param speed speed of the motor
  52709. * @param maxForce maximum force of the motor
  52710. * @param motorIndex index of the motor
  52711. */
  52712. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52713. /**
  52714. * Sets the motors limit
  52715. * @param joint joint to set limit on
  52716. * @param upperLimit upper limit
  52717. * @param lowerLimit lower limit
  52718. */
  52719. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52720. /**
  52721. * Syncs the position and rotation of a mesh with the impostor
  52722. * @param mesh mesh to sync
  52723. * @param impostor impostor to update the mesh with
  52724. */
  52725. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52726. /**
  52727. * Gets the radius of the impostor
  52728. * @param impostor impostor to get radius from
  52729. * @returns the radius
  52730. */
  52731. getRadius(impostor: PhysicsImpostor): number;
  52732. /**
  52733. * Gets the box size of the impostor
  52734. * @param impostor impostor to get box size from
  52735. * @param result the resulting box size
  52736. */
  52737. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52738. /**
  52739. * Disposes of the impostor
  52740. */
  52741. dispose(): void;
  52742. /**
  52743. * Does a raycast in the physics world
  52744. * @param from when should the ray start?
  52745. * @param to when should the ray end?
  52746. * @returns PhysicsRaycastResult
  52747. */
  52748. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52749. }
  52750. }
  52751. declare module "babylonjs/Probes/reflectionProbe" {
  52752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52753. import { Vector3 } from "babylonjs/Maths/math.vector";
  52754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52755. import { Nullable } from "babylonjs/types";
  52756. import { Scene } from "babylonjs/scene";
  52757. module "babylonjs/abstractScene" {
  52758. interface AbstractScene {
  52759. /**
  52760. * The list of reflection probes added to the scene
  52761. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52762. */
  52763. reflectionProbes: Array<ReflectionProbe>;
  52764. /**
  52765. * Removes the given reflection probe from this scene.
  52766. * @param toRemove The reflection probe to remove
  52767. * @returns The index of the removed reflection probe
  52768. */
  52769. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52770. /**
  52771. * Adds the given reflection probe to this scene.
  52772. * @param newReflectionProbe The reflection probe to add
  52773. */
  52774. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52775. }
  52776. }
  52777. /**
  52778. * Class used to generate realtime reflection / refraction cube textures
  52779. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52780. */
  52781. export class ReflectionProbe {
  52782. /** defines the name of the probe */
  52783. name: string;
  52784. private _scene;
  52785. private _renderTargetTexture;
  52786. private _projectionMatrix;
  52787. private _viewMatrix;
  52788. private _target;
  52789. private _add;
  52790. private _attachedMesh;
  52791. private _invertYAxis;
  52792. /** Gets or sets probe position (center of the cube map) */
  52793. position: Vector3;
  52794. /**
  52795. * Creates a new reflection probe
  52796. * @param name defines the name of the probe
  52797. * @param size defines the texture resolution (for each face)
  52798. * @param scene defines the hosting scene
  52799. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52800. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52801. */
  52802. constructor(
  52803. /** defines the name of the probe */
  52804. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52805. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52806. samples: number;
  52807. /** Gets or sets the refresh rate to use (on every frame by default) */
  52808. refreshRate: number;
  52809. /**
  52810. * Gets the hosting scene
  52811. * @returns a Scene
  52812. */
  52813. getScene(): Scene;
  52814. /** Gets the internal CubeTexture used to render to */
  52815. readonly cubeTexture: RenderTargetTexture;
  52816. /** Gets the list of meshes to render */
  52817. readonly renderList: Nullable<AbstractMesh[]>;
  52818. /**
  52819. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52820. * @param mesh defines the mesh to attach to
  52821. */
  52822. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52823. /**
  52824. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52825. * @param renderingGroupId The rendering group id corresponding to its index
  52826. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52827. */
  52828. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52829. /**
  52830. * Clean all associated resources
  52831. */
  52832. dispose(): void;
  52833. /**
  52834. * Converts the reflection probe information to a readable string for debug purpose.
  52835. * @param fullDetails Supports for multiple levels of logging within scene loading
  52836. * @returns the human readable reflection probe info
  52837. */
  52838. toString(fullDetails?: boolean): string;
  52839. /**
  52840. * Get the class name of the relfection probe.
  52841. * @returns "ReflectionProbe"
  52842. */
  52843. getClassName(): string;
  52844. /**
  52845. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52846. * @returns The JSON representation of the texture
  52847. */
  52848. serialize(): any;
  52849. /**
  52850. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52851. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52852. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52853. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52854. * @returns The parsed reflection probe if successful
  52855. */
  52856. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52857. }
  52858. }
  52859. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52860. /** @hidden */
  52861. export var _BabylonLoaderRegistered: boolean;
  52862. }
  52863. declare module "babylonjs/Loading/Plugins/index" {
  52864. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52865. }
  52866. declare module "babylonjs/Loading/index" {
  52867. export * from "babylonjs/Loading/loadingScreen";
  52868. export * from "babylonjs/Loading/Plugins/index";
  52869. export * from "babylonjs/Loading/sceneLoader";
  52870. export * from "babylonjs/Loading/sceneLoaderFlags";
  52871. }
  52872. declare module "babylonjs/Materials/Background/index" {
  52873. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52874. }
  52875. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52876. import { Scene } from "babylonjs/scene";
  52877. import { Color3 } from "babylonjs/Maths/math.color";
  52878. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52880. /**
  52881. * The Physically based simple base material of BJS.
  52882. *
  52883. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52884. * It is used as the base class for both the specGloss and metalRough conventions.
  52885. */
  52886. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52887. /**
  52888. * Number of Simultaneous lights allowed on the material.
  52889. */
  52890. maxSimultaneousLights: number;
  52891. /**
  52892. * If sets to true, disables all the lights affecting the material.
  52893. */
  52894. disableLighting: boolean;
  52895. /**
  52896. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52897. */
  52898. environmentTexture: BaseTexture;
  52899. /**
  52900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52901. */
  52902. invertNormalMapX: boolean;
  52903. /**
  52904. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52905. */
  52906. invertNormalMapY: boolean;
  52907. /**
  52908. * Normal map used in the model.
  52909. */
  52910. normalTexture: BaseTexture;
  52911. /**
  52912. * Emissivie color used to self-illuminate the model.
  52913. */
  52914. emissiveColor: Color3;
  52915. /**
  52916. * Emissivie texture used to self-illuminate the model.
  52917. */
  52918. emissiveTexture: BaseTexture;
  52919. /**
  52920. * Occlusion Channel Strenght.
  52921. */
  52922. occlusionStrength: number;
  52923. /**
  52924. * Occlusion Texture of the material (adding extra occlusion effects).
  52925. */
  52926. occlusionTexture: BaseTexture;
  52927. /**
  52928. * Defines the alpha limits in alpha test mode.
  52929. */
  52930. alphaCutOff: number;
  52931. /**
  52932. * Gets the current double sided mode.
  52933. */
  52934. /**
  52935. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52936. */
  52937. doubleSided: boolean;
  52938. /**
  52939. * Stores the pre-calculated light information of a mesh in a texture.
  52940. */
  52941. lightmapTexture: BaseTexture;
  52942. /**
  52943. * If true, the light map contains occlusion information instead of lighting info.
  52944. */
  52945. useLightmapAsShadowmap: boolean;
  52946. /**
  52947. * Instantiates a new PBRMaterial instance.
  52948. *
  52949. * @param name The material name
  52950. * @param scene The scene the material will be use in.
  52951. */
  52952. constructor(name: string, scene: Scene);
  52953. getClassName(): string;
  52954. }
  52955. }
  52956. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52957. import { Scene } from "babylonjs/scene";
  52958. import { Color3 } from "babylonjs/Maths/math.color";
  52959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52960. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52961. /**
  52962. * The PBR material of BJS following the metal roughness convention.
  52963. *
  52964. * This fits to the PBR convention in the GLTF definition:
  52965. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52966. */
  52967. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52968. /**
  52969. * The base color has two different interpretations depending on the value of metalness.
  52970. * When the material is a metal, the base color is the specific measured reflectance value
  52971. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52972. * of the material.
  52973. */
  52974. baseColor: Color3;
  52975. /**
  52976. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52977. * well as opacity information in the alpha channel.
  52978. */
  52979. baseTexture: BaseTexture;
  52980. /**
  52981. * Specifies the metallic scalar value of the material.
  52982. * Can also be used to scale the metalness values of the metallic texture.
  52983. */
  52984. metallic: number;
  52985. /**
  52986. * Specifies the roughness scalar value of the material.
  52987. * Can also be used to scale the roughness values of the metallic texture.
  52988. */
  52989. roughness: number;
  52990. /**
  52991. * Texture containing both the metallic value in the B channel and the
  52992. * roughness value in the G channel to keep better precision.
  52993. */
  52994. metallicRoughnessTexture: BaseTexture;
  52995. /**
  52996. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52997. *
  52998. * @param name The material name
  52999. * @param scene The scene the material will be use in.
  53000. */
  53001. constructor(name: string, scene: Scene);
  53002. /**
  53003. * Return the currrent class name of the material.
  53004. */
  53005. getClassName(): string;
  53006. /**
  53007. * Makes a duplicate of the current material.
  53008. * @param name - name to use for the new material.
  53009. */
  53010. clone(name: string): PBRMetallicRoughnessMaterial;
  53011. /**
  53012. * Serialize the material to a parsable JSON object.
  53013. */
  53014. serialize(): any;
  53015. /**
  53016. * Parses a JSON object correponding to the serialize function.
  53017. */
  53018. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53019. }
  53020. }
  53021. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53022. import { Scene } from "babylonjs/scene";
  53023. import { Color3 } from "babylonjs/Maths/math.color";
  53024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53025. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53026. /**
  53027. * The PBR material of BJS following the specular glossiness convention.
  53028. *
  53029. * This fits to the PBR convention in the GLTF definition:
  53030. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53031. */
  53032. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53033. /**
  53034. * Specifies the diffuse color of the material.
  53035. */
  53036. diffuseColor: Color3;
  53037. /**
  53038. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53039. * channel.
  53040. */
  53041. diffuseTexture: BaseTexture;
  53042. /**
  53043. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53044. */
  53045. specularColor: Color3;
  53046. /**
  53047. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53048. */
  53049. glossiness: number;
  53050. /**
  53051. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53052. */
  53053. specularGlossinessTexture: BaseTexture;
  53054. /**
  53055. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53056. *
  53057. * @param name The material name
  53058. * @param scene The scene the material will be use in.
  53059. */
  53060. constructor(name: string, scene: Scene);
  53061. /**
  53062. * Return the currrent class name of the material.
  53063. */
  53064. getClassName(): string;
  53065. /**
  53066. * Makes a duplicate of the current material.
  53067. * @param name - name to use for the new material.
  53068. */
  53069. clone(name: string): PBRSpecularGlossinessMaterial;
  53070. /**
  53071. * Serialize the material to a parsable JSON object.
  53072. */
  53073. serialize(): any;
  53074. /**
  53075. * Parses a JSON object correponding to the serialize function.
  53076. */
  53077. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53078. }
  53079. }
  53080. declare module "babylonjs/Materials/PBR/index" {
  53081. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53082. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53083. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53084. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53085. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53086. }
  53087. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53088. import { Nullable } from "babylonjs/types";
  53089. import { Scene } from "babylonjs/scene";
  53090. import { Matrix } from "babylonjs/Maths/math.vector";
  53091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53092. /**
  53093. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53094. * It can help converting any input color in a desired output one. This can then be used to create effects
  53095. * from sepia, black and white to sixties or futuristic rendering...
  53096. *
  53097. * The only supported format is currently 3dl.
  53098. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53099. */
  53100. export class ColorGradingTexture extends BaseTexture {
  53101. /**
  53102. * The current texture matrix. (will always be identity in color grading texture)
  53103. */
  53104. private _textureMatrix;
  53105. /**
  53106. * The texture URL.
  53107. */
  53108. url: string;
  53109. /**
  53110. * Empty line regex stored for GC.
  53111. */
  53112. private static _noneEmptyLineRegex;
  53113. private _engine;
  53114. /**
  53115. * Instantiates a ColorGradingTexture from the following parameters.
  53116. *
  53117. * @param url The location of the color gradind data (currently only supporting 3dl)
  53118. * @param scene The scene the texture will be used in
  53119. */
  53120. constructor(url: string, scene: Scene);
  53121. /**
  53122. * Returns the texture matrix used in most of the material.
  53123. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53124. */
  53125. getTextureMatrix(): Matrix;
  53126. /**
  53127. * Occurs when the file being loaded is a .3dl LUT file.
  53128. */
  53129. private load3dlTexture;
  53130. /**
  53131. * Starts the loading process of the texture.
  53132. */
  53133. private loadTexture;
  53134. /**
  53135. * Clones the color gradind texture.
  53136. */
  53137. clone(): ColorGradingTexture;
  53138. /**
  53139. * Called during delayed load for textures.
  53140. */
  53141. delayLoad(): void;
  53142. /**
  53143. * Parses a color grading texture serialized by Babylon.
  53144. * @param parsedTexture The texture information being parsedTexture
  53145. * @param scene The scene to load the texture in
  53146. * @param rootUrl The root url of the data assets to load
  53147. * @return A color gradind texture
  53148. */
  53149. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53150. /**
  53151. * Serializes the LUT texture to json format.
  53152. */
  53153. serialize(): any;
  53154. }
  53155. }
  53156. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53158. import { Scene } from "babylonjs/scene";
  53159. import { Nullable } from "babylonjs/types";
  53160. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53161. /**
  53162. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53163. */
  53164. export class EquiRectangularCubeTexture extends BaseTexture {
  53165. /** The six faces of the cube. */
  53166. private static _FacesMapping;
  53167. private _noMipmap;
  53168. private _onLoad;
  53169. private _onError;
  53170. /** The size of the cubemap. */
  53171. private _size;
  53172. /** The buffer of the image. */
  53173. private _buffer;
  53174. /** The width of the input image. */
  53175. private _width;
  53176. /** The height of the input image. */
  53177. private _height;
  53178. /** The URL to the image. */
  53179. url: string;
  53180. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53181. coordinatesMode: number;
  53182. /**
  53183. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53184. * @param url The location of the image
  53185. * @param scene The scene the texture will be used in
  53186. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53187. * @param noMipmap Forces to not generate the mipmap if true
  53188. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53189. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53190. * @param onLoad — defines a callback called when texture is loaded
  53191. * @param onError — defines a callback called if there is an error
  53192. */
  53193. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53194. /**
  53195. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53196. */
  53197. private loadImage;
  53198. /**
  53199. * Convert the image buffer into a cubemap and create a CubeTexture.
  53200. */
  53201. private loadTexture;
  53202. /**
  53203. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53204. * @param buffer The ArrayBuffer that should be converted.
  53205. * @returns The buffer as Float32Array.
  53206. */
  53207. private getFloat32ArrayFromArrayBuffer;
  53208. /**
  53209. * Get the current class name of the texture useful for serialization or dynamic coding.
  53210. * @returns "EquiRectangularCubeTexture"
  53211. */
  53212. getClassName(): string;
  53213. /**
  53214. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53215. * @returns A clone of the current EquiRectangularCubeTexture.
  53216. */
  53217. clone(): EquiRectangularCubeTexture;
  53218. }
  53219. }
  53220. declare module "babylonjs/Misc/tga" {
  53221. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53222. /**
  53223. * Based on jsTGALoader - Javascript loader for TGA file
  53224. * By Vincent Thibault
  53225. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53226. */
  53227. export class TGATools {
  53228. private static _TYPE_INDEXED;
  53229. private static _TYPE_RGB;
  53230. private static _TYPE_GREY;
  53231. private static _TYPE_RLE_INDEXED;
  53232. private static _TYPE_RLE_RGB;
  53233. private static _TYPE_RLE_GREY;
  53234. private static _ORIGIN_MASK;
  53235. private static _ORIGIN_SHIFT;
  53236. private static _ORIGIN_BL;
  53237. private static _ORIGIN_BR;
  53238. private static _ORIGIN_UL;
  53239. private static _ORIGIN_UR;
  53240. /**
  53241. * Gets the header of a TGA file
  53242. * @param data defines the TGA data
  53243. * @returns the header
  53244. */
  53245. static GetTGAHeader(data: Uint8Array): any;
  53246. /**
  53247. * Uploads TGA content to a Babylon Texture
  53248. * @hidden
  53249. */
  53250. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53251. /** @hidden */
  53252. 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;
  53253. /** @hidden */
  53254. 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;
  53255. /** @hidden */
  53256. 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;
  53257. /** @hidden */
  53258. 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;
  53259. /** @hidden */
  53260. 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;
  53261. /** @hidden */
  53262. 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;
  53263. }
  53264. }
  53265. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53266. import { Nullable } from "babylonjs/types";
  53267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53268. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53269. /**
  53270. * Implementation of the TGA Texture Loader.
  53271. * @hidden
  53272. */
  53273. export class _TGATextureLoader implements IInternalTextureLoader {
  53274. /**
  53275. * Defines wether the loader supports cascade loading the different faces.
  53276. */
  53277. readonly supportCascades: boolean;
  53278. /**
  53279. * This returns if the loader support the current file information.
  53280. * @param extension defines the file extension of the file being loaded
  53281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53282. * @param fallback defines the fallback internal texture if any
  53283. * @param isBase64 defines whether the texture is encoded as a base64
  53284. * @param isBuffer defines whether the texture data are stored as a buffer
  53285. * @returns true if the loader can load the specified file
  53286. */
  53287. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53288. /**
  53289. * Transform the url before loading if required.
  53290. * @param rootUrl the url of the texture
  53291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53292. * @returns the transformed texture
  53293. */
  53294. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53295. /**
  53296. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53297. * @param rootUrl the url of the texture
  53298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53299. * @returns the fallback texture
  53300. */
  53301. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53302. /**
  53303. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53304. * @param data contains the texture data
  53305. * @param texture defines the BabylonJS internal texture
  53306. * @param createPolynomials will be true if polynomials have been requested
  53307. * @param onLoad defines the callback to trigger once the texture is ready
  53308. * @param onError defines the callback to trigger in case of error
  53309. */
  53310. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53311. /**
  53312. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53313. * @param data contains the texture data
  53314. * @param texture defines the BabylonJS internal texture
  53315. * @param callback defines the method to call once ready to upload
  53316. */
  53317. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53318. }
  53319. }
  53320. declare module "babylonjs/Misc/basis" {
  53321. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53322. /**
  53323. * Info about the .basis files
  53324. */
  53325. class BasisFileInfo {
  53326. /**
  53327. * If the file has alpha
  53328. */
  53329. hasAlpha: boolean;
  53330. /**
  53331. * Info about each image of the basis file
  53332. */
  53333. images: Array<{
  53334. levels: Array<{
  53335. width: number;
  53336. height: number;
  53337. transcodedPixels: ArrayBufferView;
  53338. }>;
  53339. }>;
  53340. }
  53341. /**
  53342. * Result of transcoding a basis file
  53343. */
  53344. class TranscodeResult {
  53345. /**
  53346. * Info about the .basis file
  53347. */
  53348. fileInfo: BasisFileInfo;
  53349. /**
  53350. * Format to use when loading the file
  53351. */
  53352. format: number;
  53353. }
  53354. /**
  53355. * Configuration options for the Basis transcoder
  53356. */
  53357. export class BasisTranscodeConfiguration {
  53358. /**
  53359. * Supported compression formats used to determine the supported output format of the transcoder
  53360. */
  53361. supportedCompressionFormats?: {
  53362. /**
  53363. * etc1 compression format
  53364. */
  53365. etc1?: boolean;
  53366. /**
  53367. * s3tc compression format
  53368. */
  53369. s3tc?: boolean;
  53370. /**
  53371. * pvrtc compression format
  53372. */
  53373. pvrtc?: boolean;
  53374. /**
  53375. * etc2 compression format
  53376. */
  53377. etc2?: boolean;
  53378. };
  53379. /**
  53380. * If mipmap levels should be loaded for transcoded images (Default: true)
  53381. */
  53382. loadMipmapLevels?: boolean;
  53383. /**
  53384. * Index of a single image to load (Default: all images)
  53385. */
  53386. loadSingleImage?: number;
  53387. }
  53388. /**
  53389. * Used to load .Basis files
  53390. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53391. */
  53392. export class BasisTools {
  53393. private static _IgnoreSupportedFormats;
  53394. /**
  53395. * URL to use when loading the basis transcoder
  53396. */
  53397. static JSModuleURL: string;
  53398. /**
  53399. * URL to use when loading the wasm module for the transcoder
  53400. */
  53401. static WasmModuleURL: string;
  53402. /**
  53403. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53404. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53405. * @returns internal format corresponding to the Basis format
  53406. */
  53407. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53408. private static _WorkerPromise;
  53409. private static _Worker;
  53410. private static _actionId;
  53411. private static _CreateWorkerAsync;
  53412. /**
  53413. * Transcodes a loaded image file to compressed pixel data
  53414. * @param imageData image data to transcode
  53415. * @param config configuration options for the transcoding
  53416. * @returns a promise resulting in the transcoded image
  53417. */
  53418. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53419. /**
  53420. * Loads a texture from the transcode result
  53421. * @param texture texture load to
  53422. * @param transcodeResult the result of transcoding the basis file to load from
  53423. */
  53424. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53425. }
  53426. }
  53427. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53428. import { Nullable } from "babylonjs/types";
  53429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53430. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53431. /**
  53432. * Loader for .basis file format
  53433. */
  53434. export class _BasisTextureLoader implements IInternalTextureLoader {
  53435. /**
  53436. * Defines whether the loader supports cascade loading the different faces.
  53437. */
  53438. readonly supportCascades: boolean;
  53439. /**
  53440. * This returns if the loader support the current file information.
  53441. * @param extension defines the file extension of the file being loaded
  53442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53443. * @param fallback defines the fallback internal texture if any
  53444. * @param isBase64 defines whether the texture is encoded as a base64
  53445. * @param isBuffer defines whether the texture data are stored as a buffer
  53446. * @returns true if the loader can load the specified file
  53447. */
  53448. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53449. /**
  53450. * Transform the url before loading if required.
  53451. * @param rootUrl the url of the texture
  53452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53453. * @returns the transformed texture
  53454. */
  53455. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53456. /**
  53457. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53458. * @param rootUrl the url of the texture
  53459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53460. * @returns the fallback texture
  53461. */
  53462. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53463. /**
  53464. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53465. * @param data contains the texture data
  53466. * @param texture defines the BabylonJS internal texture
  53467. * @param createPolynomials will be true if polynomials have been requested
  53468. * @param onLoad defines the callback to trigger once the texture is ready
  53469. * @param onError defines the callback to trigger in case of error
  53470. */
  53471. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53472. /**
  53473. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53474. * @param data contains the texture data
  53475. * @param texture defines the BabylonJS internal texture
  53476. * @param callback defines the method to call once ready to upload
  53477. */
  53478. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53479. }
  53480. }
  53481. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53482. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53483. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53484. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53485. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53486. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53487. }
  53488. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53489. import { Scene } from "babylonjs/scene";
  53490. import { Texture } from "babylonjs/Materials/Textures/texture";
  53491. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53492. /**
  53493. * 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.
  53494. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53495. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53496. */
  53497. export class CustomProceduralTexture extends ProceduralTexture {
  53498. private _animate;
  53499. private _time;
  53500. private _config;
  53501. private _texturePath;
  53502. /**
  53503. * Instantiates a new Custom Procedural Texture.
  53504. * 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.
  53505. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53506. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53507. * @param name Define the name of the texture
  53508. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53509. * @param size Define the size of the texture to create
  53510. * @param scene Define the scene the texture belongs to
  53511. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53512. * @param generateMipMaps Define if the texture should creates mip maps or not
  53513. */
  53514. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53515. private _loadJson;
  53516. /**
  53517. * Is the texture ready to be used ? (rendered at least once)
  53518. * @returns true if ready, otherwise, false.
  53519. */
  53520. isReady(): boolean;
  53521. /**
  53522. * Render the texture to its associated render target.
  53523. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53524. */
  53525. render(useCameraPostProcess?: boolean): void;
  53526. /**
  53527. * Update the list of dependant textures samplers in the shader.
  53528. */
  53529. updateTextures(): void;
  53530. /**
  53531. * Update the uniform values of the procedural texture in the shader.
  53532. */
  53533. updateShaderUniforms(): void;
  53534. /**
  53535. * Define if the texture animates or not.
  53536. */
  53537. animate: boolean;
  53538. }
  53539. }
  53540. declare module "babylonjs/Shaders/noise.fragment" {
  53541. /** @hidden */
  53542. export var noisePixelShader: {
  53543. name: string;
  53544. shader: string;
  53545. };
  53546. }
  53547. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53548. import { Nullable } from "babylonjs/types";
  53549. import { Scene } from "babylonjs/scene";
  53550. import { Texture } from "babylonjs/Materials/Textures/texture";
  53551. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53552. import "babylonjs/Shaders/noise.fragment";
  53553. /**
  53554. * Class used to generate noise procedural textures
  53555. */
  53556. export class NoiseProceduralTexture extends ProceduralTexture {
  53557. private _time;
  53558. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53559. brightness: number;
  53560. /** Defines the number of octaves to process */
  53561. octaves: number;
  53562. /** Defines the level of persistence (0.8 by default) */
  53563. persistence: number;
  53564. /** Gets or sets animation speed factor (default is 1) */
  53565. animationSpeedFactor: number;
  53566. /**
  53567. * Creates a new NoiseProceduralTexture
  53568. * @param name defines the name fo the texture
  53569. * @param size defines the size of the texture (default is 256)
  53570. * @param scene defines the hosting scene
  53571. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53572. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53573. */
  53574. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53575. private _updateShaderUniforms;
  53576. protected _getDefines(): string;
  53577. /** Generate the current state of the procedural texture */
  53578. render(useCameraPostProcess?: boolean): void;
  53579. /**
  53580. * Serializes this noise procedural texture
  53581. * @returns a serialized noise procedural texture object
  53582. */
  53583. serialize(): any;
  53584. /**
  53585. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53586. * @param parsedTexture defines parsed texture data
  53587. * @param scene defines the current scene
  53588. * @param rootUrl defines the root URL containing noise procedural texture information
  53589. * @returns a parsed NoiseProceduralTexture
  53590. */
  53591. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53592. }
  53593. }
  53594. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53595. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53596. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53597. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53598. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53599. }
  53600. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53601. import { Nullable } from "babylonjs/types";
  53602. import { Scene } from "babylonjs/scene";
  53603. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53605. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53606. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53607. /**
  53608. * Raw cube texture where the raw buffers are passed in
  53609. */
  53610. export class RawCubeTexture extends CubeTexture {
  53611. /**
  53612. * Creates a cube texture where the raw buffers are passed in.
  53613. * @param scene defines the scene the texture is attached to
  53614. * @param data defines the array of data to use to create each face
  53615. * @param size defines the size of the textures
  53616. * @param format defines the format of the data
  53617. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53618. * @param generateMipMaps defines if the engine should generate the mip levels
  53619. * @param invertY defines if data must be stored with Y axis inverted
  53620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53621. * @param compression defines the compression used (null by default)
  53622. */
  53623. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53624. /**
  53625. * Updates the raw cube texture.
  53626. * @param data defines the data to store
  53627. * @param format defines the data format
  53628. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53629. * @param invertY defines if data must be stored with Y axis inverted
  53630. * @param compression defines the compression used (null by default)
  53631. * @param level defines which level of the texture to update
  53632. */
  53633. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53634. /**
  53635. * Updates a raw cube texture with RGBD encoded data.
  53636. * @param data defines the array of data [mipmap][face] to use to create each face
  53637. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53638. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53639. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53640. * @returns a promsie that resolves when the operation is complete
  53641. */
  53642. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53643. /**
  53644. * Clones the raw cube texture.
  53645. * @return a new cube texture
  53646. */
  53647. clone(): CubeTexture;
  53648. /** @hidden */
  53649. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53650. }
  53651. }
  53652. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53653. import { Scene } from "babylonjs/scene";
  53654. import { Texture } from "babylonjs/Materials/Textures/texture";
  53655. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53656. /**
  53657. * Class used to store 3D textures containing user data
  53658. */
  53659. export class RawTexture3D extends Texture {
  53660. /** Gets or sets the texture format to use */
  53661. format: number;
  53662. private _engine;
  53663. /**
  53664. * Create a new RawTexture3D
  53665. * @param data defines the data of the texture
  53666. * @param width defines the width of the texture
  53667. * @param height defines the height of the texture
  53668. * @param depth defines the depth of the texture
  53669. * @param format defines the texture format to use
  53670. * @param scene defines the hosting scene
  53671. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53672. * @param invertY defines if texture must be stored with Y axis inverted
  53673. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53674. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53675. */
  53676. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53677. /** Gets or sets the texture format to use */
  53678. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53679. /**
  53680. * Update the texture with new data
  53681. * @param data defines the data to store in the texture
  53682. */
  53683. update(data: ArrayBufferView): void;
  53684. }
  53685. }
  53686. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53687. import { Scene } from "babylonjs/scene";
  53688. import { Plane } from "babylonjs/Maths/math.plane";
  53689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53690. /**
  53691. * Creates a refraction texture used by refraction channel of the standard material.
  53692. * It is like a mirror but to see through a material.
  53693. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53694. */
  53695. export class RefractionTexture extends RenderTargetTexture {
  53696. /**
  53697. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53698. * 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.
  53699. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53700. */
  53701. refractionPlane: Plane;
  53702. /**
  53703. * Define how deep under the surface we should see.
  53704. */
  53705. depth: number;
  53706. /**
  53707. * Creates a refraction texture used by refraction channel of the standard material.
  53708. * It is like a mirror but to see through a material.
  53709. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53710. * @param name Define the texture name
  53711. * @param size Define the size of the underlying texture
  53712. * @param scene Define the scene the refraction belongs to
  53713. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53714. */
  53715. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53716. /**
  53717. * Clone the refraction texture.
  53718. * @returns the cloned texture
  53719. */
  53720. clone(): RefractionTexture;
  53721. /**
  53722. * Serialize the texture to a JSON representation you could use in Parse later on
  53723. * @returns the serialized JSON representation
  53724. */
  53725. serialize(): any;
  53726. }
  53727. }
  53728. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53729. import { Nullable } from "babylonjs/types";
  53730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53731. import { Matrix } from "babylonjs/Maths/math.vector";
  53732. import { Engine } from "babylonjs/Engines/engine";
  53733. import { Scene } from "babylonjs/scene";
  53734. /**
  53735. * Defines the options related to the creation of an HtmlElementTexture
  53736. */
  53737. export interface IHtmlElementTextureOptions {
  53738. /**
  53739. * Defines wether mip maps should be created or not.
  53740. */
  53741. generateMipMaps?: boolean;
  53742. /**
  53743. * Defines the sampling mode of the texture.
  53744. */
  53745. samplingMode?: number;
  53746. /**
  53747. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53748. */
  53749. engine: Nullable<Engine>;
  53750. /**
  53751. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53752. */
  53753. scene: Nullable<Scene>;
  53754. }
  53755. /**
  53756. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53757. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53758. * is automatically managed.
  53759. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53760. * in your application.
  53761. *
  53762. * As the update is not automatic, you need to call them manually.
  53763. */
  53764. export class HtmlElementTexture extends BaseTexture {
  53765. /**
  53766. * The texture URL.
  53767. */
  53768. element: HTMLVideoElement | HTMLCanvasElement;
  53769. private static readonly DefaultOptions;
  53770. private _textureMatrix;
  53771. private _engine;
  53772. private _isVideo;
  53773. private _generateMipMaps;
  53774. private _samplingMode;
  53775. /**
  53776. * Instantiates a HtmlElementTexture from the following parameters.
  53777. *
  53778. * @param name Defines the name of the texture
  53779. * @param element Defines the video or canvas the texture is filled with
  53780. * @param options Defines the other none mandatory texture creation options
  53781. */
  53782. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53783. private _createInternalTexture;
  53784. /**
  53785. * Returns the texture matrix used in most of the material.
  53786. */
  53787. getTextureMatrix(): Matrix;
  53788. /**
  53789. * Updates the content of the texture.
  53790. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53791. */
  53792. update(invertY?: Nullable<boolean>): void;
  53793. }
  53794. }
  53795. declare module "babylonjs/Materials/Textures/index" {
  53796. export * from "babylonjs/Materials/Textures/baseTexture";
  53797. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53798. export * from "babylonjs/Materials/Textures/cubeTexture";
  53799. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53800. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53801. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53802. export * from "babylonjs/Materials/Textures/internalTexture";
  53803. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53804. export * from "babylonjs/Materials/Textures/Loaders/index";
  53805. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53806. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53807. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53808. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53809. export * from "babylonjs/Materials/Textures/rawTexture";
  53810. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53811. export * from "babylonjs/Materials/Textures/refractionTexture";
  53812. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53813. export * from "babylonjs/Materials/Textures/texture";
  53814. export * from "babylonjs/Materials/Textures/videoTexture";
  53815. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53816. }
  53817. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53818. /**
  53819. * Enum used to define the target of a block
  53820. */
  53821. export enum NodeMaterialBlockTargets {
  53822. /** Vertex shader */
  53823. Vertex = 1,
  53824. /** Fragment shader */
  53825. Fragment = 2,
  53826. /** Neutral */
  53827. Neutral = 4,
  53828. /** Vertex and Fragment */
  53829. VertexAndFragment = 3
  53830. }
  53831. }
  53832. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53833. /**
  53834. * Defines the kind of connection point for node based material
  53835. */
  53836. export enum NodeMaterialBlockConnectionPointTypes {
  53837. /** Float */
  53838. Float = 1,
  53839. /** Int */
  53840. Int = 2,
  53841. /** Vector2 */
  53842. Vector2 = 4,
  53843. /** Vector3 */
  53844. Vector3 = 8,
  53845. /** Vector4 */
  53846. Vector4 = 16,
  53847. /** Color3 */
  53848. Color3 = 32,
  53849. /** Color4 */
  53850. Color4 = 64,
  53851. /** Matrix */
  53852. Matrix = 128,
  53853. /** Detect type based on connection */
  53854. AutoDetect = 1024,
  53855. /** Output type that will be defined by input type */
  53856. BasedOnInput = 2048
  53857. }
  53858. }
  53859. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53861. /**
  53862. * Root class for all node material optimizers
  53863. */
  53864. export class NodeMaterialOptimizer {
  53865. /**
  53866. * Function used to optimize a NodeMaterial graph
  53867. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53868. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53869. */
  53870. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53871. }
  53872. }
  53873. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53877. import { Scene } from "babylonjs/scene";
  53878. /**
  53879. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53880. */
  53881. export class TransformBlock extends NodeMaterialBlock {
  53882. /**
  53883. * Defines the value to use to complement W value to transform it to a Vector4
  53884. */
  53885. complementW: number;
  53886. /**
  53887. * Defines the value to use to complement z value to transform it to a Vector4
  53888. */
  53889. complementZ: number;
  53890. /**
  53891. * Creates a new TransformBlock
  53892. * @param name defines the block name
  53893. */
  53894. constructor(name: string);
  53895. /**
  53896. * Gets the current class name
  53897. * @returns the class name
  53898. */
  53899. getClassName(): string;
  53900. /**
  53901. * Gets the vector input
  53902. */
  53903. readonly vector: NodeMaterialConnectionPoint;
  53904. /**
  53905. * Gets the output component
  53906. */
  53907. readonly output: NodeMaterialConnectionPoint;
  53908. /**
  53909. * Gets the matrix transform input
  53910. */
  53911. readonly transform: NodeMaterialConnectionPoint;
  53912. protected _buildBlock(state: NodeMaterialBuildState): this;
  53913. serialize(): any;
  53914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53915. }
  53916. }
  53917. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53921. /**
  53922. * Block used to output the vertex position
  53923. */
  53924. export class VertexOutputBlock extends NodeMaterialBlock {
  53925. /**
  53926. * Creates a new VertexOutputBlock
  53927. * @param name defines the block name
  53928. */
  53929. constructor(name: string);
  53930. /**
  53931. * Gets the current class name
  53932. * @returns the class name
  53933. */
  53934. getClassName(): string;
  53935. /**
  53936. * Gets the vector input component
  53937. */
  53938. readonly vector: NodeMaterialConnectionPoint;
  53939. protected _buildBlock(state: NodeMaterialBuildState): this;
  53940. }
  53941. }
  53942. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53946. /**
  53947. * Block used to output the final color
  53948. */
  53949. export class FragmentOutputBlock extends NodeMaterialBlock {
  53950. /**
  53951. * Create a new FragmentOutputBlock
  53952. * @param name defines the block name
  53953. */
  53954. constructor(name: string);
  53955. /**
  53956. * Gets the current class name
  53957. * @returns the class name
  53958. */
  53959. getClassName(): string;
  53960. /**
  53961. * Gets the rgba input component
  53962. */
  53963. readonly rgba: NodeMaterialConnectionPoint;
  53964. /**
  53965. * Gets the rgb input component
  53966. */
  53967. readonly rgb: NodeMaterialConnectionPoint;
  53968. /**
  53969. * Gets the a input component
  53970. */
  53971. readonly a: NodeMaterialConnectionPoint;
  53972. protected _buildBlock(state: NodeMaterialBuildState): this;
  53973. }
  53974. }
  53975. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53977. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53978. import { Scene } from "babylonjs/scene";
  53979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53980. import { Matrix } from "babylonjs/Maths/math.vector";
  53981. import { Mesh } from "babylonjs/Meshes/mesh";
  53982. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53983. import { Observable } from "babylonjs/Misc/observable";
  53984. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53985. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53986. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53987. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53988. import { Nullable } from "babylonjs/types";
  53989. /**
  53990. * Interface used to configure the node material editor
  53991. */
  53992. export interface INodeMaterialEditorOptions {
  53993. /** Define the URl to load node editor script */
  53994. editorURL?: string;
  53995. }
  53996. /** @hidden */
  53997. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53998. /** BONES */
  53999. NUM_BONE_INFLUENCERS: number;
  54000. BonesPerMesh: number;
  54001. BONETEXTURE: boolean;
  54002. /** MORPH TARGETS */
  54003. MORPHTARGETS: boolean;
  54004. MORPHTARGETS_NORMAL: boolean;
  54005. MORPHTARGETS_TANGENT: boolean;
  54006. MORPHTARGETS_UV: boolean;
  54007. NUM_MORPH_INFLUENCERS: number;
  54008. /** IMAGE PROCESSING */
  54009. IMAGEPROCESSING: boolean;
  54010. VIGNETTE: boolean;
  54011. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54012. VIGNETTEBLENDMODEOPAQUE: boolean;
  54013. TONEMAPPING: boolean;
  54014. TONEMAPPING_ACES: boolean;
  54015. CONTRAST: boolean;
  54016. EXPOSURE: boolean;
  54017. COLORCURVES: boolean;
  54018. COLORGRADING: boolean;
  54019. COLORGRADING3D: boolean;
  54020. SAMPLER3DGREENDEPTH: boolean;
  54021. SAMPLER3DBGRMAP: boolean;
  54022. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54023. constructor();
  54024. setValue(name: string, value: boolean): void;
  54025. }
  54026. /**
  54027. * Class used to configure NodeMaterial
  54028. */
  54029. export interface INodeMaterialOptions {
  54030. /**
  54031. * Defines if blocks should emit comments
  54032. */
  54033. emitComments: boolean;
  54034. }
  54035. /**
  54036. * Class used to create a node based material built by assembling shader blocks
  54037. */
  54038. export class NodeMaterial extends PushMaterial {
  54039. private static _BuildIdGenerator;
  54040. private _options;
  54041. private _vertexCompilationState;
  54042. private _fragmentCompilationState;
  54043. private _sharedData;
  54044. private _buildId;
  54045. private _buildWasSuccessful;
  54046. private _cachedWorldViewMatrix;
  54047. private _cachedWorldViewProjectionMatrix;
  54048. private _optimizers;
  54049. /** Define the URl to load node editor script */
  54050. static EditorURL: string;
  54051. private BJSNODEMATERIALEDITOR;
  54052. /** Get the inspector from bundle or global */
  54053. private _getGlobalNodeMaterialEditor;
  54054. /**
  54055. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  54056. */
  54057. ignoreAlpha: boolean;
  54058. /**
  54059. * Defines the maximum number of lights that can be used in the material
  54060. */
  54061. maxSimultaneousLights: number;
  54062. /**
  54063. * Observable raised when the material is built
  54064. */
  54065. onBuildObservable: Observable<NodeMaterial>;
  54066. /**
  54067. * Gets or sets the root nodes of the material vertex shader
  54068. */
  54069. _vertexOutputNodes: NodeMaterialBlock[];
  54070. /**
  54071. * Gets or sets the root nodes of the material fragment (pixel) shader
  54072. */
  54073. _fragmentOutputNodes: NodeMaterialBlock[];
  54074. /** Gets or sets options to control the node material overall behavior */
  54075. options: INodeMaterialOptions;
  54076. /**
  54077. * Default configuration related to image processing available in the standard Material.
  54078. */
  54079. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54080. /**
  54081. * Gets the image processing configuration used either in this material.
  54082. */
  54083. /**
  54084. * Sets the Default image processing configuration used either in the this material.
  54085. *
  54086. * If sets to null, the scene one is in use.
  54087. */
  54088. imageProcessingConfiguration: ImageProcessingConfiguration;
  54089. /**
  54090. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54091. */
  54092. attachedBlocks: NodeMaterialBlock[];
  54093. /**
  54094. * Create a new node based material
  54095. * @param name defines the material name
  54096. * @param scene defines the hosting scene
  54097. * @param options defines creation option
  54098. */
  54099. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54100. /**
  54101. * Gets the current class name of the material e.g. "NodeMaterial"
  54102. * @returns the class name
  54103. */
  54104. getClassName(): string;
  54105. /**
  54106. * Keep track of the image processing observer to allow dispose and replace.
  54107. */
  54108. private _imageProcessingObserver;
  54109. /**
  54110. * Attaches a new image processing configuration to the Standard Material.
  54111. * @param configuration
  54112. */
  54113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54114. /**
  54115. * Adds a new optimizer to the list of optimizers
  54116. * @param optimizer defines the optimizers to add
  54117. * @returns the current material
  54118. */
  54119. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54120. /**
  54121. * Remove an optimizer from the list of optimizers
  54122. * @param optimizer defines the optimizers to remove
  54123. * @returns the current material
  54124. */
  54125. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54126. /**
  54127. * Add a new block to the list of output nodes
  54128. * @param node defines the node to add
  54129. * @returns the current material
  54130. */
  54131. addOutputNode(node: NodeMaterialBlock): this;
  54132. /**
  54133. * Remove a block from the list of root nodes
  54134. * @param node defines the node to remove
  54135. * @returns the current material
  54136. */
  54137. removeOutputNode(node: NodeMaterialBlock): this;
  54138. private _addVertexOutputNode;
  54139. private _removeVertexOutputNode;
  54140. private _addFragmentOutputNode;
  54141. private _removeFragmentOutputNode;
  54142. /**
  54143. * Specifies if the material will require alpha blending
  54144. * @returns a boolean specifying if alpha blending is needed
  54145. */
  54146. needAlphaBlending(): boolean;
  54147. /**
  54148. * Specifies if this material should be rendered in alpha test mode
  54149. * @returns a boolean specifying if an alpha test is needed.
  54150. */
  54151. needAlphaTesting(): boolean;
  54152. private _initializeBlock;
  54153. private _resetDualBlocks;
  54154. /**
  54155. * Build the material and generates the inner effect
  54156. * @param verbose defines if the build should log activity
  54157. */
  54158. build(verbose?: boolean): void;
  54159. /**
  54160. * Runs an otpimization phase to try to improve the shader code
  54161. */
  54162. optimize(): void;
  54163. private _prepareDefinesForAttributes;
  54164. /**
  54165. * Get if the submesh is ready to be used and all its information available.
  54166. * Child classes can use it to update shaders
  54167. * @param mesh defines the mesh to check
  54168. * @param subMesh defines which submesh to check
  54169. * @param useInstances specifies that instances should be used
  54170. * @returns a boolean indicating that the submesh is ready or not
  54171. */
  54172. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54173. /**
  54174. * Get a string representing the shaders built by the current node graph
  54175. */
  54176. readonly compiledShaders: string;
  54177. /**
  54178. * Binds the world matrix to the material
  54179. * @param world defines the world transformation matrix
  54180. */
  54181. bindOnlyWorldMatrix(world: Matrix): void;
  54182. /**
  54183. * Binds the submesh to this material by preparing the effect and shader to draw
  54184. * @param world defines the world transformation matrix
  54185. * @param mesh defines the mesh containing the submesh
  54186. * @param subMesh defines the submesh to bind the material to
  54187. */
  54188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54189. /**
  54190. * Gets the active textures from the material
  54191. * @returns an array of textures
  54192. */
  54193. getActiveTextures(): BaseTexture[];
  54194. /**
  54195. * Specifies if the material uses a texture
  54196. * @param texture defines the texture to check against the material
  54197. * @returns a boolean specifying if the material uses the texture
  54198. */
  54199. hasTexture(texture: BaseTexture): boolean;
  54200. /**
  54201. * Disposes the material
  54202. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54203. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54204. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54205. */
  54206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54207. /** Creates the node editor window. */
  54208. private _createNodeEditor;
  54209. /**
  54210. * Launch the node material editor
  54211. * @param config Define the configuration of the editor
  54212. * @return a promise fulfilled when the node editor is visible
  54213. */
  54214. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54215. /**
  54216. * Clear the current material
  54217. */
  54218. clear(): void;
  54219. /**
  54220. * Clear the current material and set it to a default state
  54221. */
  54222. setToDefault(): void;
  54223. private _gatherBlocks;
  54224. /**
  54225. * Serializes this material in a JSON representation
  54226. * @returns the serialized material object
  54227. */
  54228. serialize(): any;
  54229. /**
  54230. * Clear the current graph and load a new one from a serialization object
  54231. * @param source defines the JSON representation of the material
  54232. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54233. */
  54234. loadFromSerialization(source: any, rootUrl?: string): void;
  54235. /**
  54236. * Creates a node material from parsed material data
  54237. * @param source defines the JSON representation of the material
  54238. * @param scene defines the hosting scene
  54239. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54240. * @returns a new node material
  54241. */
  54242. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54243. }
  54244. }
  54245. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54251. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54252. import { Effect } from "babylonjs/Materials/effect";
  54253. import { Mesh } from "babylonjs/Meshes/mesh";
  54254. import { Nullable } from "babylonjs/types";
  54255. import { Scene } from "babylonjs/scene";
  54256. /**
  54257. * Block used to read a texture from a sampler
  54258. */
  54259. export class TextureBlock extends NodeMaterialBlock {
  54260. private _defineName;
  54261. private _samplerName;
  54262. private _transformedUVName;
  54263. private _textureTransformName;
  54264. private _textureInfoName;
  54265. private _mainUVName;
  54266. private _mainUVDefineName;
  54267. /**
  54268. * Gets or sets the texture associated with the node
  54269. */
  54270. texture: Nullable<BaseTexture>;
  54271. /**
  54272. * Create a new TextureBlock
  54273. * @param name defines the block name
  54274. */
  54275. constructor(name: string);
  54276. /**
  54277. * Gets the current class name
  54278. * @returns the class name
  54279. */
  54280. getClassName(): string;
  54281. /**
  54282. * Gets the uv input component
  54283. */
  54284. readonly uv: NodeMaterialConnectionPoint;
  54285. /**
  54286. * Gets the output component
  54287. */
  54288. readonly output: NodeMaterialConnectionPoint;
  54289. autoConfigure(): void;
  54290. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54292. isReady(): boolean;
  54293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54294. private _injectVertexCode;
  54295. private _writeOutput;
  54296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54297. serialize(): any;
  54298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54299. }
  54300. }
  54301. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54303. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54304. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54305. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54306. /**
  54307. * Class used to store shared data between 2 NodeMaterialBuildState
  54308. */
  54309. export class NodeMaterialBuildStateSharedData {
  54310. /**
  54311. * Gets the list of emitted varyings
  54312. */
  54313. varyings: string[];
  54314. /**
  54315. * Gets the varying declaration string
  54316. */
  54317. varyingDeclaration: string;
  54318. /**
  54319. * Input blocks
  54320. */
  54321. inputBlocks: InputBlock[];
  54322. /**
  54323. * Input blocks
  54324. */
  54325. textureBlocks: TextureBlock[];
  54326. /**
  54327. * Bindable blocks (Blocks that need to set data to the effect)
  54328. */
  54329. bindableBlocks: NodeMaterialBlock[];
  54330. /**
  54331. * List of blocks that can provide a compilation fallback
  54332. */
  54333. blocksWithFallbacks: NodeMaterialBlock[];
  54334. /**
  54335. * List of blocks that can provide a define update
  54336. */
  54337. blocksWithDefines: NodeMaterialBlock[];
  54338. /**
  54339. * List of blocks that can provide a repeatable content
  54340. */
  54341. repeatableContentBlocks: NodeMaterialBlock[];
  54342. /**
  54343. * List of blocks that can provide a dynamic list of uniforms
  54344. */
  54345. dynamicUniformBlocks: NodeMaterialBlock[];
  54346. /**
  54347. * List of blocks that can block the isReady function for the material
  54348. */
  54349. blockingBlocks: NodeMaterialBlock[];
  54350. /**
  54351. * Build Id used to avoid multiple recompilations
  54352. */
  54353. buildId: number;
  54354. /** List of emitted variables */
  54355. variableNames: {
  54356. [key: string]: number;
  54357. };
  54358. /** List of emitted defines */
  54359. defineNames: {
  54360. [key: string]: number;
  54361. };
  54362. /** Should emit comments? */
  54363. emitComments: boolean;
  54364. /** Emit build activity */
  54365. verbose: boolean;
  54366. /**
  54367. * Gets the compilation hints emitted at compilation time
  54368. */
  54369. hints: {
  54370. needWorldViewMatrix: boolean;
  54371. needWorldViewProjectionMatrix: boolean;
  54372. needAlphaBlending: boolean;
  54373. needAlphaTesting: boolean;
  54374. };
  54375. /**
  54376. * List of compilation checks
  54377. */
  54378. checks: {
  54379. emitVertex: boolean;
  54380. emitFragment: boolean;
  54381. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54382. };
  54383. /** Creates a new shared data */
  54384. constructor();
  54385. /**
  54386. * Emits console errors and exceptions if there is a failing check
  54387. */
  54388. emitErrors(): void;
  54389. }
  54390. }
  54391. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54392. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54393. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54394. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54395. /**
  54396. * Class used to store node based material build state
  54397. */
  54398. export class NodeMaterialBuildState {
  54399. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54400. supportUniformBuffers: boolean;
  54401. /**
  54402. * Gets the list of emitted attributes
  54403. */
  54404. attributes: string[];
  54405. /**
  54406. * Gets the list of emitted uniforms
  54407. */
  54408. uniforms: string[];
  54409. /**
  54410. * Gets the list of emitted uniform buffers
  54411. */
  54412. uniformBuffers: string[];
  54413. /**
  54414. * Gets the list of emitted samplers
  54415. */
  54416. samplers: string[];
  54417. /**
  54418. * Gets the list of emitted functions
  54419. */
  54420. functions: {
  54421. [key: string]: string;
  54422. };
  54423. /**
  54424. * Gets the target of the compilation state
  54425. */
  54426. target: NodeMaterialBlockTargets;
  54427. /**
  54428. * Gets the list of emitted counters
  54429. */
  54430. counters: {
  54431. [key: string]: number;
  54432. };
  54433. /**
  54434. * Shared data between multiple NodeMaterialBuildState instances
  54435. */
  54436. sharedData: NodeMaterialBuildStateSharedData;
  54437. /** @hidden */
  54438. _vertexState: NodeMaterialBuildState;
  54439. /** @hidden */
  54440. _attributeDeclaration: string;
  54441. /** @hidden */
  54442. _uniformDeclaration: string;
  54443. /** @hidden */
  54444. _samplerDeclaration: string;
  54445. /** @hidden */
  54446. _varyingTransfer: string;
  54447. private _repeatableContentAnchorIndex;
  54448. /** @hidden */
  54449. _builtCompilationString: string;
  54450. /**
  54451. * Gets the emitted compilation strings
  54452. */
  54453. compilationString: string;
  54454. /**
  54455. * Finalize the compilation strings
  54456. * @param state defines the current compilation state
  54457. */
  54458. finalize(state: NodeMaterialBuildState): void;
  54459. /** @hidden */
  54460. readonly _repeatableContentAnchor: string;
  54461. /** @hidden */
  54462. _getFreeVariableName(prefix: string): string;
  54463. /** @hidden */
  54464. _getFreeDefineName(prefix: string): string;
  54465. /** @hidden */
  54466. _excludeVariableName(name: string): void;
  54467. /** @hidden */
  54468. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54469. /** @hidden */
  54470. _emitFunction(name: string, code: string, comments: string): void;
  54471. /** @hidden */
  54472. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54473. replaceStrings?: {
  54474. search: RegExp;
  54475. replace: string;
  54476. }[];
  54477. repeatKey?: string;
  54478. }): string;
  54479. /** @hidden */
  54480. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54481. repeatKey?: string;
  54482. removeAttributes?: boolean;
  54483. removeUniforms?: boolean;
  54484. removeVaryings?: boolean;
  54485. removeIfDef?: boolean;
  54486. replaceStrings?: {
  54487. search: RegExp;
  54488. replace: string;
  54489. }[];
  54490. }, storeKey?: string): void;
  54491. /** @hidden */
  54492. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54493. /** @hidden */
  54494. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54495. }
  54496. }
  54497. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54498. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54500. import { Nullable } from "babylonjs/types";
  54501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54502. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54503. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54505. import { Mesh } from "babylonjs/Meshes/mesh";
  54506. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54507. import { Scene } from "babylonjs/scene";
  54508. /**
  54509. * Defines a block that can be used inside a node based material
  54510. */
  54511. export class NodeMaterialBlock {
  54512. private _buildId;
  54513. private _buildTarget;
  54514. private _target;
  54515. private _isFinalMerger;
  54516. private _isInput;
  54517. /** @hidden */
  54518. _inputs: NodeMaterialConnectionPoint[];
  54519. /** @hidden */
  54520. _outputs: NodeMaterialConnectionPoint[];
  54521. /**
  54522. * Gets or sets the name of the block
  54523. */
  54524. name: string;
  54525. /**
  54526. * Gets or sets the unique id of the node
  54527. */
  54528. uniqueId: number;
  54529. /**
  54530. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54531. */
  54532. readonly isFinalMerger: boolean;
  54533. /**
  54534. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54535. */
  54536. readonly isInput: boolean;
  54537. /**
  54538. * Gets or sets the build Id
  54539. */
  54540. buildId: number;
  54541. /**
  54542. * Gets or sets the target of the block
  54543. */
  54544. target: NodeMaterialBlockTargets;
  54545. /**
  54546. * Gets the list of input points
  54547. */
  54548. readonly inputs: NodeMaterialConnectionPoint[];
  54549. /** Gets the list of output points */
  54550. readonly outputs: NodeMaterialConnectionPoint[];
  54551. /**
  54552. * Find an input by its name
  54553. * @param name defines the name of the input to look for
  54554. * @returns the input or null if not found
  54555. */
  54556. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54557. /**
  54558. * Find an output by its name
  54559. * @param name defines the name of the outputto look for
  54560. * @returns the output or null if not found
  54561. */
  54562. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54563. /**
  54564. * Creates a new NodeMaterialBlock
  54565. * @param name defines the block name
  54566. * @param target defines the target of that block (Vertex by default)
  54567. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54568. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54569. */
  54570. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54571. /**
  54572. * Initialize the block and prepare the context for build
  54573. * @param state defines the state that will be used for the build
  54574. */
  54575. initialize(state: NodeMaterialBuildState): void;
  54576. /**
  54577. * Bind data to effect. Will only be called for blocks with isBindable === true
  54578. * @param effect defines the effect to bind data to
  54579. * @param nodeMaterial defines the hosting NodeMaterial
  54580. * @param mesh defines the mesh that will be rendered
  54581. */
  54582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54583. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54584. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54585. protected _writeFloat(value: number): string;
  54586. /**
  54587. * Gets the current class name e.g. "NodeMaterialBlock"
  54588. * @returns the class name
  54589. */
  54590. getClassName(): string;
  54591. /**
  54592. * Register a new input. Must be called inside a block constructor
  54593. * @param name defines the connection point name
  54594. * @param type defines the connection point type
  54595. * @param isOptional defines a boolean indicating that this input can be omitted
  54596. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54597. * @returns the current block
  54598. */
  54599. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54600. /**
  54601. * Register a new output. Must be called inside a block constructor
  54602. * @param name defines the connection point name
  54603. * @param type defines the connection point type
  54604. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54605. * @returns the current block
  54606. */
  54607. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54608. /**
  54609. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54610. * @param forOutput defines an optional connection point to check compatibility with
  54611. * @returns the first available input or null
  54612. */
  54613. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54614. /**
  54615. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54616. * @param forBlock defines an optional block to check compatibility with
  54617. * @returns the first available input or null
  54618. */
  54619. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54620. /**
  54621. * Connect current block with another block
  54622. * @param other defines the block to connect with
  54623. * @param options define the various options to help pick the right connections
  54624. * @returns the current block
  54625. */
  54626. connectTo(other: NodeMaterialBlock, options?: {
  54627. input?: string;
  54628. output?: string;
  54629. outputSwizzle?: string;
  54630. }): this | undefined;
  54631. protected _buildBlock(state: NodeMaterialBuildState): void;
  54632. /**
  54633. * Add uniforms, samplers and uniform buffers at compilation time
  54634. * @param state defines the state to update
  54635. * @param nodeMaterial defines the node material requesting the update
  54636. * @param defines defines the material defines to update
  54637. */
  54638. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54639. /**
  54640. * Add potential fallbacks if shader compilation fails
  54641. * @param mesh defines the mesh to be rendered
  54642. * @param fallbacks defines the current prioritized list of fallbacks
  54643. */
  54644. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54645. /**
  54646. * Update defines for shader compilation
  54647. * @param mesh defines the mesh to be rendered
  54648. * @param nodeMaterial defines the node material requesting the update
  54649. * @param defines defines the material defines to update
  54650. * @param useInstances specifies that instances should be used
  54651. */
  54652. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54653. /**
  54654. * Initialize defines for shader compilation
  54655. * @param mesh defines the mesh to be rendered
  54656. * @param nodeMaterial defines the node material requesting the update
  54657. * @param defines defines the material defines to be prepared
  54658. * @param useInstances specifies that instances should be used
  54659. */
  54660. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54661. /**
  54662. * Lets the block try to connect some inputs automatically
  54663. */
  54664. autoConfigure(): void;
  54665. /**
  54666. * Function called when a block is declared as repeatable content generator
  54667. * @param vertexShaderState defines the current compilation state for the vertex shader
  54668. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54669. * @param mesh defines the mesh to be rendered
  54670. * @param defines defines the material defines to update
  54671. */
  54672. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54673. /**
  54674. * Checks if the block is ready
  54675. * @param mesh defines the mesh to be rendered
  54676. * @param nodeMaterial defines the node material requesting the update
  54677. * @param defines defines the material defines to update
  54678. * @param useInstances specifies that instances should be used
  54679. * @returns true if the block is ready
  54680. */
  54681. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54682. private _processBuild;
  54683. /**
  54684. * Compile the current node and generate the shader code
  54685. * @param state defines the current compilation state (uniforms, samplers, current string)
  54686. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54687. * @returns true if already built
  54688. */
  54689. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54690. /**
  54691. * Serializes this block in a JSON representation
  54692. * @returns the serialized block object
  54693. */
  54694. serialize(): any;
  54695. /** @hidden */
  54696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54697. }
  54698. }
  54699. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54700. /**
  54701. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54702. */
  54703. export enum NodeMaterialBlockConnectionPointMode {
  54704. /** Value is an uniform */
  54705. Uniform = 0,
  54706. /** Value is a mesh attribute */
  54707. Attribute = 1,
  54708. /** Value is a varying between vertex and fragment shaders */
  54709. Varying = 2,
  54710. /** Mode is undefined */
  54711. Undefined = 3
  54712. }
  54713. }
  54714. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54715. /**
  54716. * Enum used to define well known values e.g. values automatically provided by the system
  54717. */
  54718. export enum NodeMaterialWellKnownValues {
  54719. /** World */
  54720. World = 1,
  54721. /** View */
  54722. View = 2,
  54723. /** Projection */
  54724. Projection = 3,
  54725. /** ViewProjection */
  54726. ViewProjection = 4,
  54727. /** WorldView */
  54728. WorldView = 5,
  54729. /** WorldViewProjection */
  54730. WorldViewProjection = 6,
  54731. /** CameraPosition */
  54732. CameraPosition = 7,
  54733. /** Fog Color */
  54734. FogColor = 8
  54735. }
  54736. }
  54737. declare module "babylonjs/Maths/math.vertexFormat" {
  54738. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54739. /**
  54740. * Contains position and normal vectors for a vertex
  54741. */
  54742. export class PositionNormalVertex {
  54743. /** the position of the vertex (defaut: 0,0,0) */
  54744. position: Vector3;
  54745. /** the normal of the vertex (defaut: 0,1,0) */
  54746. normal: Vector3;
  54747. /**
  54748. * Creates a PositionNormalVertex
  54749. * @param position the position of the vertex (defaut: 0,0,0)
  54750. * @param normal the normal of the vertex (defaut: 0,1,0)
  54751. */
  54752. constructor(
  54753. /** the position of the vertex (defaut: 0,0,0) */
  54754. position?: Vector3,
  54755. /** the normal of the vertex (defaut: 0,1,0) */
  54756. normal?: Vector3);
  54757. /**
  54758. * Clones the PositionNormalVertex
  54759. * @returns the cloned PositionNormalVertex
  54760. */
  54761. clone(): PositionNormalVertex;
  54762. }
  54763. /**
  54764. * Contains position, normal and uv vectors for a vertex
  54765. */
  54766. export class PositionNormalTextureVertex {
  54767. /** the position of the vertex (defaut: 0,0,0) */
  54768. position: Vector3;
  54769. /** the normal of the vertex (defaut: 0,1,0) */
  54770. normal: Vector3;
  54771. /** the uv of the vertex (default: 0,0) */
  54772. uv: Vector2;
  54773. /**
  54774. * Creates a PositionNormalTextureVertex
  54775. * @param position the position of the vertex (defaut: 0,0,0)
  54776. * @param normal the normal of the vertex (defaut: 0,1,0)
  54777. * @param uv the uv of the vertex (default: 0,0)
  54778. */
  54779. constructor(
  54780. /** the position of the vertex (defaut: 0,0,0) */
  54781. position?: Vector3,
  54782. /** the normal of the vertex (defaut: 0,1,0) */
  54783. normal?: Vector3,
  54784. /** the uv of the vertex (default: 0,0) */
  54785. uv?: Vector2);
  54786. /**
  54787. * Clones the PositionNormalTextureVertex
  54788. * @returns the cloned PositionNormalTextureVertex
  54789. */
  54790. clone(): PositionNormalTextureVertex;
  54791. }
  54792. }
  54793. declare module "babylonjs/Maths/math" {
  54794. export * from "babylonjs/Maths/math.axis";
  54795. export * from "babylonjs/Maths/math.color";
  54796. export * from "babylonjs/Maths/math.constants";
  54797. export * from "babylonjs/Maths/math.frustum";
  54798. export * from "babylonjs/Maths/math.path";
  54799. export * from "babylonjs/Maths/math.plane";
  54800. export * from "babylonjs/Maths/math.size";
  54801. export * from "babylonjs/Maths/math.vector";
  54802. export * from "babylonjs/Maths/math.vertexFormat";
  54803. export * from "babylonjs/Maths/math.viewport";
  54804. }
  54805. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54807. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54808. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54809. import { Nullable } from "babylonjs/types";
  54810. import { Effect } from "babylonjs/Materials/effect";
  54811. import { Matrix } from "babylonjs/Maths/math.vector";
  54812. import { Scene } from "babylonjs/scene";
  54813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54815. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54816. /**
  54817. * Block used to expose an input value
  54818. */
  54819. export class InputBlock extends NodeMaterialBlock {
  54820. private _mode;
  54821. private _associatedVariableName;
  54822. private _storedValue;
  54823. private _valueCallback;
  54824. private _type;
  54825. /** @hidden */
  54826. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54827. /**
  54828. * Gets or sets the connection point type (default is float)
  54829. */
  54830. readonly type: NodeMaterialBlockConnectionPointTypes;
  54831. /**
  54832. * Creates a new InputBlock
  54833. * @param name defines the block name
  54834. * @param target defines the target of that block (Vertex by default)
  54835. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54836. */
  54837. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54838. /**
  54839. * Gets the output component
  54840. */
  54841. readonly output: NodeMaterialConnectionPoint;
  54842. /**
  54843. * Set the source of this connection point to a vertex attribute
  54844. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54845. * @returns the current connection point
  54846. */
  54847. setAsAttribute(attributeName?: string): InputBlock;
  54848. /**
  54849. * Set the source of this connection point to a well known value
  54850. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54851. * @returns the current connection point
  54852. */
  54853. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54854. /**
  54855. * Gets or sets the value of that point.
  54856. * Please note that this value will be ignored if valueCallback is defined
  54857. */
  54858. value: any;
  54859. /**
  54860. * Gets or sets a callback used to get the value of that point.
  54861. * Please note that setting this value will force the connection point to ignore the value property
  54862. */
  54863. valueCallback: () => any;
  54864. /**
  54865. * Gets or sets the associated variable name in the shader
  54866. */
  54867. associatedVariableName: string;
  54868. /**
  54869. * Gets a boolean indicating that this connection point not defined yet
  54870. */
  54871. readonly isUndefined: boolean;
  54872. /**
  54873. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54874. * In this case the connection point name must be the name of the uniform to use.
  54875. * Can only be set on inputs
  54876. */
  54877. isUniform: boolean;
  54878. /**
  54879. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54880. * In this case the connection point name must be the name of the attribute to use
  54881. * Can only be set on inputs
  54882. */
  54883. isAttribute: boolean;
  54884. /**
  54885. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54886. * Can only be set on exit points
  54887. */
  54888. isVarying: boolean;
  54889. /**
  54890. * Gets a boolean indicating that the current connection point is a well known value
  54891. */
  54892. readonly isWellKnownValue: boolean;
  54893. /**
  54894. * Gets or sets the current well known value or null if not defined as well know value
  54895. */
  54896. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54897. /**
  54898. * Gets the current class name
  54899. * @returns the class name
  54900. */
  54901. getClassName(): string;
  54902. private _emitDefine;
  54903. /**
  54904. * Set the input block to its default value (based on its type)
  54905. */
  54906. setDefaultValue(): void;
  54907. private _emit;
  54908. /** @hidden */
  54909. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54910. /** @hidden */
  54911. _transmit(effect: Effect, scene: Scene): void;
  54912. protected _buildBlock(state: NodeMaterialBuildState): void;
  54913. serialize(): any;
  54914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54915. }
  54916. }
  54917. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54918. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54919. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54920. import { Nullable } from "babylonjs/types";
  54921. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54923. /**
  54924. * Defines a connection point for a block
  54925. */
  54926. export class NodeMaterialConnectionPoint {
  54927. /** @hidden */
  54928. _ownerBlock: NodeMaterialBlock;
  54929. /** @hidden */
  54930. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54931. private _endpoints;
  54932. private _associatedVariableName;
  54933. /** @hidden */
  54934. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54935. private _type;
  54936. /** @hidden */
  54937. _enforceAssociatedVariableName: boolean;
  54938. /**
  54939. * Gets or sets the additional types supported byt this connection point
  54940. */
  54941. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  54942. /**
  54943. * Gets or sets the associated variable name in the shader
  54944. */
  54945. associatedVariableName: string;
  54946. /**
  54947. * Gets or sets the connection point type (default is float)
  54948. */
  54949. type: NodeMaterialBlockConnectionPointTypes;
  54950. /**
  54951. * Gets or sets the connection point name
  54952. */
  54953. name: string;
  54954. /**
  54955. * Gets or sets a boolean indicating that this connection point can be omitted
  54956. */
  54957. isOptional: boolean;
  54958. /**
  54959. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54960. */
  54961. define: string;
  54962. /** Gets or sets the target of that connection point */
  54963. target: NodeMaterialBlockTargets;
  54964. /**
  54965. * Gets a boolean indicating that the current point is connected
  54966. */
  54967. readonly isConnected: boolean;
  54968. /**
  54969. * Gets a boolean indicating that the current point is connected to an input block
  54970. */
  54971. readonly isConnectedToInput: boolean;
  54972. /**
  54973. * Gets a the connected input block (if any)
  54974. */
  54975. readonly connectInputBlock: Nullable<InputBlock>;
  54976. /** Get the other side of the connection (if any) */
  54977. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54978. /** Get the block that owns this connection point */
  54979. readonly ownerBlock: NodeMaterialBlock;
  54980. /** Get the block connected on the other side of this connection (if any) */
  54981. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54982. /** Get the block connected on the endpoints of this connection (if any) */
  54983. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54984. /** Gets the list of connected endpoints */
  54985. readonly endpoints: NodeMaterialConnectionPoint[];
  54986. /**
  54987. * Creates a new connection point
  54988. * @param name defines the connection point name
  54989. * @param ownerBlock defines the block hosting this connection point
  54990. */
  54991. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54992. /**
  54993. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54994. * @returns the class name
  54995. */
  54996. getClassName(): string;
  54997. /**
  54998. * Gets an boolean indicating if the current point can be connected to another point
  54999. * @param connectionPoint defines the other connection point
  55000. * @returns true if the connection is possible
  55001. */
  55002. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55003. /**
  55004. * Connect this point to another connection point
  55005. * @param connectionPoint defines the other connection point
  55006. * @returns the current connection point
  55007. */
  55008. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55009. /**
  55010. * Disconnect this point from one of his endpoint
  55011. * @param endpoint defines the other connection point
  55012. * @returns the current connection point
  55013. */
  55014. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55015. /**
  55016. * Serializes this point in a JSON representation
  55017. * @returns the serialized point object
  55018. */
  55019. serialize(): any;
  55020. }
  55021. }
  55022. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55026. import { Mesh } from "babylonjs/Meshes/mesh";
  55027. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55028. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55029. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55030. /**
  55031. * Block used to add support for vertex skinning (bones)
  55032. */
  55033. export class BonesBlock extends NodeMaterialBlock {
  55034. /**
  55035. * Creates a new BonesBlock
  55036. * @param name defines the block name
  55037. */
  55038. constructor(name: string);
  55039. /**
  55040. * Initialize the block and prepare the context for build
  55041. * @param state defines the state that will be used for the build
  55042. */
  55043. initialize(state: NodeMaterialBuildState): void;
  55044. /**
  55045. * Gets the current class name
  55046. * @returns the class name
  55047. */
  55048. getClassName(): string;
  55049. /**
  55050. * Gets the matrix indices input component
  55051. */
  55052. readonly matricesIndices: NodeMaterialConnectionPoint;
  55053. /**
  55054. * Gets the matrix weights input component
  55055. */
  55056. readonly matricesWeights: NodeMaterialConnectionPoint;
  55057. /**
  55058. * Gets the extra matrix indices input component
  55059. */
  55060. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55061. /**
  55062. * Gets the extra matrix weights input component
  55063. */
  55064. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55065. /**
  55066. * Gets the world input component
  55067. */
  55068. readonly world: NodeMaterialConnectionPoint;
  55069. /**
  55070. * Gets the output component
  55071. */
  55072. readonly output: NodeMaterialConnectionPoint;
  55073. autoConfigure(): void;
  55074. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55075. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55077. protected _buildBlock(state: NodeMaterialBuildState): this;
  55078. }
  55079. }
  55080. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55082. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55085. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55086. /**
  55087. * Block used to add support for instances
  55088. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55089. */
  55090. export class InstancesBlock extends NodeMaterialBlock {
  55091. /**
  55092. * Creates a new InstancesBlock
  55093. * @param name defines the block name
  55094. */
  55095. constructor(name: string);
  55096. /**
  55097. * Gets the current class name
  55098. * @returns the class name
  55099. */
  55100. getClassName(): string;
  55101. /**
  55102. * Gets the first world row input component
  55103. */
  55104. readonly world0: NodeMaterialConnectionPoint;
  55105. /**
  55106. * Gets the second world row input component
  55107. */
  55108. readonly world1: NodeMaterialConnectionPoint;
  55109. /**
  55110. * Gets the third world row input component
  55111. */
  55112. readonly world2: NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the forth world row input component
  55115. */
  55116. readonly world3: NodeMaterialConnectionPoint;
  55117. /**
  55118. * Gets the world input component
  55119. */
  55120. readonly world: NodeMaterialConnectionPoint;
  55121. /**
  55122. * Gets the output component
  55123. */
  55124. readonly output: NodeMaterialConnectionPoint;
  55125. autoConfigure(): void;
  55126. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55127. protected _buildBlock(state: NodeMaterialBuildState): this;
  55128. }
  55129. }
  55130. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55135. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55136. import { Effect } from "babylonjs/Materials/effect";
  55137. import { Mesh } from "babylonjs/Meshes/mesh";
  55138. /**
  55139. * Block used to add morph targets support to vertex shader
  55140. */
  55141. export class MorphTargetsBlock extends NodeMaterialBlock {
  55142. private _repeatableContentAnchor;
  55143. private _repeatebleContentGenerated;
  55144. /**
  55145. * Create a new MorphTargetsBlock
  55146. * @param name defines the block name
  55147. */
  55148. constructor(name: string);
  55149. /**
  55150. * Gets the current class name
  55151. * @returns the class name
  55152. */
  55153. getClassName(): string;
  55154. /**
  55155. * Gets the position input component
  55156. */
  55157. readonly position: NodeMaterialConnectionPoint;
  55158. /**
  55159. * Gets the normal input component
  55160. */
  55161. readonly normal: NodeMaterialConnectionPoint;
  55162. /**
  55163. * Gets the tangent input component
  55164. */
  55165. readonly tangent: NodeMaterialConnectionPoint;
  55166. /**
  55167. * Gets the tangent input component
  55168. */
  55169. readonly uv: NodeMaterialConnectionPoint;
  55170. /**
  55171. * Gets the position output component
  55172. */
  55173. readonly positionOutput: NodeMaterialConnectionPoint;
  55174. /**
  55175. * Gets the normal output component
  55176. */
  55177. readonly normalOutput: NodeMaterialConnectionPoint;
  55178. /**
  55179. * Gets the tangent output component
  55180. */
  55181. readonly tangentOutput: NodeMaterialConnectionPoint;
  55182. /**
  55183. * Gets the tangent output component
  55184. */
  55185. readonly uvOutput: NodeMaterialConnectionPoint;
  55186. initialize(state: NodeMaterialBuildState): void;
  55187. autoConfigure(): void;
  55188. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55190. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55191. protected _buildBlock(state: NodeMaterialBuildState): this;
  55192. }
  55193. }
  55194. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  55195. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  55196. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  55197. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  55198. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  55199. }
  55200. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  55201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55204. /**
  55205. * Block used to add an alpha test in the fragment shader
  55206. */
  55207. export class AlphaTestBlock extends NodeMaterialBlock {
  55208. /**
  55209. * Gets or sets the alpha value where alpha testing happens
  55210. */
  55211. alphaCutOff: number;
  55212. /**
  55213. * Create a new AlphaTestBlock
  55214. * @param name defines the block name
  55215. */
  55216. constructor(name: string);
  55217. /**
  55218. * Gets the current class name
  55219. * @returns the class name
  55220. */
  55221. getClassName(): string;
  55222. /**
  55223. * Gets the color input component
  55224. */
  55225. readonly color: NodeMaterialConnectionPoint;
  55226. /**
  55227. * Gets the alpha input component
  55228. */
  55229. readonly alpha: NodeMaterialConnectionPoint;
  55230. protected _buildBlock(state: NodeMaterialBuildState): this;
  55231. }
  55232. }
  55233. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  55234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55237. /**
  55238. * Block used to create a Color3/4 out of individual inputs (one for each component)
  55239. */
  55240. export class ColorMergerBlock extends NodeMaterialBlock {
  55241. /**
  55242. * Create a new ColorMergerBlock
  55243. * @param name defines the block name
  55244. */
  55245. constructor(name: string);
  55246. /**
  55247. * Gets the current class name
  55248. * @returns the class name
  55249. */
  55250. getClassName(): string;
  55251. /**
  55252. * Gets the r component (input)
  55253. */
  55254. readonly r: NodeMaterialConnectionPoint;
  55255. /**
  55256. * Gets the g component (input)
  55257. */
  55258. readonly g: NodeMaterialConnectionPoint;
  55259. /**
  55260. * Gets the b component (input)
  55261. */
  55262. readonly b: NodeMaterialConnectionPoint;
  55263. /**
  55264. * Gets the a component (input)
  55265. */
  55266. readonly a: NodeMaterialConnectionPoint;
  55267. /**
  55268. * Gets the rgba component (output)
  55269. */
  55270. readonly rgba: NodeMaterialConnectionPoint;
  55271. /**
  55272. * Gets the rgb component (output)
  55273. */
  55274. readonly rgb: NodeMaterialConnectionPoint;
  55275. protected _buildBlock(state: NodeMaterialBuildState): this;
  55276. }
  55277. }
  55278. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  55279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55282. /**
  55283. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55284. */
  55285. export class VectorMergerBlock extends NodeMaterialBlock {
  55286. /**
  55287. * Create a new VectorMergerBlock
  55288. * @param name defines the block name
  55289. */
  55290. constructor(name: string);
  55291. /**
  55292. * Gets the current class name
  55293. * @returns the class name
  55294. */
  55295. getClassName(): string;
  55296. /**
  55297. * Gets the x component (input)
  55298. */
  55299. readonly x: NodeMaterialConnectionPoint;
  55300. /**
  55301. * Gets the y component (input)
  55302. */
  55303. readonly y: NodeMaterialConnectionPoint;
  55304. /**
  55305. * Gets the z component (input)
  55306. */
  55307. readonly z: NodeMaterialConnectionPoint;
  55308. /**
  55309. * Gets the w component (input)
  55310. */
  55311. readonly w: NodeMaterialConnectionPoint;
  55312. /**
  55313. * Gets the xyzw component (output)
  55314. */
  55315. readonly xyzw: NodeMaterialConnectionPoint;
  55316. /**
  55317. * Gets the xyz component (output)
  55318. */
  55319. readonly xyz: NodeMaterialConnectionPoint;
  55320. /**
  55321. * Gets the xy component (output)
  55322. */
  55323. readonly xy: NodeMaterialConnectionPoint;
  55324. protected _buildBlock(state: NodeMaterialBuildState): this;
  55325. }
  55326. }
  55327. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55331. /**
  55332. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55333. */
  55334. export class ColorSplitterBlock extends NodeMaterialBlock {
  55335. /**
  55336. * Create a new ColorSplitterBlock
  55337. * @param name defines the block name
  55338. */
  55339. constructor(name: string);
  55340. /**
  55341. * Gets the current class name
  55342. * @returns the class name
  55343. */
  55344. getClassName(): string;
  55345. /**
  55346. * Gets the rgba component (input)
  55347. */
  55348. readonly rgba: NodeMaterialConnectionPoint;
  55349. /**
  55350. * Gets the rgb component (input)
  55351. */
  55352. readonly rgbIn: NodeMaterialConnectionPoint;
  55353. /**
  55354. * Gets the rgb component (output)
  55355. */
  55356. readonly rgbOut: NodeMaterialConnectionPoint;
  55357. /**
  55358. * Gets the r component (output)
  55359. */
  55360. readonly r: NodeMaterialConnectionPoint;
  55361. /**
  55362. * Gets the g component (output)
  55363. */
  55364. readonly g: NodeMaterialConnectionPoint;
  55365. /**
  55366. * Gets the b component (output)
  55367. */
  55368. readonly b: NodeMaterialConnectionPoint;
  55369. /**
  55370. * Gets the a component (output)
  55371. */
  55372. readonly a: NodeMaterialConnectionPoint;
  55373. protected _buildBlock(state: NodeMaterialBuildState): this;
  55374. }
  55375. }
  55376. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55380. /**
  55381. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55382. */
  55383. export class VectorSplitterBlock extends NodeMaterialBlock {
  55384. /**
  55385. * Create a new VectorSplitterBlock
  55386. * @param name defines the block name
  55387. */
  55388. constructor(name: string);
  55389. /**
  55390. * Gets the current class name
  55391. * @returns the class name
  55392. */
  55393. getClassName(): string;
  55394. /**
  55395. * Gets the xyzw component (input)
  55396. */
  55397. readonly xyzw: NodeMaterialConnectionPoint;
  55398. /**
  55399. * Gets the xyz component (input)
  55400. */
  55401. readonly xyzIn: NodeMaterialConnectionPoint;
  55402. /**
  55403. * Gets the xyz component (output)
  55404. */
  55405. readonly xyzOut: NodeMaterialConnectionPoint;
  55406. /**
  55407. * Gets the xy component (output)
  55408. */
  55409. readonly xy: NodeMaterialConnectionPoint;
  55410. /**
  55411. * Gets the x component (output)
  55412. */
  55413. readonly x: NodeMaterialConnectionPoint;
  55414. /**
  55415. * Gets the y component (output)
  55416. */
  55417. readonly y: NodeMaterialConnectionPoint;
  55418. /**
  55419. * Gets the z component (output)
  55420. */
  55421. readonly z: NodeMaterialConnectionPoint;
  55422. /**
  55423. * Gets the w component (output)
  55424. */
  55425. readonly w: NodeMaterialConnectionPoint;
  55426. protected _buildBlock(state: NodeMaterialBuildState): this;
  55427. }
  55428. }
  55429. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55434. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55435. import { Effect } from "babylonjs/Materials/effect";
  55436. import { Mesh } from "babylonjs/Meshes/mesh";
  55437. /**
  55438. * Block used to add image processing support to fragment shader
  55439. */
  55440. export class ImageProcessingBlock extends NodeMaterialBlock {
  55441. /**
  55442. * Create a new ImageProcessingBlock
  55443. * @param name defines the block name
  55444. */
  55445. constructor(name: string);
  55446. /**
  55447. * Gets the current class name
  55448. * @returns the class name
  55449. */
  55450. getClassName(): string;
  55451. /**
  55452. * Gets the color input component
  55453. */
  55454. readonly color: NodeMaterialConnectionPoint;
  55455. /**
  55456. * Gets the output component
  55457. */
  55458. readonly output: NodeMaterialConnectionPoint;
  55459. /**
  55460. * Initialize the block and prepare the context for build
  55461. * @param state defines the state that will be used for the build
  55462. */
  55463. initialize(state: NodeMaterialBuildState): void;
  55464. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55466. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55467. protected _buildBlock(state: NodeMaterialBuildState): this;
  55468. }
  55469. }
  55470. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55471. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55472. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55473. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55474. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55475. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55476. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55477. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55478. }
  55479. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55482. import { Mesh } from "babylonjs/Meshes/mesh";
  55483. import { Effect } from "babylonjs/Materials/effect";
  55484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55486. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55487. /**
  55488. * Block used to add support for scene fog
  55489. */
  55490. export class FogBlock extends NodeMaterialBlock {
  55491. private _fogDistanceName;
  55492. private _fogParameters;
  55493. /**
  55494. * Create a new FogBlock
  55495. * @param name defines the block name
  55496. */
  55497. constructor(name: string);
  55498. /**
  55499. * Gets the current class name
  55500. * @returns the class name
  55501. */
  55502. getClassName(): string;
  55503. /**
  55504. * Gets the world position input component
  55505. */
  55506. readonly worldPosition: NodeMaterialConnectionPoint;
  55507. /**
  55508. * Gets the view input component
  55509. */
  55510. readonly view: NodeMaterialConnectionPoint;
  55511. /**
  55512. * Gets the color input component
  55513. */
  55514. readonly color: NodeMaterialConnectionPoint;
  55515. /**
  55516. * Gets the fog color input component
  55517. */
  55518. readonly fogColor: NodeMaterialConnectionPoint;
  55519. /**
  55520. * Gets the output component
  55521. */
  55522. readonly output: NodeMaterialConnectionPoint;
  55523. autoConfigure(): void;
  55524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55526. protected _buildBlock(state: NodeMaterialBuildState): this;
  55527. }
  55528. }
  55529. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55535. import { Effect } from "babylonjs/Materials/effect";
  55536. import { Mesh } from "babylonjs/Meshes/mesh";
  55537. import { Light } from "babylonjs/Lights/light";
  55538. import { Nullable } from "babylonjs/types";
  55539. import { Scene } from "babylonjs/scene";
  55540. /**
  55541. * Block used to add light in the fragment shader
  55542. */
  55543. export class LightBlock extends NodeMaterialBlock {
  55544. private _lightId;
  55545. /**
  55546. * Gets or sets the light associated with this block
  55547. */
  55548. light: Nullable<Light>;
  55549. /**
  55550. * Create a new LightBlock
  55551. * @param name defines the block name
  55552. */
  55553. constructor(name: string);
  55554. /**
  55555. * Gets the current class name
  55556. * @returns the class name
  55557. */
  55558. getClassName(): string;
  55559. /**
  55560. * Gets the world position input component
  55561. */
  55562. readonly worldPosition: NodeMaterialConnectionPoint;
  55563. /**
  55564. * Gets the world normal input component
  55565. */
  55566. readonly worldNormal: NodeMaterialConnectionPoint;
  55567. /**
  55568. * Gets the camera (or eye) position component
  55569. */
  55570. readonly cameraPosition: NodeMaterialConnectionPoint;
  55571. /**
  55572. * Gets the diffuse output component
  55573. */
  55574. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55575. /**
  55576. * Gets the specular output component
  55577. */
  55578. readonly specularOutput: NodeMaterialConnectionPoint;
  55579. autoConfigure(): void;
  55580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55581. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55583. private _injectVertexCode;
  55584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55585. serialize(): any;
  55586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55587. }
  55588. }
  55589. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55590. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55591. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55592. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55593. }
  55594. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55595. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55596. }
  55597. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55601. /**
  55602. * Block used to multiply 2 values
  55603. */
  55604. export class MultiplyBlock extends NodeMaterialBlock {
  55605. /**
  55606. * Creates a new MultiplyBlock
  55607. * @param name defines the block name
  55608. */
  55609. constructor(name: string);
  55610. /**
  55611. * Gets the current class name
  55612. * @returns the class name
  55613. */
  55614. getClassName(): string;
  55615. /**
  55616. * Gets the left operand input component
  55617. */
  55618. readonly left: NodeMaterialConnectionPoint;
  55619. /**
  55620. * Gets the right operand input component
  55621. */
  55622. readonly right: NodeMaterialConnectionPoint;
  55623. /**
  55624. * Gets the output component
  55625. */
  55626. readonly output: NodeMaterialConnectionPoint;
  55627. protected _buildBlock(state: NodeMaterialBuildState): this;
  55628. }
  55629. }
  55630. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55634. /**
  55635. * Block used to add 2 vectors
  55636. */
  55637. export class AddBlock extends NodeMaterialBlock {
  55638. /**
  55639. * Creates a new AddBlock
  55640. * @param name defines the block name
  55641. */
  55642. constructor(name: string);
  55643. /**
  55644. * Gets the current class name
  55645. * @returns the class name
  55646. */
  55647. getClassName(): string;
  55648. /**
  55649. * Gets the left operand input component
  55650. */
  55651. readonly left: NodeMaterialConnectionPoint;
  55652. /**
  55653. * Gets the right operand input component
  55654. */
  55655. readonly right: NodeMaterialConnectionPoint;
  55656. /**
  55657. * Gets the output component
  55658. */
  55659. readonly output: NodeMaterialConnectionPoint;
  55660. protected _buildBlock(state: NodeMaterialBuildState): this;
  55661. }
  55662. }
  55663. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55667. /**
  55668. * Block used to clamp a float
  55669. */
  55670. export class ClampBlock extends NodeMaterialBlock {
  55671. /** Gets or sets the minimum range */
  55672. minimum: number;
  55673. /** Gets or sets the maximum range */
  55674. maximum: number;
  55675. /**
  55676. * Creates a new ClampBlock
  55677. * @param name defines the block name
  55678. */
  55679. constructor(name: string);
  55680. /**
  55681. * Gets the current class name
  55682. * @returns the class name
  55683. */
  55684. getClassName(): string;
  55685. /**
  55686. * Gets the value input component
  55687. */
  55688. readonly value: NodeMaterialConnectionPoint;
  55689. /**
  55690. * Gets the output component
  55691. */
  55692. readonly output: NodeMaterialConnectionPoint;
  55693. protected _buildBlock(state: NodeMaterialBuildState): this;
  55694. }
  55695. }
  55696. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55700. /**
  55701. * Block used to apply a cross product between 2 vectors
  55702. */
  55703. export class CrossBlock extends NodeMaterialBlock {
  55704. /**
  55705. * Creates a new CrossBlock
  55706. * @param name defines the block name
  55707. */
  55708. constructor(name: string);
  55709. /**
  55710. * Gets the current class name
  55711. * @returns the class name
  55712. */
  55713. getClassName(): string;
  55714. /**
  55715. * Gets the left operand input component
  55716. */
  55717. readonly left: NodeMaterialConnectionPoint;
  55718. /**
  55719. * Gets the right operand input component
  55720. */
  55721. readonly right: NodeMaterialConnectionPoint;
  55722. /**
  55723. * Gets the output component
  55724. */
  55725. readonly output: NodeMaterialConnectionPoint;
  55726. protected _buildBlock(state: NodeMaterialBuildState): this;
  55727. }
  55728. }
  55729. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55733. /**
  55734. * Block used to apply a dot product between 2 vectors
  55735. */
  55736. export class DotBlock extends NodeMaterialBlock {
  55737. /**
  55738. * Creates a new DotBlock
  55739. * @param name defines the block name
  55740. */
  55741. constructor(name: string);
  55742. /**
  55743. * Gets the current class name
  55744. * @returns the class name
  55745. */
  55746. getClassName(): string;
  55747. /**
  55748. * Gets the left operand input component
  55749. */
  55750. readonly left: NodeMaterialConnectionPoint;
  55751. /**
  55752. * Gets the right operand input component
  55753. */
  55754. readonly right: NodeMaterialConnectionPoint;
  55755. /**
  55756. * Gets the output component
  55757. */
  55758. readonly output: NodeMaterialConnectionPoint;
  55759. protected _buildBlock(state: NodeMaterialBuildState): this;
  55760. }
  55761. }
  55762. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55766. import { Vector2 } from "babylonjs/Maths/math.vector";
  55767. /**
  55768. * Block used to remap a float from a range to a new one
  55769. */
  55770. export class RemapBlock extends NodeMaterialBlock {
  55771. /**
  55772. * Gets or sets the source range
  55773. */
  55774. sourceRange: Vector2;
  55775. /**
  55776. * Gets or sets the target range
  55777. */
  55778. targetRange: Vector2;
  55779. /**
  55780. * Creates a new RemapBlock
  55781. * @param name defines the block name
  55782. */
  55783. constructor(name: string);
  55784. /**
  55785. * Gets the current class name
  55786. * @returns the class name
  55787. */
  55788. getClassName(): string;
  55789. /**
  55790. * Gets the input component
  55791. */
  55792. readonly input: NodeMaterialConnectionPoint;
  55793. /**
  55794. * Gets the output component
  55795. */
  55796. readonly output: NodeMaterialConnectionPoint;
  55797. protected _buildBlock(state: NodeMaterialBuildState): this;
  55798. }
  55799. }
  55800. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55804. /**
  55805. * Block used to normalize a vector
  55806. */
  55807. export class NormalizeBlock extends NodeMaterialBlock {
  55808. /**
  55809. * Creates a new NormalizeBlock
  55810. * @param name defines the block name
  55811. */
  55812. constructor(name: string);
  55813. /**
  55814. * Gets the current class name
  55815. * @returns the class name
  55816. */
  55817. getClassName(): string;
  55818. /**
  55819. * Gets the input component
  55820. */
  55821. readonly input: NodeMaterialConnectionPoint;
  55822. /**
  55823. * Gets the output component
  55824. */
  55825. readonly output: NodeMaterialConnectionPoint;
  55826. protected _buildBlock(state: NodeMaterialBuildState): this;
  55827. }
  55828. }
  55829. declare module "babylonjs/Materials/Node/Blocks/index" {
  55830. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55831. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55832. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55833. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55834. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55835. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55836. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55837. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55838. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55839. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55840. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  55841. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  55842. }
  55843. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55844. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55845. }
  55846. declare module "babylonjs/Materials/Node/index" {
  55847. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55848. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55849. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55850. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55851. export * from "babylonjs/Materials/Node/nodeMaterial";
  55852. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55853. export * from "babylonjs/Materials/Node/Blocks/index";
  55854. export * from "babylonjs/Materials/Node/Optimizers/index";
  55855. }
  55856. declare module "babylonjs/Materials/effectRenderer" {
  55857. import { Nullable } from "babylonjs/types";
  55858. import { Texture } from "babylonjs/Materials/Textures/texture";
  55859. import { Engine } from "babylonjs/Engines/engine";
  55860. import { Viewport } from "babylonjs/Maths/math.viewport";
  55861. import { Observable } from "babylonjs/Misc/observable";
  55862. import { Effect } from "babylonjs/Materials/effect";
  55863. import "babylonjs/Shaders/postprocess.vertex";
  55864. /**
  55865. * Effect Render Options
  55866. */
  55867. export interface IEffectRendererOptions {
  55868. /**
  55869. * Defines the vertices positions.
  55870. */
  55871. positions?: number[];
  55872. /**
  55873. * Defines the indices.
  55874. */
  55875. indices?: number[];
  55876. }
  55877. /**
  55878. * Helper class to render one or more effects
  55879. */
  55880. export class EffectRenderer {
  55881. private engine;
  55882. private static _DefaultOptions;
  55883. private _vertexBuffers;
  55884. private _indexBuffer;
  55885. private _ringBufferIndex;
  55886. private _ringScreenBuffer;
  55887. private _fullscreenViewport;
  55888. private _getNextFrameBuffer;
  55889. /**
  55890. * Creates an effect renderer
  55891. * @param engine the engine to use for rendering
  55892. * @param options defines the options of the effect renderer
  55893. */
  55894. constructor(engine: Engine, options?: IEffectRendererOptions);
  55895. /**
  55896. * Sets the current viewport in normalized coordinates 0-1
  55897. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55898. */
  55899. setViewport(viewport?: Viewport): void;
  55900. /**
  55901. * Sets the current effect wrapper to use during draw.
  55902. * The effect needs to be ready before calling this api.
  55903. * This also sets the default full screen position attribute.
  55904. * @param effectWrapper Defines the effect to draw with
  55905. */
  55906. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55907. /**
  55908. * Draws a full screen quad.
  55909. */
  55910. draw(): void;
  55911. /**
  55912. * renders one or more effects to a specified texture
  55913. * @param effectWrappers list of effects to renderer
  55914. * @param outputTexture texture to draw to, if null it will render to the screen
  55915. */
  55916. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55917. /**
  55918. * Disposes of the effect renderer
  55919. */
  55920. dispose(): void;
  55921. }
  55922. /**
  55923. * Options to create an EffectWrapper
  55924. */
  55925. interface EffectWrapperCreationOptions {
  55926. /**
  55927. * Engine to use to create the effect
  55928. */
  55929. engine: Engine;
  55930. /**
  55931. * Fragment shader for the effect
  55932. */
  55933. fragmentShader: string;
  55934. /**
  55935. * Vertex shader for the effect
  55936. */
  55937. vertexShader?: string;
  55938. /**
  55939. * Attributes to use in the shader
  55940. */
  55941. attributeNames?: Array<string>;
  55942. /**
  55943. * Uniforms to use in the shader
  55944. */
  55945. uniformNames?: Array<string>;
  55946. /**
  55947. * Texture sampler names to use in the shader
  55948. */
  55949. samplerNames?: Array<string>;
  55950. /**
  55951. * The friendly name of the effect displayed in Spector.
  55952. */
  55953. name?: string;
  55954. }
  55955. /**
  55956. * Wraps an effect to be used for rendering
  55957. */
  55958. export class EffectWrapper {
  55959. /**
  55960. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55961. */
  55962. onApplyObservable: Observable<{}>;
  55963. /**
  55964. * The underlying effect
  55965. */
  55966. effect: Effect;
  55967. /**
  55968. * Creates an effect to be renderer
  55969. * @param creationOptions options to create the effect
  55970. */
  55971. constructor(creationOptions: EffectWrapperCreationOptions);
  55972. /**
  55973. * Disposes of the effect wrapper
  55974. */
  55975. dispose(): void;
  55976. }
  55977. }
  55978. declare module "babylonjs/Materials/index" {
  55979. export * from "babylonjs/Materials/Background/index";
  55980. export * from "babylonjs/Materials/colorCurves";
  55981. export * from "babylonjs/Materials/effect";
  55982. export * from "babylonjs/Materials/fresnelParameters";
  55983. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55984. export * from "babylonjs/Materials/material";
  55985. export * from "babylonjs/Materials/materialDefines";
  55986. export * from "babylonjs/Materials/materialHelper";
  55987. export * from "babylonjs/Materials/multiMaterial";
  55988. export * from "babylonjs/Materials/PBR/index";
  55989. export * from "babylonjs/Materials/pushMaterial";
  55990. export * from "babylonjs/Materials/shaderMaterial";
  55991. export * from "babylonjs/Materials/standardMaterial";
  55992. export * from "babylonjs/Materials/Textures/index";
  55993. export * from "babylonjs/Materials/uniformBuffer";
  55994. export * from "babylonjs/Materials/materialFlags";
  55995. export * from "babylonjs/Materials/Node/index";
  55996. export * from "babylonjs/Materials/effectRenderer";
  55997. }
  55998. declare module "babylonjs/Maths/index" {
  55999. export * from "babylonjs/Maths/math.scalar";
  56000. export * from "babylonjs/Maths/math";
  56001. export * from "babylonjs/Maths/sphericalPolynomial";
  56002. }
  56003. declare module "babylonjs/Misc/workerPool" {
  56004. import { IDisposable } from "babylonjs/scene";
  56005. /**
  56006. * Helper class to push actions to a pool of workers.
  56007. */
  56008. export class WorkerPool implements IDisposable {
  56009. private _workerInfos;
  56010. private _pendingActions;
  56011. /**
  56012. * Constructor
  56013. * @param workers Array of workers to use for actions
  56014. */
  56015. constructor(workers: Array<Worker>);
  56016. /**
  56017. * Terminates all workers and clears any pending actions.
  56018. */
  56019. dispose(): void;
  56020. /**
  56021. * Pushes an action to the worker pool. If all the workers are active, the action will be
  56022. * pended until a worker has completed its action.
  56023. * @param action The action to perform. Call onComplete when the action is complete.
  56024. */
  56025. push(action: (worker: Worker, onComplete: () => void) => void): void;
  56026. private _execute;
  56027. }
  56028. }
  56029. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  56030. import { IDisposable } from "babylonjs/scene";
  56031. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56032. /**
  56033. * Configuration for Draco compression
  56034. */
  56035. export interface IDracoCompressionConfiguration {
  56036. /**
  56037. * Configuration for the decoder.
  56038. */
  56039. decoder: {
  56040. /**
  56041. * The url to the WebAssembly module.
  56042. */
  56043. wasmUrl?: string;
  56044. /**
  56045. * The url to the WebAssembly binary.
  56046. */
  56047. wasmBinaryUrl?: string;
  56048. /**
  56049. * The url to the fallback JavaScript module.
  56050. */
  56051. fallbackUrl?: string;
  56052. };
  56053. }
  56054. /**
  56055. * Draco compression (https://google.github.io/draco/)
  56056. *
  56057. * This class wraps the Draco module.
  56058. *
  56059. * **Encoder**
  56060. *
  56061. * The encoder is not currently implemented.
  56062. *
  56063. * **Decoder**
  56064. *
  56065. * 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.
  56066. *
  56067. * To update the configuration, use the following code:
  56068. * ```javascript
  56069. * DracoCompression.Configuration = {
  56070. * decoder: {
  56071. * wasmUrl: "<url to the WebAssembly library>",
  56072. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  56073. * fallbackUrl: "<url to the fallback JavaScript library>",
  56074. * }
  56075. * };
  56076. * ```
  56077. *
  56078. * 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.
  56079. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  56080. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  56081. *
  56082. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  56083. * ```javascript
  56084. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  56085. * ```
  56086. *
  56087. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  56088. */
  56089. export class DracoCompression implements IDisposable {
  56090. private _workerPoolPromise?;
  56091. private _decoderModulePromise?;
  56092. /**
  56093. * The configuration. Defaults to the following urls:
  56094. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  56095. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  56096. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  56097. */
  56098. static Configuration: IDracoCompressionConfiguration;
  56099. /**
  56100. * Returns true if the decoder configuration is available.
  56101. */
  56102. static readonly DecoderAvailable: boolean;
  56103. /**
  56104. * Default number of workers to create when creating the draco compression object.
  56105. */
  56106. static DefaultNumWorkers: number;
  56107. private static GetDefaultNumWorkers;
  56108. private static _Default;
  56109. /**
  56110. * Default instance for the draco compression object.
  56111. */
  56112. static readonly Default: DracoCompression;
  56113. /**
  56114. * Constructor
  56115. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  56116. */
  56117. constructor(numWorkers?: number);
  56118. /**
  56119. * Stop all async operations and release resources.
  56120. */
  56121. dispose(): void;
  56122. /**
  56123. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  56124. * @returns a promise that resolves when ready
  56125. */
  56126. whenReadyAsync(): Promise<void>;
  56127. /**
  56128. * Decode Draco compressed mesh data to vertex data.
  56129. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  56130. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  56131. * @returns A promise that resolves with the decoded vertex data
  56132. */
  56133. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  56134. [kind: string]: number;
  56135. }): Promise<VertexData>;
  56136. }
  56137. }
  56138. declare module "babylonjs/Meshes/Compression/index" {
  56139. export * from "babylonjs/Meshes/Compression/dracoCompression";
  56140. }
  56141. declare module "babylonjs/Meshes/csg" {
  56142. import { Nullable } from "babylonjs/types";
  56143. import { Scene } from "babylonjs/scene";
  56144. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56145. import { Mesh } from "babylonjs/Meshes/mesh";
  56146. import { Material } from "babylonjs/Materials/material";
  56147. /**
  56148. * Class for building Constructive Solid Geometry
  56149. */
  56150. export class CSG {
  56151. private polygons;
  56152. /**
  56153. * The world matrix
  56154. */
  56155. matrix: Matrix;
  56156. /**
  56157. * Stores the position
  56158. */
  56159. position: Vector3;
  56160. /**
  56161. * Stores the rotation
  56162. */
  56163. rotation: Vector3;
  56164. /**
  56165. * Stores the rotation quaternion
  56166. */
  56167. rotationQuaternion: Nullable<Quaternion>;
  56168. /**
  56169. * Stores the scaling vector
  56170. */
  56171. scaling: Vector3;
  56172. /**
  56173. * Convert the Mesh to CSG
  56174. * @param mesh The Mesh to convert to CSG
  56175. * @returns A new CSG from the Mesh
  56176. */
  56177. static FromMesh(mesh: Mesh): CSG;
  56178. /**
  56179. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  56180. * @param polygons Polygons used to construct a CSG solid
  56181. */
  56182. private static FromPolygons;
  56183. /**
  56184. * Clones, or makes a deep copy, of the CSG
  56185. * @returns A new CSG
  56186. */
  56187. clone(): CSG;
  56188. /**
  56189. * Unions this CSG with another CSG
  56190. * @param csg The CSG to union against this CSG
  56191. * @returns The unioned CSG
  56192. */
  56193. union(csg: CSG): CSG;
  56194. /**
  56195. * Unions this CSG with another CSG in place
  56196. * @param csg The CSG to union against this CSG
  56197. */
  56198. unionInPlace(csg: CSG): void;
  56199. /**
  56200. * Subtracts this CSG with another CSG
  56201. * @param csg The CSG to subtract against this CSG
  56202. * @returns A new CSG
  56203. */
  56204. subtract(csg: CSG): CSG;
  56205. /**
  56206. * Subtracts this CSG with another CSG in place
  56207. * @param csg The CSG to subtact against this CSG
  56208. */
  56209. subtractInPlace(csg: CSG): void;
  56210. /**
  56211. * Intersect this CSG with another CSG
  56212. * @param csg The CSG to intersect against this CSG
  56213. * @returns A new CSG
  56214. */
  56215. intersect(csg: CSG): CSG;
  56216. /**
  56217. * Intersects this CSG with another CSG in place
  56218. * @param csg The CSG to intersect against this CSG
  56219. */
  56220. intersectInPlace(csg: CSG): void;
  56221. /**
  56222. * Return a new CSG solid with solid and empty space switched. This solid is
  56223. * not modified.
  56224. * @returns A new CSG solid with solid and empty space switched
  56225. */
  56226. inverse(): CSG;
  56227. /**
  56228. * Inverses the CSG in place
  56229. */
  56230. inverseInPlace(): void;
  56231. /**
  56232. * This is used to keep meshes transformations so they can be restored
  56233. * when we build back a Babylon Mesh
  56234. * NB : All CSG operations are performed in world coordinates
  56235. * @param csg The CSG to copy the transform attributes from
  56236. * @returns This CSG
  56237. */
  56238. copyTransformAttributes(csg: CSG): CSG;
  56239. /**
  56240. * Build Raw mesh from CSG
  56241. * Coordinates here are in world space
  56242. * @param name The name of the mesh geometry
  56243. * @param scene The Scene
  56244. * @param keepSubMeshes Specifies if the submeshes should be kept
  56245. * @returns A new Mesh
  56246. */
  56247. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  56248. /**
  56249. * Build Mesh from CSG taking material and transforms into account
  56250. * @param name The name of the Mesh
  56251. * @param material The material of the Mesh
  56252. * @param scene The Scene
  56253. * @param keepSubMeshes Specifies if submeshes should be kept
  56254. * @returns The new Mesh
  56255. */
  56256. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  56257. }
  56258. }
  56259. declare module "babylonjs/Meshes/trailMesh" {
  56260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56261. import { Mesh } from "babylonjs/Meshes/mesh";
  56262. import { Scene } from "babylonjs/scene";
  56263. /**
  56264. * Class used to create a trail following a mesh
  56265. */
  56266. export class TrailMesh extends Mesh {
  56267. private _generator;
  56268. private _autoStart;
  56269. private _running;
  56270. private _diameter;
  56271. private _length;
  56272. private _sectionPolygonPointsCount;
  56273. private _sectionVectors;
  56274. private _sectionNormalVectors;
  56275. private _beforeRenderObserver;
  56276. /**
  56277. * @constructor
  56278. * @param name The value used by scene.getMeshByName() to do a lookup.
  56279. * @param generator The mesh to generate a trail.
  56280. * @param scene The scene to add this mesh to.
  56281. * @param diameter Diameter of trailing mesh. Default is 1.
  56282. * @param length Length of trailing mesh. Default is 60.
  56283. * @param autoStart Automatically start trailing mesh. Default true.
  56284. */
  56285. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56286. /**
  56287. * "TrailMesh"
  56288. * @returns "TrailMesh"
  56289. */
  56290. getClassName(): string;
  56291. private _createMesh;
  56292. /**
  56293. * Start trailing mesh.
  56294. */
  56295. start(): void;
  56296. /**
  56297. * Stop trailing mesh.
  56298. */
  56299. stop(): void;
  56300. /**
  56301. * Update trailing mesh geometry.
  56302. */
  56303. update(): void;
  56304. /**
  56305. * Returns a new TrailMesh object.
  56306. * @param name is a string, the name given to the new mesh
  56307. * @param newGenerator use new generator object for cloned trail mesh
  56308. * @returns a new mesh
  56309. */
  56310. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56311. /**
  56312. * Serializes this trail mesh
  56313. * @param serializationObject object to write serialization to
  56314. */
  56315. serialize(serializationObject: any): void;
  56316. /**
  56317. * Parses a serialized trail mesh
  56318. * @param parsedMesh the serialized mesh
  56319. * @param scene the scene to create the trail mesh in
  56320. * @returns the created trail mesh
  56321. */
  56322. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56323. }
  56324. }
  56325. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56326. import { Nullable } from "babylonjs/types";
  56327. import { Scene } from "babylonjs/scene";
  56328. import { Vector4 } from "babylonjs/Maths/math.vector";
  56329. import { Color4 } from "babylonjs/Maths/math.color";
  56330. import { Mesh } from "babylonjs/Meshes/mesh";
  56331. /**
  56332. * Class containing static functions to help procedurally build meshes
  56333. */
  56334. export class TiledBoxBuilder {
  56335. /**
  56336. * Creates a box mesh
  56337. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  56338. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56342. * @param name defines the name of the mesh
  56343. * @param options defines the options used to create the mesh
  56344. * @param scene defines the hosting scene
  56345. * @returns the box mesh
  56346. */
  56347. static CreateTiledBox(name: string, options: {
  56348. pattern?: number;
  56349. width?: number;
  56350. height?: number;
  56351. depth?: number;
  56352. tileSize?: number;
  56353. tileWidth?: number;
  56354. tileHeight?: number;
  56355. alignHorizontal?: number;
  56356. alignVertical?: number;
  56357. faceUV?: Vector4[];
  56358. faceColors?: Color4[];
  56359. sideOrientation?: number;
  56360. updatable?: boolean;
  56361. }, scene?: Nullable<Scene>): Mesh;
  56362. }
  56363. }
  56364. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56365. import { Vector4 } from "babylonjs/Maths/math.vector";
  56366. import { Mesh } from "babylonjs/Meshes/mesh";
  56367. /**
  56368. * Class containing static functions to help procedurally build meshes
  56369. */
  56370. export class TorusKnotBuilder {
  56371. /**
  56372. * Creates a torus knot mesh
  56373. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56374. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56375. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56376. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56380. * @param name defines the name of the mesh
  56381. * @param options defines the options used to create the mesh
  56382. * @param scene defines the hosting scene
  56383. * @returns the torus knot mesh
  56384. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56385. */
  56386. static CreateTorusKnot(name: string, options: {
  56387. radius?: number;
  56388. tube?: number;
  56389. radialSegments?: number;
  56390. tubularSegments?: number;
  56391. p?: number;
  56392. q?: number;
  56393. updatable?: boolean;
  56394. sideOrientation?: number;
  56395. frontUVs?: Vector4;
  56396. backUVs?: Vector4;
  56397. }, scene: any): Mesh;
  56398. }
  56399. }
  56400. declare module "babylonjs/Meshes/polygonMesh" {
  56401. import { Scene } from "babylonjs/scene";
  56402. import { Vector2 } from "babylonjs/Maths/math.vector";
  56403. import { Mesh } from "babylonjs/Meshes/mesh";
  56404. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56405. import { Path2 } from "babylonjs/Maths/math.path";
  56406. /**
  56407. * Polygon
  56408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56409. */
  56410. export class Polygon {
  56411. /**
  56412. * Creates a rectangle
  56413. * @param xmin bottom X coord
  56414. * @param ymin bottom Y coord
  56415. * @param xmax top X coord
  56416. * @param ymax top Y coord
  56417. * @returns points that make the resulting rectation
  56418. */
  56419. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56420. /**
  56421. * Creates a circle
  56422. * @param radius radius of circle
  56423. * @param cx scale in x
  56424. * @param cy scale in y
  56425. * @param numberOfSides number of sides that make up the circle
  56426. * @returns points that make the resulting circle
  56427. */
  56428. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56429. /**
  56430. * Creates a polygon from input string
  56431. * @param input Input polygon data
  56432. * @returns the parsed points
  56433. */
  56434. static Parse(input: string): Vector2[];
  56435. /**
  56436. * Starts building a polygon from x and y coordinates
  56437. * @param x x coordinate
  56438. * @param y y coordinate
  56439. * @returns the started path2
  56440. */
  56441. static StartingAt(x: number, y: number): Path2;
  56442. }
  56443. /**
  56444. * Builds a polygon
  56445. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56446. */
  56447. export class PolygonMeshBuilder {
  56448. private _points;
  56449. private _outlinepoints;
  56450. private _holes;
  56451. private _name;
  56452. private _scene;
  56453. private _epoints;
  56454. private _eholes;
  56455. private _addToepoint;
  56456. /**
  56457. * Babylon reference to the earcut plugin.
  56458. */
  56459. bjsEarcut: any;
  56460. /**
  56461. * Creates a PolygonMeshBuilder
  56462. * @param name name of the builder
  56463. * @param contours Path of the polygon
  56464. * @param scene scene to add to when creating the mesh
  56465. * @param earcutInjection can be used to inject your own earcut reference
  56466. */
  56467. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56468. /**
  56469. * Adds a whole within the polygon
  56470. * @param hole Array of points defining the hole
  56471. * @returns this
  56472. */
  56473. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56474. /**
  56475. * Creates the polygon
  56476. * @param updatable If the mesh should be updatable
  56477. * @param depth The depth of the mesh created
  56478. * @returns the created mesh
  56479. */
  56480. build(updatable?: boolean, depth?: number): Mesh;
  56481. /**
  56482. * Creates the polygon
  56483. * @param depth The depth of the mesh created
  56484. * @returns the created VertexData
  56485. */
  56486. buildVertexData(depth?: number): VertexData;
  56487. /**
  56488. * Adds a side to the polygon
  56489. * @param positions points that make the polygon
  56490. * @param normals normals of the polygon
  56491. * @param uvs uvs of the polygon
  56492. * @param indices indices of the polygon
  56493. * @param bounds bounds of the polygon
  56494. * @param points points of the polygon
  56495. * @param depth depth of the polygon
  56496. * @param flip flip of the polygon
  56497. */
  56498. private addSide;
  56499. }
  56500. }
  56501. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56502. import { Scene } from "babylonjs/scene";
  56503. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56504. import { Color4 } from "babylonjs/Maths/math.color";
  56505. import { Mesh } from "babylonjs/Meshes/mesh";
  56506. import { Nullable } from "babylonjs/types";
  56507. /**
  56508. * Class containing static functions to help procedurally build meshes
  56509. */
  56510. export class PolygonBuilder {
  56511. /**
  56512. * Creates a polygon mesh
  56513. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56514. * * 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
  56515. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56518. * * Remember you can only change the shape positions, not their number when updating a polygon
  56519. * @param name defines the name of the mesh
  56520. * @param options defines the options used to create the mesh
  56521. * @param scene defines the hosting scene
  56522. * @param earcutInjection can be used to inject your own earcut reference
  56523. * @returns the polygon mesh
  56524. */
  56525. static CreatePolygon(name: string, options: {
  56526. shape: Vector3[];
  56527. holes?: Vector3[][];
  56528. depth?: number;
  56529. faceUV?: Vector4[];
  56530. faceColors?: Color4[];
  56531. updatable?: boolean;
  56532. sideOrientation?: number;
  56533. frontUVs?: Vector4;
  56534. backUVs?: Vector4;
  56535. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56536. /**
  56537. * Creates an extruded polygon mesh, with depth in the Y direction.
  56538. * * 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)
  56539. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56540. * @param name defines the name of the mesh
  56541. * @param options defines the options used to create the mesh
  56542. * @param scene defines the hosting scene
  56543. * @param earcutInjection can be used to inject your own earcut reference
  56544. * @returns the polygon mesh
  56545. */
  56546. static ExtrudePolygon(name: string, options: {
  56547. shape: Vector3[];
  56548. holes?: Vector3[][];
  56549. depth?: number;
  56550. faceUV?: Vector4[];
  56551. faceColors?: Color4[];
  56552. updatable?: boolean;
  56553. sideOrientation?: number;
  56554. frontUVs?: Vector4;
  56555. backUVs?: Vector4;
  56556. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56557. }
  56558. }
  56559. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56560. import { Scene } from "babylonjs/scene";
  56561. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56562. import { Mesh } from "babylonjs/Meshes/mesh";
  56563. import { Nullable } from "babylonjs/types";
  56564. /**
  56565. * Class containing static functions to help procedurally build meshes
  56566. */
  56567. export class LatheBuilder {
  56568. /**
  56569. * Creates lathe mesh.
  56570. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56571. * * 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
  56572. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56573. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56574. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56575. * * 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
  56576. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56577. * * 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
  56578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56579. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56580. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56582. * @param name defines the name of the mesh
  56583. * @param options defines the options used to create the mesh
  56584. * @param scene defines the hosting scene
  56585. * @returns the lathe mesh
  56586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56587. */
  56588. static CreateLathe(name: string, options: {
  56589. shape: Vector3[];
  56590. radius?: number;
  56591. tessellation?: number;
  56592. clip?: number;
  56593. arc?: number;
  56594. closed?: boolean;
  56595. updatable?: boolean;
  56596. sideOrientation?: number;
  56597. frontUVs?: Vector4;
  56598. backUVs?: Vector4;
  56599. cap?: number;
  56600. invertUV?: boolean;
  56601. }, scene?: Nullable<Scene>): Mesh;
  56602. }
  56603. }
  56604. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56605. import { Nullable } from "babylonjs/types";
  56606. import { Scene } from "babylonjs/scene";
  56607. import { Vector4 } from "babylonjs/Maths/math.vector";
  56608. import { Mesh } from "babylonjs/Meshes/mesh";
  56609. /**
  56610. * Class containing static functions to help procedurally build meshes
  56611. */
  56612. export class TiledPlaneBuilder {
  56613. /**
  56614. * Creates a tiled plane mesh
  56615. * * The parameter `pattern` will, depending on value, do nothing or
  56616. * * * flip (reflect about central vertical) alternate tiles across and up
  56617. * * * flip every tile on alternate rows
  56618. * * * rotate (180 degs) alternate tiles across and up
  56619. * * * rotate every tile on alternate rows
  56620. * * * flip and rotate alternate tiles across and up
  56621. * * * flip and rotate every tile on alternate rows
  56622. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56623. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56625. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56626. * * 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)
  56627. * * 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)
  56628. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56629. * @param name defines the name of the mesh
  56630. * @param options defines the options used to create the mesh
  56631. * @param scene defines the hosting scene
  56632. * @returns the box mesh
  56633. */
  56634. static CreateTiledPlane(name: string, options: {
  56635. pattern?: number;
  56636. tileSize?: number;
  56637. tileWidth?: number;
  56638. tileHeight?: number;
  56639. size?: number;
  56640. width?: number;
  56641. height?: number;
  56642. alignHorizontal?: number;
  56643. alignVertical?: number;
  56644. sideOrientation?: number;
  56645. frontUVs?: Vector4;
  56646. backUVs?: Vector4;
  56647. updatable?: boolean;
  56648. }, scene?: Nullable<Scene>): Mesh;
  56649. }
  56650. }
  56651. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56652. import { Nullable } from "babylonjs/types";
  56653. import { Scene } from "babylonjs/scene";
  56654. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56655. import { Mesh } from "babylonjs/Meshes/mesh";
  56656. /**
  56657. * Class containing static functions to help procedurally build meshes
  56658. */
  56659. export class TubeBuilder {
  56660. /**
  56661. * Creates a tube mesh.
  56662. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56663. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56664. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56665. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56666. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56667. * * 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)
  56668. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56669. * * 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
  56670. * * 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
  56671. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56672. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56673. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56675. * @param name defines the name of the mesh
  56676. * @param options defines the options used to create the mesh
  56677. * @param scene defines the hosting scene
  56678. * @returns the tube mesh
  56679. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56680. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56681. */
  56682. static CreateTube(name: string, options: {
  56683. path: Vector3[];
  56684. radius?: number;
  56685. tessellation?: number;
  56686. radiusFunction?: {
  56687. (i: number, distance: number): number;
  56688. };
  56689. cap?: number;
  56690. arc?: number;
  56691. updatable?: boolean;
  56692. sideOrientation?: number;
  56693. frontUVs?: Vector4;
  56694. backUVs?: Vector4;
  56695. instance?: Mesh;
  56696. invertUV?: boolean;
  56697. }, scene?: Nullable<Scene>): Mesh;
  56698. }
  56699. }
  56700. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56701. import { Scene } from "babylonjs/scene";
  56702. import { Vector4 } from "babylonjs/Maths/math.vector";
  56703. import { Mesh } from "babylonjs/Meshes/mesh";
  56704. import { Nullable } from "babylonjs/types";
  56705. /**
  56706. * Class containing static functions to help procedurally build meshes
  56707. */
  56708. export class IcoSphereBuilder {
  56709. /**
  56710. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56711. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56712. * * 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`)
  56713. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56714. * * 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
  56715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56718. * @param name defines the name of the mesh
  56719. * @param options defines the options used to create the mesh
  56720. * @param scene defines the hosting scene
  56721. * @returns the icosahedron mesh
  56722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56723. */
  56724. static CreateIcoSphere(name: string, options: {
  56725. radius?: number;
  56726. radiusX?: number;
  56727. radiusY?: number;
  56728. radiusZ?: number;
  56729. flat?: boolean;
  56730. subdivisions?: number;
  56731. sideOrientation?: number;
  56732. frontUVs?: Vector4;
  56733. backUVs?: Vector4;
  56734. updatable?: boolean;
  56735. }, scene?: Nullable<Scene>): Mesh;
  56736. }
  56737. }
  56738. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56739. import { Vector3 } from "babylonjs/Maths/math.vector";
  56740. import { Mesh } from "babylonjs/Meshes/mesh";
  56741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56742. /**
  56743. * Class containing static functions to help procedurally build meshes
  56744. */
  56745. export class DecalBuilder {
  56746. /**
  56747. * Creates a decal mesh.
  56748. * 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
  56749. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56750. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56751. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56752. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56753. * @param name defines the name of the mesh
  56754. * @param sourceMesh defines the mesh where the decal must be applied
  56755. * @param options defines the options used to create the mesh
  56756. * @param scene defines the hosting scene
  56757. * @returns the decal mesh
  56758. * @see https://doc.babylonjs.com/how_to/decals
  56759. */
  56760. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56761. position?: Vector3;
  56762. normal?: Vector3;
  56763. size?: Vector3;
  56764. angle?: number;
  56765. }): Mesh;
  56766. }
  56767. }
  56768. declare module "babylonjs/Meshes/meshBuilder" {
  56769. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56770. import { Nullable } from "babylonjs/types";
  56771. import { Scene } from "babylonjs/scene";
  56772. import { Mesh } from "babylonjs/Meshes/mesh";
  56773. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56774. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56776. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56777. import { Plane } from "babylonjs/Maths/math.plane";
  56778. /**
  56779. * Class containing static functions to help procedurally build meshes
  56780. */
  56781. export class MeshBuilder {
  56782. /**
  56783. * Creates a box mesh
  56784. * * The parameter `size` sets the size (float) of each box side (default 1)
  56785. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56786. * * 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)
  56787. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56791. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56792. * @param name defines the name of the mesh
  56793. * @param options defines the options used to create the mesh
  56794. * @param scene defines the hosting scene
  56795. * @returns the box mesh
  56796. */
  56797. static CreateBox(name: string, options: {
  56798. size?: number;
  56799. width?: number;
  56800. height?: number;
  56801. depth?: number;
  56802. faceUV?: Vector4[];
  56803. faceColors?: Color4[];
  56804. sideOrientation?: number;
  56805. frontUVs?: Vector4;
  56806. backUVs?: Vector4;
  56807. updatable?: boolean;
  56808. }, scene?: Nullable<Scene>): Mesh;
  56809. /**
  56810. * Creates a tiled box mesh
  56811. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56813. * @param name defines the name of the mesh
  56814. * @param options defines the options used to create the mesh
  56815. * @param scene defines the hosting scene
  56816. * @returns the tiled box mesh
  56817. */
  56818. static CreateTiledBox(name: string, options: {
  56819. pattern?: number;
  56820. size?: number;
  56821. width?: number;
  56822. height?: number;
  56823. depth: number;
  56824. tileSize?: number;
  56825. tileWidth?: number;
  56826. tileHeight?: number;
  56827. faceUV?: Vector4[];
  56828. faceColors?: Color4[];
  56829. alignHorizontal?: number;
  56830. alignVertical?: number;
  56831. sideOrientation?: number;
  56832. updatable?: boolean;
  56833. }, scene?: Nullable<Scene>): Mesh;
  56834. /**
  56835. * Creates a sphere mesh
  56836. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56837. * * 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`)
  56838. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56839. * * 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
  56840. * * 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)
  56841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56844. * @param name defines the name of the mesh
  56845. * @param options defines the options used to create the mesh
  56846. * @param scene defines the hosting scene
  56847. * @returns the sphere mesh
  56848. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56849. */
  56850. static CreateSphere(name: string, options: {
  56851. segments?: number;
  56852. diameter?: number;
  56853. diameterX?: number;
  56854. diameterY?: number;
  56855. diameterZ?: number;
  56856. arc?: number;
  56857. slice?: number;
  56858. sideOrientation?: number;
  56859. frontUVs?: Vector4;
  56860. backUVs?: Vector4;
  56861. updatable?: boolean;
  56862. }, scene?: Nullable<Scene>): Mesh;
  56863. /**
  56864. * Creates a plane polygonal mesh. By default, this is a disc
  56865. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56866. * * 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
  56867. * * 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
  56868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56871. * @param name defines the name of the mesh
  56872. * @param options defines the options used to create the mesh
  56873. * @param scene defines the hosting scene
  56874. * @returns the plane polygonal mesh
  56875. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56876. */
  56877. static CreateDisc(name: string, options: {
  56878. radius?: number;
  56879. tessellation?: number;
  56880. arc?: number;
  56881. updatable?: boolean;
  56882. sideOrientation?: number;
  56883. frontUVs?: Vector4;
  56884. backUVs?: Vector4;
  56885. }, scene?: Nullable<Scene>): Mesh;
  56886. /**
  56887. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56888. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56889. * * 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`)
  56890. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56891. * * 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
  56892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56895. * @param name defines the name of the mesh
  56896. * @param options defines the options used to create the mesh
  56897. * @param scene defines the hosting scene
  56898. * @returns the icosahedron mesh
  56899. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56900. */
  56901. static CreateIcoSphere(name: string, options: {
  56902. radius?: number;
  56903. radiusX?: number;
  56904. radiusY?: number;
  56905. radiusZ?: number;
  56906. flat?: boolean;
  56907. subdivisions?: number;
  56908. sideOrientation?: number;
  56909. frontUVs?: Vector4;
  56910. backUVs?: Vector4;
  56911. updatable?: boolean;
  56912. }, scene?: Nullable<Scene>): Mesh;
  56913. /**
  56914. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56915. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56916. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56917. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56918. * * 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
  56919. * * 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
  56920. * * 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
  56921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56924. * * 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
  56925. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56926. * * 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
  56927. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56929. * @param name defines the name of the mesh
  56930. * @param options defines the options used to create the mesh
  56931. * @param scene defines the hosting scene
  56932. * @returns the ribbon mesh
  56933. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56934. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56935. */
  56936. static CreateRibbon(name: string, options: {
  56937. pathArray: Vector3[][];
  56938. closeArray?: boolean;
  56939. closePath?: boolean;
  56940. offset?: number;
  56941. updatable?: boolean;
  56942. sideOrientation?: number;
  56943. frontUVs?: Vector4;
  56944. backUVs?: Vector4;
  56945. instance?: Mesh;
  56946. invertUV?: boolean;
  56947. uvs?: Vector2[];
  56948. colors?: Color4[];
  56949. }, scene?: Nullable<Scene>): Mesh;
  56950. /**
  56951. * Creates a cylinder or a cone mesh
  56952. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56953. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56954. * * 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.
  56955. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56956. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56957. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56958. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56959. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  56960. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56961. * * 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).
  56962. * * 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
  56963. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56964. * * 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
  56965. * * 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.
  56966. * * If `enclose` is false, a ring surface is one element.
  56967. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56968. * * 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
  56969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56972. * @param name defines the name of the mesh
  56973. * @param options defines the options used to create the mesh
  56974. * @param scene defines the hosting scene
  56975. * @returns the cylinder mesh
  56976. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56977. */
  56978. static CreateCylinder(name: string, options: {
  56979. height?: number;
  56980. diameterTop?: number;
  56981. diameterBottom?: number;
  56982. diameter?: number;
  56983. tessellation?: number;
  56984. subdivisions?: number;
  56985. arc?: number;
  56986. faceColors?: Color4[];
  56987. faceUV?: Vector4[];
  56988. updatable?: boolean;
  56989. hasRings?: boolean;
  56990. enclose?: boolean;
  56991. cap?: number;
  56992. sideOrientation?: number;
  56993. frontUVs?: Vector4;
  56994. backUVs?: Vector4;
  56995. }, scene?: Nullable<Scene>): Mesh;
  56996. /**
  56997. * Creates a torus mesh
  56998. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56999. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  57000. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  57001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57004. * @param name defines the name of the mesh
  57005. * @param options defines the options used to create the mesh
  57006. * @param scene defines the hosting scene
  57007. * @returns the torus mesh
  57008. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  57009. */
  57010. static CreateTorus(name: string, options: {
  57011. diameter?: number;
  57012. thickness?: number;
  57013. tessellation?: number;
  57014. updatable?: boolean;
  57015. sideOrientation?: number;
  57016. frontUVs?: Vector4;
  57017. backUVs?: Vector4;
  57018. }, scene?: Nullable<Scene>): Mesh;
  57019. /**
  57020. * Creates a torus knot mesh
  57021. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57022. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57023. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57024. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57028. * @param name defines the name of the mesh
  57029. * @param options defines the options used to create the mesh
  57030. * @param scene defines the hosting scene
  57031. * @returns the torus knot mesh
  57032. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57033. */
  57034. static CreateTorusKnot(name: string, options: {
  57035. radius?: number;
  57036. tube?: number;
  57037. radialSegments?: number;
  57038. tubularSegments?: number;
  57039. p?: number;
  57040. q?: number;
  57041. updatable?: boolean;
  57042. sideOrientation?: number;
  57043. frontUVs?: Vector4;
  57044. backUVs?: Vector4;
  57045. }, scene?: Nullable<Scene>): Mesh;
  57046. /**
  57047. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  57048. * * 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
  57049. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  57050. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  57051. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  57052. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  57053. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  57054. * * 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
  57055. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  57056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  57058. * @param name defines the name of the new line system
  57059. * @param options defines the options used to create the line system
  57060. * @param scene defines the hosting scene
  57061. * @returns a new line system mesh
  57062. */
  57063. static CreateLineSystem(name: string, options: {
  57064. lines: Vector3[][];
  57065. updatable?: boolean;
  57066. instance?: Nullable<LinesMesh>;
  57067. colors?: Nullable<Color4[][]>;
  57068. useVertexAlpha?: boolean;
  57069. }, scene: Nullable<Scene>): LinesMesh;
  57070. /**
  57071. * Creates a line mesh
  57072. * 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
  57073. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57074. * * The parameter `points` is an array successive Vector3
  57075. * * 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
  57076. * * The optional parameter `colors` is an array of successive Color4, one per line point
  57077. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  57078. * * When updating an instance, remember that only point positions can change, not the number of points
  57079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  57081. * @param name defines the name of the new line system
  57082. * @param options defines the options used to create the line system
  57083. * @param scene defines the hosting scene
  57084. * @returns a new line mesh
  57085. */
  57086. static CreateLines(name: string, options: {
  57087. points: Vector3[];
  57088. updatable?: boolean;
  57089. instance?: Nullable<LinesMesh>;
  57090. colors?: Color4[];
  57091. useVertexAlpha?: boolean;
  57092. }, scene?: Nullable<Scene>): LinesMesh;
  57093. /**
  57094. * Creates a dashed line mesh
  57095. * * 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
  57096. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  57097. * * The parameter `points` is an array successive Vector3
  57098. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  57099. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  57100. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  57101. * * 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
  57102. * * When updating an instance, remember that only point positions can change, not the number of points
  57103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57104. * @param name defines the name of the mesh
  57105. * @param options defines the options used to create the mesh
  57106. * @param scene defines the hosting scene
  57107. * @returns the dashed line mesh
  57108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  57109. */
  57110. static CreateDashedLines(name: string, options: {
  57111. points: Vector3[];
  57112. dashSize?: number;
  57113. gapSize?: number;
  57114. dashNb?: number;
  57115. updatable?: boolean;
  57116. instance?: LinesMesh;
  57117. }, scene?: Nullable<Scene>): LinesMesh;
  57118. /**
  57119. * 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.
  57120. * * 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.
  57121. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57122. * * 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.
  57123. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57124. * * 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
  57125. * * 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
  57126. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57131. * @param name defines the name of the mesh
  57132. * @param options defines the options used to create the mesh
  57133. * @param scene defines the hosting scene
  57134. * @returns the extruded shape mesh
  57135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57137. */
  57138. static ExtrudeShape(name: string, options: {
  57139. shape: Vector3[];
  57140. path: Vector3[];
  57141. scale?: number;
  57142. rotation?: number;
  57143. cap?: number;
  57144. updatable?: boolean;
  57145. sideOrientation?: number;
  57146. frontUVs?: Vector4;
  57147. backUVs?: Vector4;
  57148. instance?: Mesh;
  57149. invertUV?: boolean;
  57150. }, scene?: Nullable<Scene>): Mesh;
  57151. /**
  57152. * Creates an custom extruded shape mesh.
  57153. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57154. * * 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.
  57155. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57156. * * 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
  57157. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57158. * * 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
  57159. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57160. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57161. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57162. * * 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
  57163. * * 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
  57164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57169. * @param name defines the name of the mesh
  57170. * @param options defines the options used to create the mesh
  57171. * @param scene defines the hosting scene
  57172. * @returns the custom extruded shape mesh
  57173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57176. */
  57177. static ExtrudeShapeCustom(name: string, options: {
  57178. shape: Vector3[];
  57179. path: Vector3[];
  57180. scaleFunction?: any;
  57181. rotationFunction?: any;
  57182. ribbonCloseArray?: boolean;
  57183. ribbonClosePath?: boolean;
  57184. cap?: number;
  57185. updatable?: boolean;
  57186. sideOrientation?: number;
  57187. frontUVs?: Vector4;
  57188. backUVs?: Vector4;
  57189. instance?: Mesh;
  57190. invertUV?: boolean;
  57191. }, scene?: Nullable<Scene>): Mesh;
  57192. /**
  57193. * Creates lathe mesh.
  57194. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  57195. * * 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
  57196. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  57197. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  57198. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  57199. * * 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
  57200. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  57201. * * 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
  57202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57206. * @param name defines the name of the mesh
  57207. * @param options defines the options used to create the mesh
  57208. * @param scene defines the hosting scene
  57209. * @returns the lathe mesh
  57210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  57211. */
  57212. static CreateLathe(name: string, options: {
  57213. shape: Vector3[];
  57214. radius?: number;
  57215. tessellation?: number;
  57216. clip?: number;
  57217. arc?: number;
  57218. closed?: boolean;
  57219. updatable?: boolean;
  57220. sideOrientation?: number;
  57221. frontUVs?: Vector4;
  57222. backUVs?: Vector4;
  57223. cap?: number;
  57224. invertUV?: boolean;
  57225. }, scene?: Nullable<Scene>): Mesh;
  57226. /**
  57227. * Creates a tiled plane mesh
  57228. * * You can set a limited pattern arrangement with the tiles
  57229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57232. * @param name defines the name of the mesh
  57233. * @param options defines the options used to create the mesh
  57234. * @param scene defines the hosting scene
  57235. * @returns the plane mesh
  57236. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57237. */
  57238. static CreateTiledPlane(name: string, options: {
  57239. pattern?: number;
  57240. tileSize?: number;
  57241. tileWidth?: number;
  57242. tileHeight?: number;
  57243. size?: number;
  57244. width?: number;
  57245. height?: number;
  57246. alignHorizontal?: number;
  57247. alignVertical?: number;
  57248. sideOrientation?: number;
  57249. frontUVs?: Vector4;
  57250. backUVs?: Vector4;
  57251. updatable?: boolean;
  57252. }, scene?: Nullable<Scene>): Mesh;
  57253. /**
  57254. * Creates a plane mesh
  57255. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  57256. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  57257. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  57258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57261. * @param name defines the name of the mesh
  57262. * @param options defines the options used to create the mesh
  57263. * @param scene defines the hosting scene
  57264. * @returns the plane mesh
  57265. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  57266. */
  57267. static CreatePlane(name: string, options: {
  57268. size?: number;
  57269. width?: number;
  57270. height?: number;
  57271. sideOrientation?: number;
  57272. frontUVs?: Vector4;
  57273. backUVs?: Vector4;
  57274. updatable?: boolean;
  57275. sourcePlane?: Plane;
  57276. }, scene?: Nullable<Scene>): Mesh;
  57277. /**
  57278. * Creates a ground mesh
  57279. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  57280. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  57281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57282. * @param name defines the name of the mesh
  57283. * @param options defines the options used to create the mesh
  57284. * @param scene defines the hosting scene
  57285. * @returns the ground mesh
  57286. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57287. */
  57288. static CreateGround(name: string, options: {
  57289. width?: number;
  57290. height?: number;
  57291. subdivisions?: number;
  57292. subdivisionsX?: number;
  57293. subdivisionsY?: number;
  57294. updatable?: boolean;
  57295. }, scene?: Nullable<Scene>): Mesh;
  57296. /**
  57297. * Creates a tiled ground mesh
  57298. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57299. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57300. * * 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
  57301. * * 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
  57302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57303. * @param name defines the name of the mesh
  57304. * @param options defines the options used to create the mesh
  57305. * @param scene defines the hosting scene
  57306. * @returns the tiled ground mesh
  57307. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57308. */
  57309. static CreateTiledGround(name: string, options: {
  57310. xmin: number;
  57311. zmin: number;
  57312. xmax: number;
  57313. zmax: number;
  57314. subdivisions?: {
  57315. w: number;
  57316. h: number;
  57317. };
  57318. precision?: {
  57319. w: number;
  57320. h: number;
  57321. };
  57322. updatable?: boolean;
  57323. }, scene?: Nullable<Scene>): Mesh;
  57324. /**
  57325. * Creates a ground mesh from a height map
  57326. * * The parameter `url` sets the URL of the height map image resource.
  57327. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57328. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57329. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57330. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57331. * * 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.
  57332. * * 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).
  57333. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57335. * @param name defines the name of the mesh
  57336. * @param url defines the url to the height map
  57337. * @param options defines the options used to create the mesh
  57338. * @param scene defines the hosting scene
  57339. * @returns the ground mesh
  57340. * @see https://doc.babylonjs.com/babylon101/height_map
  57341. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57342. */
  57343. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57344. width?: number;
  57345. height?: number;
  57346. subdivisions?: number;
  57347. minHeight?: number;
  57348. maxHeight?: number;
  57349. colorFilter?: Color3;
  57350. alphaFilter?: number;
  57351. updatable?: boolean;
  57352. onReady?: (mesh: GroundMesh) => void;
  57353. }, scene?: Nullable<Scene>): GroundMesh;
  57354. /**
  57355. * Creates a polygon mesh
  57356. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57357. * * 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
  57358. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57361. * * Remember you can only change the shape positions, not their number when updating a polygon
  57362. * @param name defines the name of the mesh
  57363. * @param options defines the options used to create the mesh
  57364. * @param scene defines the hosting scene
  57365. * @param earcutInjection can be used to inject your own earcut reference
  57366. * @returns the polygon mesh
  57367. */
  57368. static CreatePolygon(name: string, options: {
  57369. shape: Vector3[];
  57370. holes?: Vector3[][];
  57371. depth?: number;
  57372. faceUV?: Vector4[];
  57373. faceColors?: Color4[];
  57374. updatable?: boolean;
  57375. sideOrientation?: number;
  57376. frontUVs?: Vector4;
  57377. backUVs?: Vector4;
  57378. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57379. /**
  57380. * Creates an extruded polygon mesh, with depth in the Y direction.
  57381. * * 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)
  57382. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57383. * @param name defines the name of the mesh
  57384. * @param options defines the options used to create the mesh
  57385. * @param scene defines the hosting scene
  57386. * @param earcutInjection can be used to inject your own earcut reference
  57387. * @returns the polygon mesh
  57388. */
  57389. static ExtrudePolygon(name: string, options: {
  57390. shape: Vector3[];
  57391. holes?: Vector3[][];
  57392. depth?: number;
  57393. faceUV?: Vector4[];
  57394. faceColors?: Color4[];
  57395. updatable?: boolean;
  57396. sideOrientation?: number;
  57397. frontUVs?: Vector4;
  57398. backUVs?: Vector4;
  57399. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57400. /**
  57401. * Creates a tube mesh.
  57402. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57403. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57404. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57405. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57406. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57407. * * 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)
  57408. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57409. * * 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
  57410. * * 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
  57411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57413. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57415. * @param name defines the name of the mesh
  57416. * @param options defines the options used to create the mesh
  57417. * @param scene defines the hosting scene
  57418. * @returns the tube mesh
  57419. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57420. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57421. */
  57422. static CreateTube(name: string, options: {
  57423. path: Vector3[];
  57424. radius?: number;
  57425. tessellation?: number;
  57426. radiusFunction?: {
  57427. (i: number, distance: number): number;
  57428. };
  57429. cap?: number;
  57430. arc?: number;
  57431. updatable?: boolean;
  57432. sideOrientation?: number;
  57433. frontUVs?: Vector4;
  57434. backUVs?: Vector4;
  57435. instance?: Mesh;
  57436. invertUV?: boolean;
  57437. }, scene?: Nullable<Scene>): Mesh;
  57438. /**
  57439. * Creates a polyhedron mesh
  57440. * * 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
  57441. * * The parameter `size` (positive float, default 1) sets the polygon size
  57442. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57443. * * 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`
  57444. * * 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
  57445. * * 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)`)
  57446. * * 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
  57447. * * 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
  57448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57451. * @param name defines the name of the mesh
  57452. * @param options defines the options used to create the mesh
  57453. * @param scene defines the hosting scene
  57454. * @returns the polyhedron mesh
  57455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57456. */
  57457. static CreatePolyhedron(name: string, options: {
  57458. type?: number;
  57459. size?: number;
  57460. sizeX?: number;
  57461. sizeY?: number;
  57462. sizeZ?: number;
  57463. custom?: any;
  57464. faceUV?: Vector4[];
  57465. faceColors?: Color4[];
  57466. flat?: boolean;
  57467. updatable?: boolean;
  57468. sideOrientation?: number;
  57469. frontUVs?: Vector4;
  57470. backUVs?: Vector4;
  57471. }, scene?: Nullable<Scene>): Mesh;
  57472. /**
  57473. * Creates a decal mesh.
  57474. * 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
  57475. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57476. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57477. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57478. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57479. * @param name defines the name of the mesh
  57480. * @param sourceMesh defines the mesh where the decal must be applied
  57481. * @param options defines the options used to create the mesh
  57482. * @param scene defines the hosting scene
  57483. * @returns the decal mesh
  57484. * @see https://doc.babylonjs.com/how_to/decals
  57485. */
  57486. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57487. position?: Vector3;
  57488. normal?: Vector3;
  57489. size?: Vector3;
  57490. angle?: number;
  57491. }): Mesh;
  57492. }
  57493. }
  57494. declare module "babylonjs/Meshes/meshSimplification" {
  57495. import { Mesh } from "babylonjs/Meshes/mesh";
  57496. /**
  57497. * A simplifier interface for future simplification implementations
  57498. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57499. */
  57500. export interface ISimplifier {
  57501. /**
  57502. * Simplification of a given mesh according to the given settings.
  57503. * Since this requires computation, it is assumed that the function runs async.
  57504. * @param settings The settings of the simplification, including quality and distance
  57505. * @param successCallback A callback that will be called after the mesh was simplified.
  57506. * @param errorCallback in case of an error, this callback will be called. optional.
  57507. */
  57508. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57509. }
  57510. /**
  57511. * Expected simplification settings.
  57512. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57513. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57514. */
  57515. export interface ISimplificationSettings {
  57516. /**
  57517. * Gets or sets the expected quality
  57518. */
  57519. quality: number;
  57520. /**
  57521. * Gets or sets the distance when this optimized version should be used
  57522. */
  57523. distance: number;
  57524. /**
  57525. * Gets an already optimized mesh
  57526. */
  57527. optimizeMesh?: boolean;
  57528. }
  57529. /**
  57530. * Class used to specify simplification options
  57531. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57532. */
  57533. export class SimplificationSettings implements ISimplificationSettings {
  57534. /** expected quality */
  57535. quality: number;
  57536. /** distance when this optimized version should be used */
  57537. distance: number;
  57538. /** already optimized mesh */
  57539. optimizeMesh?: boolean | undefined;
  57540. /**
  57541. * Creates a SimplificationSettings
  57542. * @param quality expected quality
  57543. * @param distance distance when this optimized version should be used
  57544. * @param optimizeMesh already optimized mesh
  57545. */
  57546. constructor(
  57547. /** expected quality */
  57548. quality: number,
  57549. /** distance when this optimized version should be used */
  57550. distance: number,
  57551. /** already optimized mesh */
  57552. optimizeMesh?: boolean | undefined);
  57553. }
  57554. /**
  57555. * Interface used to define a simplification task
  57556. */
  57557. export interface ISimplificationTask {
  57558. /**
  57559. * Array of settings
  57560. */
  57561. settings: Array<ISimplificationSettings>;
  57562. /**
  57563. * Simplification type
  57564. */
  57565. simplificationType: SimplificationType;
  57566. /**
  57567. * Mesh to simplify
  57568. */
  57569. mesh: Mesh;
  57570. /**
  57571. * Callback called on success
  57572. */
  57573. successCallback?: () => void;
  57574. /**
  57575. * Defines if parallel processing can be used
  57576. */
  57577. parallelProcessing: boolean;
  57578. }
  57579. /**
  57580. * Queue used to order the simplification tasks
  57581. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57582. */
  57583. export class SimplificationQueue {
  57584. private _simplificationArray;
  57585. /**
  57586. * Gets a boolean indicating that the process is still running
  57587. */
  57588. running: boolean;
  57589. /**
  57590. * Creates a new queue
  57591. */
  57592. constructor();
  57593. /**
  57594. * Adds a new simplification task
  57595. * @param task defines a task to add
  57596. */
  57597. addTask(task: ISimplificationTask): void;
  57598. /**
  57599. * Execute next task
  57600. */
  57601. executeNext(): void;
  57602. /**
  57603. * Execute a simplification task
  57604. * @param task defines the task to run
  57605. */
  57606. runSimplification(task: ISimplificationTask): void;
  57607. private getSimplifier;
  57608. }
  57609. /**
  57610. * The implemented types of simplification
  57611. * At the moment only Quadratic Error Decimation is implemented
  57612. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57613. */
  57614. export enum SimplificationType {
  57615. /** Quadratic error decimation */
  57616. QUADRATIC = 0
  57617. }
  57618. }
  57619. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57620. import { Scene } from "babylonjs/scene";
  57621. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57622. import { ISceneComponent } from "babylonjs/sceneComponent";
  57623. module "babylonjs/scene" {
  57624. interface Scene {
  57625. /** @hidden (Backing field) */
  57626. _simplificationQueue: SimplificationQueue;
  57627. /**
  57628. * Gets or sets the simplification queue attached to the scene
  57629. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57630. */
  57631. simplificationQueue: SimplificationQueue;
  57632. }
  57633. }
  57634. module "babylonjs/Meshes/mesh" {
  57635. interface Mesh {
  57636. /**
  57637. * Simplify the mesh according to the given array of settings.
  57638. * Function will return immediately and will simplify async
  57639. * @param settings a collection of simplification settings
  57640. * @param parallelProcessing should all levels calculate parallel or one after the other
  57641. * @param simplificationType the type of simplification to run
  57642. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57643. * @returns the current mesh
  57644. */
  57645. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57646. }
  57647. }
  57648. /**
  57649. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57650. * created in a scene
  57651. */
  57652. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57653. /**
  57654. * The component name helpfull to identify the component in the list of scene components.
  57655. */
  57656. readonly name: string;
  57657. /**
  57658. * The scene the component belongs to.
  57659. */
  57660. scene: Scene;
  57661. /**
  57662. * Creates a new instance of the component for the given scene
  57663. * @param scene Defines the scene to register the component in
  57664. */
  57665. constructor(scene: Scene);
  57666. /**
  57667. * Registers the component in a given scene
  57668. */
  57669. register(): void;
  57670. /**
  57671. * Rebuilds the elements related to this component in case of
  57672. * context lost for instance.
  57673. */
  57674. rebuild(): void;
  57675. /**
  57676. * Disposes the component and the associated ressources
  57677. */
  57678. dispose(): void;
  57679. private _beforeCameraUpdate;
  57680. }
  57681. }
  57682. declare module "babylonjs/Meshes/Builders/index" {
  57683. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57684. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57685. export * from "babylonjs/Meshes/Builders/discBuilder";
  57686. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57687. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57688. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57689. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57690. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57691. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57692. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57693. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57694. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57695. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57696. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57697. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57698. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57699. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57700. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57701. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57702. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57703. }
  57704. declare module "babylonjs/Meshes/index" {
  57705. export * from "babylonjs/Meshes/abstractMesh";
  57706. export * from "babylonjs/Meshes/buffer";
  57707. export * from "babylonjs/Meshes/Compression/index";
  57708. export * from "babylonjs/Meshes/csg";
  57709. export * from "babylonjs/Meshes/geometry";
  57710. export * from "babylonjs/Meshes/groundMesh";
  57711. export * from "babylonjs/Meshes/trailMesh";
  57712. export * from "babylonjs/Meshes/instancedMesh";
  57713. export * from "babylonjs/Meshes/linesMesh";
  57714. export * from "babylonjs/Meshes/mesh";
  57715. export * from "babylonjs/Meshes/mesh.vertexData";
  57716. export * from "babylonjs/Meshes/meshBuilder";
  57717. export * from "babylonjs/Meshes/meshSimplification";
  57718. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57719. export * from "babylonjs/Meshes/polygonMesh";
  57720. export * from "babylonjs/Meshes/subMesh";
  57721. export * from "babylonjs/Meshes/meshLODLevel";
  57722. export * from "babylonjs/Meshes/transformNode";
  57723. export * from "babylonjs/Meshes/Builders/index";
  57724. export * from "babylonjs/Meshes/dataBuffer";
  57725. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57726. }
  57727. declare module "babylonjs/Morph/index" {
  57728. export * from "babylonjs/Morph/morphTarget";
  57729. export * from "babylonjs/Morph/morphTargetManager";
  57730. }
  57731. declare module "babylonjs/Navigation/INavigationEngine" {
  57732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57733. import { Vector3 } from "babylonjs/Maths/math";
  57734. import { Mesh } from "babylonjs/Meshes/mesh";
  57735. import { Scene } from "babylonjs/scene";
  57736. /**
  57737. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57738. */
  57739. export interface INavigationEnginePlugin {
  57740. /**
  57741. * plugin name
  57742. */
  57743. name: string;
  57744. /**
  57745. * Creates a navigation mesh
  57746. * @param meshes array of all the geometry used to compute the navigatio mesh
  57747. * @param parameters bunch of parameters used to filter geometry
  57748. */
  57749. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57750. /**
  57751. * Create a navigation mesh debug mesh
  57752. * @param scene is where the mesh will be added
  57753. * @returns debug display mesh
  57754. */
  57755. createDebugNavMesh(scene: Scene): Mesh;
  57756. /**
  57757. * Get a navigation mesh constrained position, closest to the parameter position
  57758. * @param position world position
  57759. * @returns the closest point to position constrained by the navigation mesh
  57760. */
  57761. getClosestPoint(position: Vector3): Vector3;
  57762. /**
  57763. * Get a navigation mesh constrained position, within a particular radius
  57764. * @param position world position
  57765. * @param maxRadius the maximum distance to the constrained world position
  57766. * @returns the closest point to position constrained by the navigation mesh
  57767. */
  57768. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57769. /**
  57770. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57771. * @param start world position
  57772. * @param end world position
  57773. * @returns array containing world position composing the path
  57774. */
  57775. computePath(start: Vector3, end: Vector3): Vector3[];
  57776. /**
  57777. * If this plugin is supported
  57778. * @returns true if plugin is supported
  57779. */
  57780. isSupported(): boolean;
  57781. /**
  57782. * Create a new Crowd so you can add agents
  57783. * @param maxAgents the maximum agent count in the crowd
  57784. * @param maxAgentRadius the maximum radius an agent can have
  57785. * @param scene to attach the crowd to
  57786. * @returns the crowd you can add agents to
  57787. */
  57788. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57789. /**
  57790. * Release all resources
  57791. */
  57792. dispose(): void;
  57793. }
  57794. /**
  57795. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57796. */
  57797. export interface ICrowd {
  57798. /**
  57799. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57800. * You can attach anything to that node. The node position is updated in the scene update tick.
  57801. * @param pos world position that will be constrained by the navigation mesh
  57802. * @param parameters agent parameters
  57803. * @param transform hooked to the agent that will be update by the scene
  57804. * @returns agent index
  57805. */
  57806. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57807. /**
  57808. * Returns the agent position in world space
  57809. * @param index agent index returned by addAgent
  57810. * @returns world space position
  57811. */
  57812. getAgentPosition(index: number): Vector3;
  57813. /**
  57814. * Gets the agent velocity in world space
  57815. * @param index agent index returned by addAgent
  57816. * @returns world space velocity
  57817. */
  57818. getAgentVelocity(index: number): Vector3;
  57819. /**
  57820. * remove a particular agent previously created
  57821. * @param index agent index returned by addAgent
  57822. */
  57823. removeAgent(index: number): void;
  57824. /**
  57825. * get the list of all agents attached to this crowd
  57826. * @returns list of agent indices
  57827. */
  57828. getAgents(): number[];
  57829. /**
  57830. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57831. * @param deltaTime in seconds
  57832. */
  57833. update(deltaTime: number): void;
  57834. /**
  57835. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57836. * @param index agent index returned by addAgent
  57837. * @param destination targeted world position
  57838. */
  57839. agentGoto(index: number, destination: Vector3): void;
  57840. /**
  57841. * Release all resources
  57842. */
  57843. dispose(): void;
  57844. }
  57845. /**
  57846. * Configures an agent
  57847. */
  57848. export interface IAgentParameters {
  57849. /**
  57850. * Agent radius. [Limit: >= 0]
  57851. */
  57852. radius: number;
  57853. /**
  57854. * Agent height. [Limit: > 0]
  57855. */
  57856. height: number;
  57857. /**
  57858. * Maximum allowed acceleration. [Limit: >= 0]
  57859. */
  57860. maxAcceleration: number;
  57861. /**
  57862. * Maximum allowed speed. [Limit: >= 0]
  57863. */
  57864. maxSpeed: number;
  57865. /**
  57866. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57867. */
  57868. collisionQueryRange: number;
  57869. /**
  57870. * The path visibility optimization range. [Limit: > 0]
  57871. */
  57872. pathOptimizationRange: number;
  57873. /**
  57874. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57875. */
  57876. separationWeight: number;
  57877. }
  57878. /**
  57879. * Configures the navigation mesh creation
  57880. */
  57881. export interface INavMeshParameters {
  57882. /**
  57883. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57884. */
  57885. cs: number;
  57886. /**
  57887. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57888. */
  57889. ch: number;
  57890. /**
  57891. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57892. */
  57893. walkableSlopeAngle: number;
  57894. /**
  57895. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57896. * be considered walkable. [Limit: >= 3] [Units: vx]
  57897. */
  57898. walkableHeight: number;
  57899. /**
  57900. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57901. */
  57902. walkableClimb: number;
  57903. /**
  57904. * The distance to erode/shrink the walkable area of the heightfield away from
  57905. * obstructions. [Limit: >=0] [Units: vx]
  57906. */
  57907. walkableRadius: number;
  57908. /**
  57909. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57910. */
  57911. maxEdgeLen: number;
  57912. /**
  57913. * The maximum distance a simplfied contour's border edges should deviate
  57914. * the original raw contour. [Limit: >=0] [Units: vx]
  57915. */
  57916. maxSimplificationError: number;
  57917. /**
  57918. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57919. */
  57920. minRegionArea: number;
  57921. /**
  57922. * Any regions with a span count smaller than this value will, if possible,
  57923. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57924. */
  57925. mergeRegionArea: number;
  57926. /**
  57927. * The maximum number of vertices allowed for polygons generated during the
  57928. * contour to polygon conversion process. [Limit: >= 3]
  57929. */
  57930. maxVertsPerPoly: number;
  57931. /**
  57932. * Sets the sampling distance to use when generating the detail mesh.
  57933. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57934. */
  57935. detailSampleDist: number;
  57936. /**
  57937. * The maximum distance the detail mesh surface should deviate from heightfield
  57938. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57939. */
  57940. detailSampleMaxError: number;
  57941. }
  57942. }
  57943. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57944. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57945. import { Mesh } from "babylonjs/Meshes/mesh";
  57946. import { Scene } from "babylonjs/scene";
  57947. import { Vector3 } from "babylonjs/Maths/math";
  57948. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57949. /**
  57950. * RecastJS navigation plugin
  57951. */
  57952. export class RecastJSPlugin implements INavigationEnginePlugin {
  57953. /**
  57954. * Reference to the Recast library
  57955. */
  57956. bjsRECAST: any;
  57957. /**
  57958. * plugin name
  57959. */
  57960. name: string;
  57961. /**
  57962. * the first navmesh created. We might extend this to support multiple navmeshes
  57963. */
  57964. navMesh: any;
  57965. /**
  57966. * Initializes the recastJS plugin
  57967. * @param recastInjection can be used to inject your own recast reference
  57968. */
  57969. constructor(recastInjection?: any);
  57970. /**
  57971. * Creates a navigation mesh
  57972. * @param meshes array of all the geometry used to compute the navigatio mesh
  57973. * @param parameters bunch of parameters used to filter geometry
  57974. */
  57975. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57976. /**
  57977. * Create a navigation mesh debug mesh
  57978. * @param scene is where the mesh will be added
  57979. * @returns debug display mesh
  57980. */
  57981. createDebugNavMesh(scene: Scene): Mesh;
  57982. /**
  57983. * Get a navigation mesh constrained position, closest to the parameter position
  57984. * @param position world position
  57985. * @returns the closest point to position constrained by the navigation mesh
  57986. */
  57987. getClosestPoint(position: Vector3): Vector3;
  57988. /**
  57989. * Get a navigation mesh constrained position, within a particular radius
  57990. * @param position world position
  57991. * @param maxRadius the maximum distance to the constrained world position
  57992. * @returns the closest point to position constrained by the navigation mesh
  57993. */
  57994. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57995. /**
  57996. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57997. * @param start world position
  57998. * @param end world position
  57999. * @returns array containing world position composing the path
  58000. */
  58001. computePath(start: Vector3, end: Vector3): Vector3[];
  58002. /**
  58003. * Create a new Crowd so you can add agents
  58004. * @param maxAgents the maximum agent count in the crowd
  58005. * @param maxAgentRadius the maximum radius an agent can have
  58006. * @param scene to attach the crowd to
  58007. * @returns the crowd you can add agents to
  58008. */
  58009. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  58010. /**
  58011. * Disposes
  58012. */
  58013. dispose(): void;
  58014. /**
  58015. * If this plugin is supported
  58016. * @returns true if plugin is supported
  58017. */
  58018. isSupported(): boolean;
  58019. }
  58020. /**
  58021. * Recast detour crowd implementation
  58022. */
  58023. export class RecastJSCrowd implements ICrowd {
  58024. /**
  58025. * Recast/detour plugin
  58026. */
  58027. bjsRECASTPlugin: RecastJSPlugin;
  58028. /**
  58029. * Link to the detour crowd
  58030. */
  58031. recastCrowd: any;
  58032. /**
  58033. * One transform per agent
  58034. */
  58035. transforms: TransformNode[];
  58036. /**
  58037. * All agents created
  58038. */
  58039. agents: number[];
  58040. /**
  58041. * Link to the scene is kept to unregister the crowd from the scene
  58042. */
  58043. private _scene;
  58044. /**
  58045. * Observer for crowd updates
  58046. */
  58047. private _onBeforeAnimationsObserver;
  58048. /**
  58049. * Constructor
  58050. * @param plugin recastJS plugin
  58051. * @param maxAgents the maximum agent count in the crowd
  58052. * @param maxAgentRadius the maximum radius an agent can have
  58053. * @param scene to attach the crowd to
  58054. * @returns the crowd you can add agents to
  58055. */
  58056. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  58057. /**
  58058. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  58059. * You can attach anything to that node. The node position is updated in the scene update tick.
  58060. * @param pos world position that will be constrained by the navigation mesh
  58061. * @param parameters agent parameters
  58062. * @param transform hooked to the agent that will be update by the scene
  58063. * @returns agent index
  58064. */
  58065. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  58066. /**
  58067. * Returns the agent position in world space
  58068. * @param index agent index returned by addAgent
  58069. * @returns world space position
  58070. */
  58071. getAgentPosition(index: number): Vector3;
  58072. /**
  58073. * Returns the agent velocity in world space
  58074. * @param index agent index returned by addAgent
  58075. * @returns world space velocity
  58076. */
  58077. getAgentVelocity(index: number): Vector3;
  58078. /**
  58079. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  58080. * @param index agent index returned by addAgent
  58081. * @param destination targeted world position
  58082. */
  58083. agentGoto(index: number, destination: Vector3): void;
  58084. /**
  58085. * remove a particular agent previously created
  58086. * @param index agent index returned by addAgent
  58087. */
  58088. removeAgent(index: number): void;
  58089. /**
  58090. * get the list of all agents attached to this crowd
  58091. * @returns list of agent indices
  58092. */
  58093. getAgents(): number[];
  58094. /**
  58095. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  58096. * @param deltaTime in seconds
  58097. */
  58098. update(deltaTime: number): void;
  58099. /**
  58100. * Release all resources
  58101. */
  58102. dispose(): void;
  58103. }
  58104. }
  58105. declare module "babylonjs/Navigation/Plugins/index" {
  58106. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  58107. }
  58108. declare module "babylonjs/Navigation/index" {
  58109. export * from "babylonjs/Navigation/INavigationEngine";
  58110. export * from "babylonjs/Navigation/Plugins/index";
  58111. }
  58112. declare module "babylonjs/Offline/database" {
  58113. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  58114. /**
  58115. * Class used to enable access to IndexedDB
  58116. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  58117. */
  58118. export class Database implements IOfflineProvider {
  58119. private _callbackManifestChecked;
  58120. private _currentSceneUrl;
  58121. private _db;
  58122. private _enableSceneOffline;
  58123. private _enableTexturesOffline;
  58124. private _manifestVersionFound;
  58125. private _mustUpdateRessources;
  58126. private _hasReachedQuota;
  58127. private _isSupported;
  58128. private _idbFactory;
  58129. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  58130. private static IsUASupportingBlobStorage;
  58131. /**
  58132. * Gets a boolean indicating if Database storate is enabled (off by default)
  58133. */
  58134. static IDBStorageEnabled: boolean;
  58135. /**
  58136. * Gets a boolean indicating if scene must be saved in the database
  58137. */
  58138. readonly enableSceneOffline: boolean;
  58139. /**
  58140. * Gets a boolean indicating if textures must be saved in the database
  58141. */
  58142. readonly enableTexturesOffline: boolean;
  58143. /**
  58144. * Creates a new Database
  58145. * @param urlToScene defines the url to load the scene
  58146. * @param callbackManifestChecked defines the callback to use when manifest is checked
  58147. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  58148. */
  58149. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  58150. private static _ParseURL;
  58151. private static _ReturnFullUrlLocation;
  58152. private _checkManifestFile;
  58153. /**
  58154. * Open the database and make it available
  58155. * @param successCallback defines the callback to call on success
  58156. * @param errorCallback defines the callback to call on error
  58157. */
  58158. open(successCallback: () => void, errorCallback: () => void): void;
  58159. /**
  58160. * Loads an image from the database
  58161. * @param url defines the url to load from
  58162. * @param image defines the target DOM image
  58163. */
  58164. loadImage(url: string, image: HTMLImageElement): void;
  58165. private _loadImageFromDBAsync;
  58166. private _saveImageIntoDBAsync;
  58167. private _checkVersionFromDB;
  58168. private _loadVersionFromDBAsync;
  58169. private _saveVersionIntoDBAsync;
  58170. /**
  58171. * Loads a file from database
  58172. * @param url defines the URL to load from
  58173. * @param sceneLoaded defines a callback to call on success
  58174. * @param progressCallBack defines a callback to call when progress changed
  58175. * @param errorCallback defines a callback to call on error
  58176. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  58177. */
  58178. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  58179. private _loadFileAsync;
  58180. private _saveFileAsync;
  58181. /**
  58182. * Validates if xhr data is correct
  58183. * @param xhr defines the request to validate
  58184. * @param dataType defines the expected data type
  58185. * @returns true if data is correct
  58186. */
  58187. private static _ValidateXHRData;
  58188. }
  58189. }
  58190. declare module "babylonjs/Offline/index" {
  58191. export * from "babylonjs/Offline/database";
  58192. export * from "babylonjs/Offline/IOfflineProvider";
  58193. }
  58194. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  58195. /** @hidden */
  58196. export var gpuUpdateParticlesPixelShader: {
  58197. name: string;
  58198. shader: string;
  58199. };
  58200. }
  58201. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  58202. /** @hidden */
  58203. export var gpuUpdateParticlesVertexShader: {
  58204. name: string;
  58205. shader: string;
  58206. };
  58207. }
  58208. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  58209. /** @hidden */
  58210. export var clipPlaneFragmentDeclaration2: {
  58211. name: string;
  58212. shader: string;
  58213. };
  58214. }
  58215. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  58216. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  58217. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58218. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58219. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58220. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58221. /** @hidden */
  58222. export var gpuRenderParticlesPixelShader: {
  58223. name: string;
  58224. shader: string;
  58225. };
  58226. }
  58227. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  58228. /** @hidden */
  58229. export var clipPlaneVertexDeclaration2: {
  58230. name: string;
  58231. shader: string;
  58232. };
  58233. }
  58234. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  58235. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  58236. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58237. /** @hidden */
  58238. export var gpuRenderParticlesVertexShader: {
  58239. name: string;
  58240. shader: string;
  58241. };
  58242. }
  58243. declare module "babylonjs/Particles/gpuParticleSystem" {
  58244. import { Nullable } from "babylonjs/types";
  58245. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  58246. import { Observable } from "babylonjs/Misc/observable";
  58247. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58248. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58249. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  58250. import { Scene, IDisposable } from "babylonjs/scene";
  58251. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  58252. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58253. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  58254. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  58255. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  58256. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  58257. /**
  58258. * This represents a GPU particle system in Babylon
  58259. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  58260. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  58261. */
  58262. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  58263. /**
  58264. * The layer mask we are rendering the particles through.
  58265. */
  58266. layerMask: number;
  58267. private _capacity;
  58268. private _activeCount;
  58269. private _currentActiveCount;
  58270. private _accumulatedCount;
  58271. private _renderEffect;
  58272. private _updateEffect;
  58273. private _buffer0;
  58274. private _buffer1;
  58275. private _spriteBuffer;
  58276. private _updateVAO;
  58277. private _renderVAO;
  58278. private _targetIndex;
  58279. private _sourceBuffer;
  58280. private _targetBuffer;
  58281. private _engine;
  58282. private _currentRenderId;
  58283. private _started;
  58284. private _stopped;
  58285. private _timeDelta;
  58286. private _randomTexture;
  58287. private _randomTexture2;
  58288. private _attributesStrideSize;
  58289. private _updateEffectOptions;
  58290. private _randomTextureSize;
  58291. private _actualFrame;
  58292. private readonly _rawTextureWidth;
  58293. /**
  58294. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58295. */
  58296. static readonly IsSupported: boolean;
  58297. /**
  58298. * An event triggered when the system is disposed.
  58299. */
  58300. onDisposeObservable: Observable<GPUParticleSystem>;
  58301. /**
  58302. * Gets the maximum number of particles active at the same time.
  58303. * @returns The max number of active particles.
  58304. */
  58305. getCapacity(): number;
  58306. /**
  58307. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58308. * to override the particles.
  58309. */
  58310. forceDepthWrite: boolean;
  58311. /**
  58312. * Gets or set the number of active particles
  58313. */
  58314. activeParticleCount: number;
  58315. private _preWarmDone;
  58316. /**
  58317. * Is this system ready to be used/rendered
  58318. * @return true if the system is ready
  58319. */
  58320. isReady(): boolean;
  58321. /**
  58322. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58323. * @returns True if it has been started, otherwise false.
  58324. */
  58325. isStarted(): boolean;
  58326. /**
  58327. * Starts the particle system and begins to emit
  58328. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58329. */
  58330. start(delay?: number): void;
  58331. /**
  58332. * Stops the particle system.
  58333. */
  58334. stop(): void;
  58335. /**
  58336. * Remove all active particles
  58337. */
  58338. reset(): void;
  58339. /**
  58340. * Returns the string "GPUParticleSystem"
  58341. * @returns a string containing the class name
  58342. */
  58343. getClassName(): string;
  58344. private _colorGradientsTexture;
  58345. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58346. /**
  58347. * Adds a new color gradient
  58348. * @param gradient defines the gradient to use (between 0 and 1)
  58349. * @param color1 defines the color to affect to the specified gradient
  58350. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58351. * @returns the current particle system
  58352. */
  58353. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58354. /**
  58355. * Remove a specific color gradient
  58356. * @param gradient defines the gradient to remove
  58357. * @returns the current particle system
  58358. */
  58359. removeColorGradient(gradient: number): GPUParticleSystem;
  58360. private _angularSpeedGradientsTexture;
  58361. private _sizeGradientsTexture;
  58362. private _velocityGradientsTexture;
  58363. private _limitVelocityGradientsTexture;
  58364. private _dragGradientsTexture;
  58365. private _addFactorGradient;
  58366. /**
  58367. * Adds a new size gradient
  58368. * @param gradient defines the gradient to use (between 0 and 1)
  58369. * @param factor defines the size factor to affect to the specified gradient
  58370. * @returns the current particle system
  58371. */
  58372. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58373. /**
  58374. * Remove a specific size gradient
  58375. * @param gradient defines the gradient to remove
  58376. * @returns the current particle system
  58377. */
  58378. removeSizeGradient(gradient: number): GPUParticleSystem;
  58379. /**
  58380. * Adds a new angular speed gradient
  58381. * @param gradient defines the gradient to use (between 0 and 1)
  58382. * @param factor defines the angular speed to affect to the specified gradient
  58383. * @returns the current particle system
  58384. */
  58385. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58386. /**
  58387. * Remove a specific angular speed gradient
  58388. * @param gradient defines the gradient to remove
  58389. * @returns the current particle system
  58390. */
  58391. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58392. /**
  58393. * Adds a new velocity gradient
  58394. * @param gradient defines the gradient to use (between 0 and 1)
  58395. * @param factor defines the velocity to affect to the specified gradient
  58396. * @returns the current particle system
  58397. */
  58398. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58399. /**
  58400. * Remove a specific velocity gradient
  58401. * @param gradient defines the gradient to remove
  58402. * @returns the current particle system
  58403. */
  58404. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58405. /**
  58406. * Adds a new limit velocity gradient
  58407. * @param gradient defines the gradient to use (between 0 and 1)
  58408. * @param factor defines the limit velocity value to affect to the specified gradient
  58409. * @returns the current particle system
  58410. */
  58411. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58412. /**
  58413. * Remove a specific limit velocity gradient
  58414. * @param gradient defines the gradient to remove
  58415. * @returns the current particle system
  58416. */
  58417. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58418. /**
  58419. * Adds a new drag gradient
  58420. * @param gradient defines the gradient to use (between 0 and 1)
  58421. * @param factor defines the drag value to affect to the specified gradient
  58422. * @returns the current particle system
  58423. */
  58424. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58425. /**
  58426. * Remove a specific drag gradient
  58427. * @param gradient defines the gradient to remove
  58428. * @returns the current particle system
  58429. */
  58430. removeDragGradient(gradient: number): GPUParticleSystem;
  58431. /**
  58432. * Not supported by GPUParticleSystem
  58433. * @param gradient defines the gradient to use (between 0 and 1)
  58434. * @param factor defines the emit rate value to affect to the specified gradient
  58435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58436. * @returns the current particle system
  58437. */
  58438. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58439. /**
  58440. * Not supported by GPUParticleSystem
  58441. * @param gradient defines the gradient to remove
  58442. * @returns the current particle system
  58443. */
  58444. removeEmitRateGradient(gradient: number): IParticleSystem;
  58445. /**
  58446. * Not supported by GPUParticleSystem
  58447. * @param gradient defines the gradient to use (between 0 and 1)
  58448. * @param factor defines the start size value to affect to the specified gradient
  58449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58450. * @returns the current particle system
  58451. */
  58452. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58453. /**
  58454. * Not supported by GPUParticleSystem
  58455. * @param gradient defines the gradient to remove
  58456. * @returns the current particle system
  58457. */
  58458. removeStartSizeGradient(gradient: number): IParticleSystem;
  58459. /**
  58460. * Not supported by GPUParticleSystem
  58461. * @param gradient defines the gradient to use (between 0 and 1)
  58462. * @param min defines the color remap minimal range
  58463. * @param max defines the color remap maximal range
  58464. * @returns the current particle system
  58465. */
  58466. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58467. /**
  58468. * Not supported by GPUParticleSystem
  58469. * @param gradient defines the gradient to remove
  58470. * @returns the current particle system
  58471. */
  58472. removeColorRemapGradient(): IParticleSystem;
  58473. /**
  58474. * Not supported by GPUParticleSystem
  58475. * @param gradient defines the gradient to use (between 0 and 1)
  58476. * @param min defines the alpha remap minimal range
  58477. * @param max defines the alpha remap maximal range
  58478. * @returns the current particle system
  58479. */
  58480. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58481. /**
  58482. * Not supported by GPUParticleSystem
  58483. * @param gradient defines the gradient to remove
  58484. * @returns the current particle system
  58485. */
  58486. removeAlphaRemapGradient(): IParticleSystem;
  58487. /**
  58488. * Not supported by GPUParticleSystem
  58489. * @param gradient defines the gradient to use (between 0 and 1)
  58490. * @param color defines the color to affect to the specified gradient
  58491. * @returns the current particle system
  58492. */
  58493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58494. /**
  58495. * Not supported by GPUParticleSystem
  58496. * @param gradient defines the gradient to remove
  58497. * @returns the current particle system
  58498. */
  58499. removeRampGradient(): IParticleSystem;
  58500. /**
  58501. * Not supported by GPUParticleSystem
  58502. * @returns the list of ramp gradients
  58503. */
  58504. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58505. /**
  58506. * Not supported by GPUParticleSystem
  58507. * Gets or sets a boolean indicating that ramp gradients must be used
  58508. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58509. */
  58510. useRampGradients: boolean;
  58511. /**
  58512. * Not supported by GPUParticleSystem
  58513. * @param gradient defines the gradient to use (between 0 and 1)
  58514. * @param factor defines the life time factor to affect to the specified gradient
  58515. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58516. * @returns the current particle system
  58517. */
  58518. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58519. /**
  58520. * Not supported by GPUParticleSystem
  58521. * @param gradient defines the gradient to remove
  58522. * @returns the current particle system
  58523. */
  58524. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58525. /**
  58526. * Instantiates a GPU particle system.
  58527. * 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.
  58528. * @param name The name of the particle system
  58529. * @param options The options used to create the system
  58530. * @param scene The scene the particle system belongs to
  58531. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58532. */
  58533. constructor(name: string, options: Partial<{
  58534. capacity: number;
  58535. randomTextureSize: number;
  58536. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58537. protected _reset(): void;
  58538. private _createUpdateVAO;
  58539. private _createRenderVAO;
  58540. private _initialize;
  58541. /** @hidden */
  58542. _recreateUpdateEffect(): void;
  58543. /** @hidden */
  58544. _recreateRenderEffect(): void;
  58545. /**
  58546. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58547. * @param preWarm defines if we are in the pre-warmimg phase
  58548. */
  58549. animate(preWarm?: boolean): void;
  58550. private _createFactorGradientTexture;
  58551. private _createSizeGradientTexture;
  58552. private _createAngularSpeedGradientTexture;
  58553. private _createVelocityGradientTexture;
  58554. private _createLimitVelocityGradientTexture;
  58555. private _createDragGradientTexture;
  58556. private _createColorGradientTexture;
  58557. /**
  58558. * Renders the particle system in its current state
  58559. * @param preWarm defines if the system should only update the particles but not render them
  58560. * @returns the current number of particles
  58561. */
  58562. render(preWarm?: boolean): number;
  58563. /**
  58564. * Rebuilds the particle system
  58565. */
  58566. rebuild(): void;
  58567. private _releaseBuffers;
  58568. private _releaseVAOs;
  58569. /**
  58570. * Disposes the particle system and free the associated resources
  58571. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58572. */
  58573. dispose(disposeTexture?: boolean): void;
  58574. /**
  58575. * Clones the particle system.
  58576. * @param name The name of the cloned object
  58577. * @param newEmitter The new emitter to use
  58578. * @returns the cloned particle system
  58579. */
  58580. clone(name: string, newEmitter: any): GPUParticleSystem;
  58581. /**
  58582. * Serializes the particle system to a JSON object.
  58583. * @returns the JSON object
  58584. */
  58585. serialize(): any;
  58586. /**
  58587. * Parses a JSON object to create a GPU particle system.
  58588. * @param parsedParticleSystem The JSON object to parse
  58589. * @param scene The scene to create the particle system in
  58590. * @param rootUrl The root url to use to load external dependencies like texture
  58591. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58592. * @returns the parsed GPU particle system
  58593. */
  58594. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58595. }
  58596. }
  58597. declare module "babylonjs/Particles/particleSystemSet" {
  58598. import { Nullable } from "babylonjs/types";
  58599. import { Color3 } from "babylonjs/Maths/math.color";
  58600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58603. import { Scene, IDisposable } from "babylonjs/scene";
  58604. /**
  58605. * Represents a set of particle systems working together to create a specific effect
  58606. */
  58607. export class ParticleSystemSet implements IDisposable {
  58608. private _emitterCreationOptions;
  58609. private _emitterNode;
  58610. /**
  58611. * Gets the particle system list
  58612. */
  58613. systems: IParticleSystem[];
  58614. /**
  58615. * Gets the emitter node used with this set
  58616. */
  58617. readonly emitterNode: Nullable<TransformNode>;
  58618. /**
  58619. * Creates a new emitter mesh as a sphere
  58620. * @param options defines the options used to create the sphere
  58621. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58622. * @param scene defines the hosting scene
  58623. */
  58624. setEmitterAsSphere(options: {
  58625. diameter: number;
  58626. segments: number;
  58627. color: Color3;
  58628. }, renderingGroupId: number, scene: Scene): void;
  58629. /**
  58630. * Starts all particle systems of the set
  58631. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58632. */
  58633. start(emitter?: AbstractMesh): void;
  58634. /**
  58635. * Release all associated resources
  58636. */
  58637. dispose(): void;
  58638. /**
  58639. * Serialize the set into a JSON compatible object
  58640. * @returns a JSON compatible representation of the set
  58641. */
  58642. serialize(): any;
  58643. /**
  58644. * Parse a new ParticleSystemSet from a serialized source
  58645. * @param data defines a JSON compatible representation of the set
  58646. * @param scene defines the hosting scene
  58647. * @param gpu defines if we want GPU particles or CPU particles
  58648. * @returns a new ParticleSystemSet
  58649. */
  58650. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58651. }
  58652. }
  58653. declare module "babylonjs/Particles/particleHelper" {
  58654. import { Nullable } from "babylonjs/types";
  58655. import { Scene } from "babylonjs/scene";
  58656. import { Vector3 } from "babylonjs/Maths/math.vector";
  58657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58658. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58659. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58660. /**
  58661. * This class is made for on one-liner static method to help creating particle system set.
  58662. */
  58663. export class ParticleHelper {
  58664. /**
  58665. * Gets or sets base Assets URL
  58666. */
  58667. static BaseAssetsUrl: string;
  58668. /**
  58669. * Create a default particle system that you can tweak
  58670. * @param emitter defines the emitter to use
  58671. * @param capacity defines the system capacity (default is 500 particles)
  58672. * @param scene defines the hosting scene
  58673. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58674. * @returns the new Particle system
  58675. */
  58676. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58677. /**
  58678. * This is the main static method (one-liner) of this helper to create different particle systems
  58679. * @param type This string represents the type to the particle system to create
  58680. * @param scene The scene where the particle system should live
  58681. * @param gpu If the system will use gpu
  58682. * @returns the ParticleSystemSet created
  58683. */
  58684. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58685. /**
  58686. * Static function used to export a particle system to a ParticleSystemSet variable.
  58687. * Please note that the emitter shape is not exported
  58688. * @param systems defines the particle systems to export
  58689. * @returns the created particle system set
  58690. */
  58691. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58692. }
  58693. }
  58694. declare module "babylonjs/Particles/particleSystemComponent" {
  58695. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58696. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58697. import "babylonjs/Shaders/particles.vertex";
  58698. module "babylonjs/Engines/engine" {
  58699. interface Engine {
  58700. /**
  58701. * Create an effect to use with particle systems.
  58702. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58703. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58704. * @param uniformsNames defines a list of attribute names
  58705. * @param samplers defines an array of string used to represent textures
  58706. * @param defines defines the string containing the defines to use to compile the shaders
  58707. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58708. * @param onCompiled defines a function to call when the effect creation is successful
  58709. * @param onError defines a function to call when the effect creation has failed
  58710. * @returns the new Effect
  58711. */
  58712. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58713. }
  58714. }
  58715. module "babylonjs/Meshes/mesh" {
  58716. interface Mesh {
  58717. /**
  58718. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58719. * @returns an array of IParticleSystem
  58720. */
  58721. getEmittedParticleSystems(): IParticleSystem[];
  58722. /**
  58723. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58724. * @returns an array of IParticleSystem
  58725. */
  58726. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58727. }
  58728. }
  58729. /**
  58730. * @hidden
  58731. */
  58732. export var _IDoNeedToBeInTheBuild: number;
  58733. }
  58734. declare module "babylonjs/Particles/index" {
  58735. export * from "babylonjs/Particles/baseParticleSystem";
  58736. export * from "babylonjs/Particles/EmitterTypes/index";
  58737. export * from "babylonjs/Particles/gpuParticleSystem";
  58738. export * from "babylonjs/Particles/IParticleSystem";
  58739. export * from "babylonjs/Particles/particle";
  58740. export * from "babylonjs/Particles/particleHelper";
  58741. export * from "babylonjs/Particles/particleSystem";
  58742. export * from "babylonjs/Particles/particleSystemComponent";
  58743. export * from "babylonjs/Particles/particleSystemSet";
  58744. export * from "babylonjs/Particles/solidParticle";
  58745. export * from "babylonjs/Particles/solidParticleSystem";
  58746. export * from "babylonjs/Particles/subEmitter";
  58747. }
  58748. declare module "babylonjs/Physics/physicsEngineComponent" {
  58749. import { Nullable } from "babylonjs/types";
  58750. import { Observable, Observer } from "babylonjs/Misc/observable";
  58751. import { Vector3 } from "babylonjs/Maths/math.vector";
  58752. import { Mesh } from "babylonjs/Meshes/mesh";
  58753. import { ISceneComponent } from "babylonjs/sceneComponent";
  58754. import { Scene } from "babylonjs/scene";
  58755. import { Node } from "babylonjs/node";
  58756. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58757. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58758. module "babylonjs/scene" {
  58759. interface Scene {
  58760. /** @hidden (Backing field) */
  58761. _physicsEngine: Nullable<IPhysicsEngine>;
  58762. /**
  58763. * Gets the current physics engine
  58764. * @returns a IPhysicsEngine or null if none attached
  58765. */
  58766. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58767. /**
  58768. * Enables physics to the current scene
  58769. * @param gravity defines the scene's gravity for the physics engine
  58770. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58771. * @return a boolean indicating if the physics engine was initialized
  58772. */
  58773. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58774. /**
  58775. * Disables and disposes the physics engine associated with the scene
  58776. */
  58777. disablePhysicsEngine(): void;
  58778. /**
  58779. * Gets a boolean indicating if there is an active physics engine
  58780. * @returns a boolean indicating if there is an active physics engine
  58781. */
  58782. isPhysicsEnabled(): boolean;
  58783. /**
  58784. * Deletes a physics compound impostor
  58785. * @param compound defines the compound to delete
  58786. */
  58787. deleteCompoundImpostor(compound: any): void;
  58788. /**
  58789. * An event triggered when physic simulation is about to be run
  58790. */
  58791. onBeforePhysicsObservable: Observable<Scene>;
  58792. /**
  58793. * An event triggered when physic simulation has been done
  58794. */
  58795. onAfterPhysicsObservable: Observable<Scene>;
  58796. }
  58797. }
  58798. module "babylonjs/Meshes/abstractMesh" {
  58799. interface AbstractMesh {
  58800. /** @hidden */
  58801. _physicsImpostor: Nullable<PhysicsImpostor>;
  58802. /**
  58803. * Gets or sets impostor used for physic simulation
  58804. * @see http://doc.babylonjs.com/features/physics_engine
  58805. */
  58806. physicsImpostor: Nullable<PhysicsImpostor>;
  58807. /**
  58808. * Gets the current physics impostor
  58809. * @see http://doc.babylonjs.com/features/physics_engine
  58810. * @returns a physics impostor or null
  58811. */
  58812. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58813. /** Apply a physic impulse to the mesh
  58814. * @param force defines the force to apply
  58815. * @param contactPoint defines where to apply the force
  58816. * @returns the current mesh
  58817. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58818. */
  58819. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58820. /**
  58821. * Creates a physic joint between two meshes
  58822. * @param otherMesh defines the other mesh to use
  58823. * @param pivot1 defines the pivot to use on this mesh
  58824. * @param pivot2 defines the pivot to use on the other mesh
  58825. * @param options defines additional options (can be plugin dependent)
  58826. * @returns the current mesh
  58827. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58828. */
  58829. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58830. /** @hidden */
  58831. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58832. }
  58833. }
  58834. /**
  58835. * Defines the physics engine scene component responsible to manage a physics engine
  58836. */
  58837. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58838. /**
  58839. * The component name helpful to identify the component in the list of scene components.
  58840. */
  58841. readonly name: string;
  58842. /**
  58843. * The scene the component belongs to.
  58844. */
  58845. scene: Scene;
  58846. /**
  58847. * Creates a new instance of the component for the given scene
  58848. * @param scene Defines the scene to register the component in
  58849. */
  58850. constructor(scene: Scene);
  58851. /**
  58852. * Registers the component in a given scene
  58853. */
  58854. register(): void;
  58855. /**
  58856. * Rebuilds the elements related to this component in case of
  58857. * context lost for instance.
  58858. */
  58859. rebuild(): void;
  58860. /**
  58861. * Disposes the component and the associated ressources
  58862. */
  58863. dispose(): void;
  58864. }
  58865. }
  58866. declare module "babylonjs/Physics/physicsHelper" {
  58867. import { Nullable } from "babylonjs/types";
  58868. import { Vector3 } from "babylonjs/Maths/math.vector";
  58869. import { Mesh } from "babylonjs/Meshes/mesh";
  58870. import { Scene } from "babylonjs/scene";
  58871. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58872. /**
  58873. * A helper for physics simulations
  58874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58875. */
  58876. export class PhysicsHelper {
  58877. private _scene;
  58878. private _physicsEngine;
  58879. /**
  58880. * Initializes the Physics helper
  58881. * @param scene Babylon.js scene
  58882. */
  58883. constructor(scene: Scene);
  58884. /**
  58885. * Applies a radial explosion impulse
  58886. * @param origin the origin of the explosion
  58887. * @param radiusOrEventOptions the radius or the options of radial explosion
  58888. * @param strength the explosion strength
  58889. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58890. * @returns A physics radial explosion event, or null
  58891. */
  58892. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58893. /**
  58894. * Applies a radial explosion force
  58895. * @param origin the origin of the explosion
  58896. * @param radiusOrEventOptions the radius or the options of radial explosion
  58897. * @param strength the explosion strength
  58898. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58899. * @returns A physics radial explosion event, or null
  58900. */
  58901. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58902. /**
  58903. * Creates a gravitational field
  58904. * @param origin the origin of the explosion
  58905. * @param radiusOrEventOptions the radius or the options of radial explosion
  58906. * @param strength the explosion strength
  58907. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58908. * @returns A physics gravitational field event, or null
  58909. */
  58910. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58911. /**
  58912. * Creates a physics updraft event
  58913. * @param origin the origin of the updraft
  58914. * @param radiusOrEventOptions the radius or the options of the updraft
  58915. * @param strength the strength of the updraft
  58916. * @param height the height of the updraft
  58917. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58918. * @returns A physics updraft event, or null
  58919. */
  58920. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58921. /**
  58922. * Creates a physics vortex event
  58923. * @param origin the of the vortex
  58924. * @param radiusOrEventOptions the radius or the options of the vortex
  58925. * @param strength the strength of the vortex
  58926. * @param height the height of the vortex
  58927. * @returns a Physics vortex event, or null
  58928. * A physics vortex event or null
  58929. */
  58930. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58931. }
  58932. /**
  58933. * Represents a physics radial explosion event
  58934. */
  58935. class PhysicsRadialExplosionEvent {
  58936. private _scene;
  58937. private _options;
  58938. private _sphere;
  58939. private _dataFetched;
  58940. /**
  58941. * Initializes a radial explosioin event
  58942. * @param _scene BabylonJS scene
  58943. * @param _options The options for the vortex event
  58944. */
  58945. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58946. /**
  58947. * Returns the data related to the radial explosion event (sphere).
  58948. * @returns The radial explosion event data
  58949. */
  58950. getData(): PhysicsRadialExplosionEventData;
  58951. /**
  58952. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58953. * @param impostor A physics imposter
  58954. * @param origin the origin of the explosion
  58955. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58956. */
  58957. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58958. /**
  58959. * Triggers affecterd impostors callbacks
  58960. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58961. */
  58962. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58963. /**
  58964. * Disposes the sphere.
  58965. * @param force Specifies if the sphere should be disposed by force
  58966. */
  58967. dispose(force?: boolean): void;
  58968. /*** Helpers ***/
  58969. private _prepareSphere;
  58970. private _intersectsWithSphere;
  58971. }
  58972. /**
  58973. * Represents a gravitational field event
  58974. */
  58975. class PhysicsGravitationalFieldEvent {
  58976. private _physicsHelper;
  58977. private _scene;
  58978. private _origin;
  58979. private _options;
  58980. private _tickCallback;
  58981. private _sphere;
  58982. private _dataFetched;
  58983. /**
  58984. * Initializes the physics gravitational field event
  58985. * @param _physicsHelper A physics helper
  58986. * @param _scene BabylonJS scene
  58987. * @param _origin The origin position of the gravitational field event
  58988. * @param _options The options for the vortex event
  58989. */
  58990. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58991. /**
  58992. * Returns the data related to the gravitational field event (sphere).
  58993. * @returns A gravitational field event
  58994. */
  58995. getData(): PhysicsGravitationalFieldEventData;
  58996. /**
  58997. * Enables the gravitational field.
  58998. */
  58999. enable(): void;
  59000. /**
  59001. * Disables the gravitational field.
  59002. */
  59003. disable(): void;
  59004. /**
  59005. * Disposes the sphere.
  59006. * @param force The force to dispose from the gravitational field event
  59007. */
  59008. dispose(force?: boolean): void;
  59009. private _tick;
  59010. }
  59011. /**
  59012. * Represents a physics updraft event
  59013. */
  59014. class PhysicsUpdraftEvent {
  59015. private _scene;
  59016. private _origin;
  59017. private _options;
  59018. private _physicsEngine;
  59019. private _originTop;
  59020. private _originDirection;
  59021. private _tickCallback;
  59022. private _cylinder;
  59023. private _cylinderPosition;
  59024. private _dataFetched;
  59025. /**
  59026. * Initializes the physics updraft event
  59027. * @param _scene BabylonJS scene
  59028. * @param _origin The origin position of the updraft
  59029. * @param _options The options for the updraft event
  59030. */
  59031. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  59032. /**
  59033. * Returns the data related to the updraft event (cylinder).
  59034. * @returns A physics updraft event
  59035. */
  59036. getData(): PhysicsUpdraftEventData;
  59037. /**
  59038. * Enables the updraft.
  59039. */
  59040. enable(): void;
  59041. /**
  59042. * Disables the updraft.
  59043. */
  59044. disable(): void;
  59045. /**
  59046. * Disposes the cylinder.
  59047. * @param force Specifies if the updraft should be disposed by force
  59048. */
  59049. dispose(force?: boolean): void;
  59050. private getImpostorHitData;
  59051. private _tick;
  59052. /*** Helpers ***/
  59053. private _prepareCylinder;
  59054. private _intersectsWithCylinder;
  59055. }
  59056. /**
  59057. * Represents a physics vortex event
  59058. */
  59059. class PhysicsVortexEvent {
  59060. private _scene;
  59061. private _origin;
  59062. private _options;
  59063. private _physicsEngine;
  59064. private _originTop;
  59065. private _tickCallback;
  59066. private _cylinder;
  59067. private _cylinderPosition;
  59068. private _dataFetched;
  59069. /**
  59070. * Initializes the physics vortex event
  59071. * @param _scene The BabylonJS scene
  59072. * @param _origin The origin position of the vortex
  59073. * @param _options The options for the vortex event
  59074. */
  59075. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  59076. /**
  59077. * Returns the data related to the vortex event (cylinder).
  59078. * @returns The physics vortex event data
  59079. */
  59080. getData(): PhysicsVortexEventData;
  59081. /**
  59082. * Enables the vortex.
  59083. */
  59084. enable(): void;
  59085. /**
  59086. * Disables the cortex.
  59087. */
  59088. disable(): void;
  59089. /**
  59090. * Disposes the sphere.
  59091. * @param force
  59092. */
  59093. dispose(force?: boolean): void;
  59094. private getImpostorHitData;
  59095. private _tick;
  59096. /*** Helpers ***/
  59097. private _prepareCylinder;
  59098. private _intersectsWithCylinder;
  59099. }
  59100. /**
  59101. * Options fot the radial explosion event
  59102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59103. */
  59104. export class PhysicsRadialExplosionEventOptions {
  59105. /**
  59106. * The radius of the sphere for the radial explosion.
  59107. */
  59108. radius: number;
  59109. /**
  59110. * The strenth of the explosion.
  59111. */
  59112. strength: number;
  59113. /**
  59114. * The strenght of the force in correspondence to the distance of the affected object
  59115. */
  59116. falloff: PhysicsRadialImpulseFalloff;
  59117. /**
  59118. * Sphere options for the radial explosion.
  59119. */
  59120. sphere: {
  59121. segments: number;
  59122. diameter: number;
  59123. };
  59124. /**
  59125. * Sphere options for the radial explosion.
  59126. */
  59127. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  59128. }
  59129. /**
  59130. * Options fot the updraft event
  59131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59132. */
  59133. export class PhysicsUpdraftEventOptions {
  59134. /**
  59135. * The radius of the cylinder for the vortex
  59136. */
  59137. radius: number;
  59138. /**
  59139. * The strenth of the updraft.
  59140. */
  59141. strength: number;
  59142. /**
  59143. * The height of the cylinder for the updraft.
  59144. */
  59145. height: number;
  59146. /**
  59147. * The mode for the the updraft.
  59148. */
  59149. updraftMode: PhysicsUpdraftMode;
  59150. }
  59151. /**
  59152. * Options fot the vortex event
  59153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59154. */
  59155. export class PhysicsVortexEventOptions {
  59156. /**
  59157. * The radius of the cylinder for the vortex
  59158. */
  59159. radius: number;
  59160. /**
  59161. * The strenth of the vortex.
  59162. */
  59163. strength: number;
  59164. /**
  59165. * The height of the cylinder for the vortex.
  59166. */
  59167. height: number;
  59168. /**
  59169. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  59170. */
  59171. centripetalForceThreshold: number;
  59172. /**
  59173. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  59174. */
  59175. centripetalForceMultiplier: number;
  59176. /**
  59177. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  59178. */
  59179. centrifugalForceMultiplier: number;
  59180. /**
  59181. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  59182. */
  59183. updraftForceMultiplier: number;
  59184. }
  59185. /**
  59186. * The strenght of the force in correspondence to the distance of the affected object
  59187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59188. */
  59189. export enum PhysicsRadialImpulseFalloff {
  59190. /** Defines that impulse is constant in strength across it's whole radius */
  59191. Constant = 0,
  59192. /** Defines that impulse gets weaker if it's further from the origin */
  59193. Linear = 1
  59194. }
  59195. /**
  59196. * The strength of the force in correspondence to the distance of the affected object
  59197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59198. */
  59199. export enum PhysicsUpdraftMode {
  59200. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  59201. Center = 0,
  59202. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  59203. Perpendicular = 1
  59204. }
  59205. /**
  59206. * Interface for a physics hit data
  59207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59208. */
  59209. export interface PhysicsHitData {
  59210. /**
  59211. * The force applied at the contact point
  59212. */
  59213. force: Vector3;
  59214. /**
  59215. * The contact point
  59216. */
  59217. contactPoint: Vector3;
  59218. /**
  59219. * The distance from the origin to the contact point
  59220. */
  59221. distanceFromOrigin: number;
  59222. }
  59223. /**
  59224. * Interface for radial explosion event data
  59225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59226. */
  59227. export interface PhysicsRadialExplosionEventData {
  59228. /**
  59229. * A sphere used for the radial explosion event
  59230. */
  59231. sphere: Mesh;
  59232. }
  59233. /**
  59234. * Interface for gravitational field event data
  59235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59236. */
  59237. export interface PhysicsGravitationalFieldEventData {
  59238. /**
  59239. * A sphere mesh used for the gravitational field event
  59240. */
  59241. sphere: Mesh;
  59242. }
  59243. /**
  59244. * Interface for updraft event data
  59245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59246. */
  59247. export interface PhysicsUpdraftEventData {
  59248. /**
  59249. * A cylinder used for the updraft event
  59250. */
  59251. cylinder: Mesh;
  59252. }
  59253. /**
  59254. * Interface for vortex event data
  59255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59256. */
  59257. export interface PhysicsVortexEventData {
  59258. /**
  59259. * A cylinder used for the vortex event
  59260. */
  59261. cylinder: Mesh;
  59262. }
  59263. /**
  59264. * Interface for an affected physics impostor
  59265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  59266. */
  59267. export interface PhysicsAffectedImpostorWithData {
  59268. /**
  59269. * The impostor affected by the effect
  59270. */
  59271. impostor: PhysicsImpostor;
  59272. /**
  59273. * The data about the hit/horce from the explosion
  59274. */
  59275. hitData: PhysicsHitData;
  59276. }
  59277. }
  59278. declare module "babylonjs/Physics/Plugins/index" {
  59279. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  59280. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  59281. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  59282. }
  59283. declare module "babylonjs/Physics/index" {
  59284. export * from "babylonjs/Physics/IPhysicsEngine";
  59285. export * from "babylonjs/Physics/physicsEngine";
  59286. export * from "babylonjs/Physics/physicsEngineComponent";
  59287. export * from "babylonjs/Physics/physicsHelper";
  59288. export * from "babylonjs/Physics/physicsImpostor";
  59289. export * from "babylonjs/Physics/physicsJoint";
  59290. export * from "babylonjs/Physics/Plugins/index";
  59291. }
  59292. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59293. /** @hidden */
  59294. export var blackAndWhitePixelShader: {
  59295. name: string;
  59296. shader: string;
  59297. };
  59298. }
  59299. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59301. import { Camera } from "babylonjs/Cameras/camera";
  59302. import { Engine } from "babylonjs/Engines/engine";
  59303. import "babylonjs/Shaders/blackAndWhite.fragment";
  59304. /**
  59305. * Post process used to render in black and white
  59306. */
  59307. export class BlackAndWhitePostProcess extends PostProcess {
  59308. /**
  59309. * Linear about to convert he result to black and white (default: 1)
  59310. */
  59311. degree: number;
  59312. /**
  59313. * Creates a black and white post process
  59314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59315. * @param name The name of the effect.
  59316. * @param options The required width/height ratio to downsize to before computing the render pass.
  59317. * @param camera The camera to apply the render pass to.
  59318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59319. * @param engine The engine which the post process will be applied. (default: current engine)
  59320. * @param reusable If the post process can be reused on the same frame. (default: false)
  59321. */
  59322. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59323. }
  59324. }
  59325. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59326. import { Nullable } from "babylonjs/types";
  59327. import { Camera } from "babylonjs/Cameras/camera";
  59328. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59329. import { Engine } from "babylonjs/Engines/engine";
  59330. /**
  59331. * This represents a set of one or more post processes in Babylon.
  59332. * A post process can be used to apply a shader to a texture after it is rendered.
  59333. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59334. */
  59335. export class PostProcessRenderEffect {
  59336. private _postProcesses;
  59337. private _getPostProcesses;
  59338. private _singleInstance;
  59339. private _cameras;
  59340. private _indicesForCamera;
  59341. /**
  59342. * Name of the effect
  59343. * @hidden
  59344. */
  59345. _name: string;
  59346. /**
  59347. * Instantiates a post process render effect.
  59348. * A post process can be used to apply a shader to a texture after it is rendered.
  59349. * @param engine The engine the effect is tied to
  59350. * @param name The name of the effect
  59351. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59352. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59353. */
  59354. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59355. /**
  59356. * Checks if all the post processes in the effect are supported.
  59357. */
  59358. readonly isSupported: boolean;
  59359. /**
  59360. * Updates the current state of the effect
  59361. * @hidden
  59362. */
  59363. _update(): void;
  59364. /**
  59365. * Attaches the effect on cameras
  59366. * @param cameras The camera to attach to.
  59367. * @hidden
  59368. */
  59369. _attachCameras(cameras: Camera): void;
  59370. /**
  59371. * Attaches the effect on cameras
  59372. * @param cameras The camera to attach to.
  59373. * @hidden
  59374. */
  59375. _attachCameras(cameras: Camera[]): void;
  59376. /**
  59377. * Detaches the effect on cameras
  59378. * @param cameras The camera to detatch from.
  59379. * @hidden
  59380. */
  59381. _detachCameras(cameras: Camera): void;
  59382. /**
  59383. * Detatches the effect on cameras
  59384. * @param cameras The camera to detatch from.
  59385. * @hidden
  59386. */
  59387. _detachCameras(cameras: Camera[]): void;
  59388. /**
  59389. * Enables the effect on given cameras
  59390. * @param cameras The camera to enable.
  59391. * @hidden
  59392. */
  59393. _enable(cameras: Camera): void;
  59394. /**
  59395. * Enables the effect on given cameras
  59396. * @param cameras The camera to enable.
  59397. * @hidden
  59398. */
  59399. _enable(cameras: Nullable<Camera[]>): void;
  59400. /**
  59401. * Disables the effect on the given cameras
  59402. * @param cameras The camera to disable.
  59403. * @hidden
  59404. */
  59405. _disable(cameras: Camera): void;
  59406. /**
  59407. * Disables the effect on the given cameras
  59408. * @param cameras The camera to disable.
  59409. * @hidden
  59410. */
  59411. _disable(cameras: Nullable<Camera[]>): void;
  59412. /**
  59413. * Gets a list of the post processes contained in the effect.
  59414. * @param camera The camera to get the post processes on.
  59415. * @returns The list of the post processes in the effect.
  59416. */
  59417. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59418. }
  59419. }
  59420. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59421. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59422. /** @hidden */
  59423. export var extractHighlightsPixelShader: {
  59424. name: string;
  59425. shader: string;
  59426. };
  59427. }
  59428. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59429. import { Nullable } from "babylonjs/types";
  59430. import { Camera } from "babylonjs/Cameras/camera";
  59431. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59432. import { Engine } from "babylonjs/Engines/engine";
  59433. import "babylonjs/Shaders/extractHighlights.fragment";
  59434. /**
  59435. * 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.
  59436. */
  59437. export class ExtractHighlightsPostProcess extends PostProcess {
  59438. /**
  59439. * The luminance threshold, pixels below this value will be set to black.
  59440. */
  59441. threshold: number;
  59442. /** @hidden */
  59443. _exposure: number;
  59444. /**
  59445. * Post process which has the input texture to be used when performing highlight extraction
  59446. * @hidden
  59447. */
  59448. _inputPostProcess: Nullable<PostProcess>;
  59449. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59450. }
  59451. }
  59452. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59453. /** @hidden */
  59454. export var bloomMergePixelShader: {
  59455. name: string;
  59456. shader: string;
  59457. };
  59458. }
  59459. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59460. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59461. import { Nullable } from "babylonjs/types";
  59462. import { Engine } from "babylonjs/Engines/engine";
  59463. import { Camera } from "babylonjs/Cameras/camera";
  59464. import "babylonjs/Shaders/bloomMerge.fragment";
  59465. /**
  59466. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59467. */
  59468. export class BloomMergePostProcess extends PostProcess {
  59469. /** Weight of the bloom to be added to the original input. */
  59470. weight: number;
  59471. /**
  59472. * Creates a new instance of @see BloomMergePostProcess
  59473. * @param name The name of the effect.
  59474. * @param originalFromInput Post process which's input will be used for the merge.
  59475. * @param blurred Blurred highlights post process which's output will be used.
  59476. * @param weight Weight of the bloom to be added to the original input.
  59477. * @param options The required width/height ratio to downsize to before computing the render pass.
  59478. * @param camera The camera to apply the render pass to.
  59479. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59480. * @param engine The engine which the post process will be applied. (default: current engine)
  59481. * @param reusable If the post process can be reused on the same frame. (default: false)
  59482. * @param textureType Type of textures used when performing the post process. (default: 0)
  59483. * @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)
  59484. */
  59485. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59486. /** Weight of the bloom to be added to the original input. */
  59487. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59488. }
  59489. }
  59490. declare module "babylonjs/PostProcesses/bloomEffect" {
  59491. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59492. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59493. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59494. import { Camera } from "babylonjs/Cameras/camera";
  59495. import { Scene } from "babylonjs/scene";
  59496. /**
  59497. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59498. */
  59499. export class BloomEffect extends PostProcessRenderEffect {
  59500. private bloomScale;
  59501. /**
  59502. * @hidden Internal
  59503. */
  59504. _effects: Array<PostProcess>;
  59505. /**
  59506. * @hidden Internal
  59507. */
  59508. _downscale: ExtractHighlightsPostProcess;
  59509. private _blurX;
  59510. private _blurY;
  59511. private _merge;
  59512. /**
  59513. * The luminance threshold to find bright areas of the image to bloom.
  59514. */
  59515. threshold: number;
  59516. /**
  59517. * The strength of the bloom.
  59518. */
  59519. weight: number;
  59520. /**
  59521. * Specifies the size of the bloom blur kernel, relative to the final output size
  59522. */
  59523. kernel: number;
  59524. /**
  59525. * Creates a new instance of @see BloomEffect
  59526. * @param scene The scene the effect belongs to.
  59527. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59528. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59529. * @param bloomWeight The the strength of bloom.
  59530. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59531. * @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)
  59532. */
  59533. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59534. /**
  59535. * Disposes each of the internal effects for a given camera.
  59536. * @param camera The camera to dispose the effect on.
  59537. */
  59538. disposeEffects(camera: Camera): void;
  59539. /**
  59540. * @hidden Internal
  59541. */
  59542. _updateEffects(): void;
  59543. /**
  59544. * Internal
  59545. * @returns if all the contained post processes are ready.
  59546. * @hidden
  59547. */
  59548. _isReady(): boolean;
  59549. }
  59550. }
  59551. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59552. /** @hidden */
  59553. export var chromaticAberrationPixelShader: {
  59554. name: string;
  59555. shader: string;
  59556. };
  59557. }
  59558. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59559. import { Vector2 } from "babylonjs/Maths/math.vector";
  59560. import { Nullable } from "babylonjs/types";
  59561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59562. import { Camera } from "babylonjs/Cameras/camera";
  59563. import { Engine } from "babylonjs/Engines/engine";
  59564. import "babylonjs/Shaders/chromaticAberration.fragment";
  59565. /**
  59566. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59567. */
  59568. export class ChromaticAberrationPostProcess extends PostProcess {
  59569. /**
  59570. * The amount of seperation of rgb channels (default: 30)
  59571. */
  59572. aberrationAmount: number;
  59573. /**
  59574. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59575. */
  59576. radialIntensity: number;
  59577. /**
  59578. * 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))
  59579. */
  59580. direction: Vector2;
  59581. /**
  59582. * 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))
  59583. */
  59584. centerPosition: Vector2;
  59585. /**
  59586. * Creates a new instance ChromaticAberrationPostProcess
  59587. * @param name The name of the effect.
  59588. * @param screenWidth The width of the screen to apply the effect on.
  59589. * @param screenHeight The height of the screen to apply the effect on.
  59590. * @param options The required width/height ratio to downsize to before computing the render pass.
  59591. * @param camera The camera to apply the render pass to.
  59592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59593. * @param engine The engine which the post process will be applied. (default: current engine)
  59594. * @param reusable If the post process can be reused on the same frame. (default: false)
  59595. * @param textureType Type of textures used when performing the post process. (default: 0)
  59596. * @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)
  59597. */
  59598. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59599. }
  59600. }
  59601. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59602. /** @hidden */
  59603. export var circleOfConfusionPixelShader: {
  59604. name: string;
  59605. shader: string;
  59606. };
  59607. }
  59608. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59609. import { Nullable } from "babylonjs/types";
  59610. import { Engine } from "babylonjs/Engines/engine";
  59611. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59613. import { Camera } from "babylonjs/Cameras/camera";
  59614. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59615. /**
  59616. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59617. */
  59618. export class CircleOfConfusionPostProcess extends PostProcess {
  59619. /**
  59620. * 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.
  59621. */
  59622. lensSize: number;
  59623. /**
  59624. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59625. */
  59626. fStop: number;
  59627. /**
  59628. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59629. */
  59630. focusDistance: number;
  59631. /**
  59632. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59633. */
  59634. focalLength: number;
  59635. private _depthTexture;
  59636. /**
  59637. * Creates a new instance CircleOfConfusionPostProcess
  59638. * @param name The name of the effect.
  59639. * @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.
  59640. * @param options The required width/height ratio to downsize to before computing the render pass.
  59641. * @param camera The camera to apply the render pass to.
  59642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59643. * @param engine The engine which the post process will be applied. (default: current engine)
  59644. * @param reusable If the post process can be reused on the same frame. (default: false)
  59645. * @param textureType Type of textures used when performing the post process. (default: 0)
  59646. * @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)
  59647. */
  59648. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59649. /**
  59650. * 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.
  59651. */
  59652. depthTexture: RenderTargetTexture;
  59653. }
  59654. }
  59655. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59656. /** @hidden */
  59657. export var colorCorrectionPixelShader: {
  59658. name: string;
  59659. shader: string;
  59660. };
  59661. }
  59662. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59664. import { Engine } from "babylonjs/Engines/engine";
  59665. import { Camera } from "babylonjs/Cameras/camera";
  59666. import "babylonjs/Shaders/colorCorrection.fragment";
  59667. /**
  59668. *
  59669. * This post-process allows the modification of rendered colors by using
  59670. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59671. *
  59672. * The object needs to be provided an url to a texture containing the color
  59673. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59674. * Use an image editing software to tweak the LUT to match your needs.
  59675. *
  59676. * For an example of a color LUT, see here:
  59677. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59678. * For explanations on color grading, see here:
  59679. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59680. *
  59681. */
  59682. export class ColorCorrectionPostProcess extends PostProcess {
  59683. private _colorTableTexture;
  59684. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59685. }
  59686. }
  59687. declare module "babylonjs/Shaders/convolution.fragment" {
  59688. /** @hidden */
  59689. export var convolutionPixelShader: {
  59690. name: string;
  59691. shader: string;
  59692. };
  59693. }
  59694. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59696. import { Nullable } from "babylonjs/types";
  59697. import { Camera } from "babylonjs/Cameras/camera";
  59698. import { Engine } from "babylonjs/Engines/engine";
  59699. import "babylonjs/Shaders/convolution.fragment";
  59700. /**
  59701. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59702. * input texture to perform effects such as edge detection or sharpening
  59703. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59704. */
  59705. export class ConvolutionPostProcess extends PostProcess {
  59706. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59707. kernel: number[];
  59708. /**
  59709. * Creates a new instance ConvolutionPostProcess
  59710. * @param name The name of the effect.
  59711. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59712. * @param options The required width/height ratio to downsize to before computing the render pass.
  59713. * @param camera The camera to apply the render pass to.
  59714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59715. * @param engine The engine which the post process will be applied. (default: current engine)
  59716. * @param reusable If the post process can be reused on the same frame. (default: false)
  59717. * @param textureType Type of textures used when performing the post process. (default: 0)
  59718. */
  59719. constructor(name: string,
  59720. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59721. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59722. /**
  59723. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59724. */
  59725. static EdgeDetect0Kernel: number[];
  59726. /**
  59727. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59728. */
  59729. static EdgeDetect1Kernel: number[];
  59730. /**
  59731. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59732. */
  59733. static EdgeDetect2Kernel: number[];
  59734. /**
  59735. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59736. */
  59737. static SharpenKernel: number[];
  59738. /**
  59739. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59740. */
  59741. static EmbossKernel: number[];
  59742. /**
  59743. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59744. */
  59745. static GaussianKernel: number[];
  59746. }
  59747. }
  59748. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59749. import { Nullable } from "babylonjs/types";
  59750. import { Vector2 } from "babylonjs/Maths/math.vector";
  59751. import { Camera } from "babylonjs/Cameras/camera";
  59752. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59753. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59754. import { Engine } from "babylonjs/Engines/engine";
  59755. import { Scene } from "babylonjs/scene";
  59756. /**
  59757. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59758. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59759. * based on samples that have a large difference in distance than the center pixel.
  59760. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59761. */
  59762. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59763. direction: Vector2;
  59764. /**
  59765. * Creates a new instance CircleOfConfusionPostProcess
  59766. * @param name The name of the effect.
  59767. * @param scene The scene the effect belongs to.
  59768. * @param direction The direction the blur should be applied.
  59769. * @param kernel The size of the kernel used to blur.
  59770. * @param options The required width/height ratio to downsize to before computing the render pass.
  59771. * @param camera The camera to apply the render pass to.
  59772. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59773. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59775. * @param engine The engine which the post process will be applied. (default: current engine)
  59776. * @param reusable If the post process can be reused on the same frame. (default: false)
  59777. * @param textureType Type of textures used when performing the post process. (default: 0)
  59778. * @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)
  59779. */
  59780. 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);
  59781. }
  59782. }
  59783. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59784. /** @hidden */
  59785. export var depthOfFieldMergePixelShader: {
  59786. name: string;
  59787. shader: string;
  59788. };
  59789. }
  59790. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59791. import { Nullable } from "babylonjs/types";
  59792. import { Camera } from "babylonjs/Cameras/camera";
  59793. import { Effect } from "babylonjs/Materials/effect";
  59794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59795. import { Engine } from "babylonjs/Engines/engine";
  59796. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59797. /**
  59798. * Options to be set when merging outputs from the default pipeline.
  59799. */
  59800. export class DepthOfFieldMergePostProcessOptions {
  59801. /**
  59802. * The original image to merge on top of
  59803. */
  59804. originalFromInput: PostProcess;
  59805. /**
  59806. * Parameters to perform the merge of the depth of field effect
  59807. */
  59808. depthOfField?: {
  59809. circleOfConfusion: PostProcess;
  59810. blurSteps: Array<PostProcess>;
  59811. };
  59812. /**
  59813. * Parameters to perform the merge of bloom effect
  59814. */
  59815. bloom?: {
  59816. blurred: PostProcess;
  59817. weight: number;
  59818. };
  59819. }
  59820. /**
  59821. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59822. */
  59823. export class DepthOfFieldMergePostProcess extends PostProcess {
  59824. private blurSteps;
  59825. /**
  59826. * Creates a new instance of DepthOfFieldMergePostProcess
  59827. * @param name The name of the effect.
  59828. * @param originalFromInput Post process which's input will be used for the merge.
  59829. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59830. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59831. * @param options The required width/height ratio to downsize to before computing the render pass.
  59832. * @param camera The camera to apply the render pass to.
  59833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59834. * @param engine The engine which the post process will be applied. (default: current engine)
  59835. * @param reusable If the post process can be reused on the same frame. (default: false)
  59836. * @param textureType Type of textures used when performing the post process. (default: 0)
  59837. * @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)
  59838. */
  59839. 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);
  59840. /**
  59841. * Updates the effect with the current post process compile time values and recompiles the shader.
  59842. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59843. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59844. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59845. * @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
  59846. * @param onCompiled Called when the shader has been compiled.
  59847. * @param onError Called if there is an error when compiling a shader.
  59848. */
  59849. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59850. }
  59851. }
  59852. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59853. import { Nullable } from "babylonjs/types";
  59854. import { Camera } from "babylonjs/Cameras/camera";
  59855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59857. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59858. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59859. import { Scene } from "babylonjs/scene";
  59860. /**
  59861. * Specifies the level of max blur that should be applied when using the depth of field effect
  59862. */
  59863. export enum DepthOfFieldEffectBlurLevel {
  59864. /**
  59865. * Subtle blur
  59866. */
  59867. Low = 0,
  59868. /**
  59869. * Medium blur
  59870. */
  59871. Medium = 1,
  59872. /**
  59873. * Large blur
  59874. */
  59875. High = 2
  59876. }
  59877. /**
  59878. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59879. */
  59880. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59881. private _circleOfConfusion;
  59882. /**
  59883. * @hidden Internal, blurs from high to low
  59884. */
  59885. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59886. private _depthOfFieldBlurY;
  59887. private _dofMerge;
  59888. /**
  59889. * @hidden Internal post processes in depth of field effect
  59890. */
  59891. _effects: Array<PostProcess>;
  59892. /**
  59893. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59894. */
  59895. focalLength: number;
  59896. /**
  59897. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59898. */
  59899. fStop: number;
  59900. /**
  59901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59902. */
  59903. focusDistance: number;
  59904. /**
  59905. * 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.
  59906. */
  59907. lensSize: number;
  59908. /**
  59909. * Creates a new instance DepthOfFieldEffect
  59910. * @param scene The scene the effect belongs to.
  59911. * @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.
  59912. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59913. * @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)
  59914. */
  59915. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59916. /**
  59917. * Get the current class name of the current effet
  59918. * @returns "DepthOfFieldEffect"
  59919. */
  59920. getClassName(): string;
  59921. /**
  59922. * 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.
  59923. */
  59924. depthTexture: RenderTargetTexture;
  59925. /**
  59926. * Disposes each of the internal effects for a given camera.
  59927. * @param camera The camera to dispose the effect on.
  59928. */
  59929. disposeEffects(camera: Camera): void;
  59930. /**
  59931. * @hidden Internal
  59932. */
  59933. _updateEffects(): void;
  59934. /**
  59935. * Internal
  59936. * @returns if all the contained post processes are ready.
  59937. * @hidden
  59938. */
  59939. _isReady(): boolean;
  59940. }
  59941. }
  59942. declare module "babylonjs/Shaders/displayPass.fragment" {
  59943. /** @hidden */
  59944. export var displayPassPixelShader: {
  59945. name: string;
  59946. shader: string;
  59947. };
  59948. }
  59949. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59950. import { Nullable } from "babylonjs/types";
  59951. import { Camera } from "babylonjs/Cameras/camera";
  59952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59953. import { Engine } from "babylonjs/Engines/engine";
  59954. import "babylonjs/Shaders/displayPass.fragment";
  59955. /**
  59956. * DisplayPassPostProcess which produces an output the same as it's input
  59957. */
  59958. export class DisplayPassPostProcess extends PostProcess {
  59959. /**
  59960. * Creates the DisplayPassPostProcess
  59961. * @param name The name of the effect.
  59962. * @param options The required width/height ratio to downsize to before computing the render pass.
  59963. * @param camera The camera to apply the render pass to.
  59964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59965. * @param engine The engine which the post process will be applied. (default: current engine)
  59966. * @param reusable If the post process can be reused on the same frame. (default: false)
  59967. */
  59968. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59969. }
  59970. }
  59971. declare module "babylonjs/Shaders/filter.fragment" {
  59972. /** @hidden */
  59973. export var filterPixelShader: {
  59974. name: string;
  59975. shader: string;
  59976. };
  59977. }
  59978. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59979. import { Nullable } from "babylonjs/types";
  59980. import { Matrix } from "babylonjs/Maths/math.vector";
  59981. import { Camera } from "babylonjs/Cameras/camera";
  59982. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59983. import { Engine } from "babylonjs/Engines/engine";
  59984. import "babylonjs/Shaders/filter.fragment";
  59985. /**
  59986. * Applies a kernel filter to the image
  59987. */
  59988. export class FilterPostProcess extends PostProcess {
  59989. /** The matrix to be applied to the image */
  59990. kernelMatrix: Matrix;
  59991. /**
  59992. *
  59993. * @param name The name of the effect.
  59994. * @param kernelMatrix The matrix to be applied to the image
  59995. * @param options The required width/height ratio to downsize to before computing the render pass.
  59996. * @param camera The camera to apply the render pass to.
  59997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59998. * @param engine The engine which the post process will be applied. (default: current engine)
  59999. * @param reusable If the post process can be reused on the same frame. (default: false)
  60000. */
  60001. constructor(name: string,
  60002. /** The matrix to be applied to the image */
  60003. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60004. }
  60005. }
  60006. declare module "babylonjs/Shaders/fxaa.fragment" {
  60007. /** @hidden */
  60008. export var fxaaPixelShader: {
  60009. name: string;
  60010. shader: string;
  60011. };
  60012. }
  60013. declare module "babylonjs/Shaders/fxaa.vertex" {
  60014. /** @hidden */
  60015. export var fxaaVertexShader: {
  60016. name: string;
  60017. shader: string;
  60018. };
  60019. }
  60020. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  60021. import { Nullable } from "babylonjs/types";
  60022. import { Camera } from "babylonjs/Cameras/camera";
  60023. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60024. import { Engine } from "babylonjs/Engines/engine";
  60025. import "babylonjs/Shaders/fxaa.fragment";
  60026. import "babylonjs/Shaders/fxaa.vertex";
  60027. /**
  60028. * Fxaa post process
  60029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  60030. */
  60031. export class FxaaPostProcess extends PostProcess {
  60032. /** @hidden */
  60033. texelWidth: number;
  60034. /** @hidden */
  60035. texelHeight: number;
  60036. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60037. private _getDefines;
  60038. }
  60039. }
  60040. declare module "babylonjs/Shaders/grain.fragment" {
  60041. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60042. /** @hidden */
  60043. export var grainPixelShader: {
  60044. name: string;
  60045. shader: string;
  60046. };
  60047. }
  60048. declare module "babylonjs/PostProcesses/grainPostProcess" {
  60049. import { Nullable } from "babylonjs/types";
  60050. import { Camera } from "babylonjs/Cameras/camera";
  60051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60052. import { Engine } from "babylonjs/Engines/engine";
  60053. import "babylonjs/Shaders/grain.fragment";
  60054. /**
  60055. * The GrainPostProcess adds noise to the image at mid luminance levels
  60056. */
  60057. export class GrainPostProcess extends PostProcess {
  60058. /**
  60059. * The intensity of the grain added (default: 30)
  60060. */
  60061. intensity: number;
  60062. /**
  60063. * If the grain should be randomized on every frame
  60064. */
  60065. animated: boolean;
  60066. /**
  60067. * Creates a new instance of @see GrainPostProcess
  60068. * @param name The name of the effect.
  60069. * @param options The required width/height ratio to downsize to before computing the render pass.
  60070. * @param camera The camera to apply the render pass to.
  60071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60072. * @param engine The engine which the post process will be applied. (default: current engine)
  60073. * @param reusable If the post process can be reused on the same frame. (default: false)
  60074. * @param textureType Type of textures used when performing the post process. (default: 0)
  60075. * @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)
  60076. */
  60077. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60078. }
  60079. }
  60080. declare module "babylonjs/Shaders/highlights.fragment" {
  60081. /** @hidden */
  60082. export var highlightsPixelShader: {
  60083. name: string;
  60084. shader: string;
  60085. };
  60086. }
  60087. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  60088. import { Nullable } from "babylonjs/types";
  60089. import { Camera } from "babylonjs/Cameras/camera";
  60090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60091. import { Engine } from "babylonjs/Engines/engine";
  60092. import "babylonjs/Shaders/highlights.fragment";
  60093. /**
  60094. * Extracts highlights from the image
  60095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60096. */
  60097. export class HighlightsPostProcess extends PostProcess {
  60098. /**
  60099. * Extracts highlights from the image
  60100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  60101. * @param name The name of the effect.
  60102. * @param options The required width/height ratio to downsize to before computing the render pass.
  60103. * @param camera The camera to apply the render pass to.
  60104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60105. * @param engine The engine which the post process will be applied. (default: current engine)
  60106. * @param reusable If the post process can be reused on the same frame. (default: false)
  60107. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  60108. */
  60109. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  60110. }
  60111. }
  60112. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  60113. /** @hidden */
  60114. export var mrtFragmentDeclaration: {
  60115. name: string;
  60116. shader: string;
  60117. };
  60118. }
  60119. declare module "babylonjs/Shaders/geometry.fragment" {
  60120. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  60121. /** @hidden */
  60122. export var geometryPixelShader: {
  60123. name: string;
  60124. shader: string;
  60125. };
  60126. }
  60127. declare module "babylonjs/Shaders/geometry.vertex" {
  60128. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60129. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60130. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60131. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60132. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60133. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60134. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60135. /** @hidden */
  60136. export var geometryVertexShader: {
  60137. name: string;
  60138. shader: string;
  60139. };
  60140. }
  60141. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  60142. import { Matrix } from "babylonjs/Maths/math.vector";
  60143. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60144. import { Mesh } from "babylonjs/Meshes/mesh";
  60145. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  60146. import { Effect } from "babylonjs/Materials/effect";
  60147. import { Scene } from "babylonjs/scene";
  60148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60149. import "babylonjs/Shaders/geometry.fragment";
  60150. import "babylonjs/Shaders/geometry.vertex";
  60151. /** @hidden */
  60152. interface ISavedTransformationMatrix {
  60153. world: Matrix;
  60154. viewProjection: Matrix;
  60155. }
  60156. /**
  60157. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  60158. */
  60159. export class GeometryBufferRenderer {
  60160. /**
  60161. * Constant used to retrieve the position texture index in the G-Buffer textures array
  60162. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  60163. */
  60164. static readonly POSITION_TEXTURE_TYPE: number;
  60165. /**
  60166. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  60167. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  60168. */
  60169. static readonly VELOCITY_TEXTURE_TYPE: number;
  60170. /**
  60171. * Dictionary used to store the previous transformation matrices of each rendered mesh
  60172. * in order to compute objects velocities when enableVelocity is set to "true"
  60173. * @hidden
  60174. */
  60175. _previousTransformationMatrices: {
  60176. [index: number]: ISavedTransformationMatrix;
  60177. };
  60178. /**
  60179. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  60180. * in order to compute objects velocities when enableVelocity is set to "true"
  60181. * @hidden
  60182. */
  60183. _previousBonesTransformationMatrices: {
  60184. [index: number]: Float32Array;
  60185. };
  60186. /**
  60187. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  60188. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  60189. */
  60190. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  60191. private _scene;
  60192. private _multiRenderTarget;
  60193. private _ratio;
  60194. private _enablePosition;
  60195. private _enableVelocity;
  60196. private _positionIndex;
  60197. private _velocityIndex;
  60198. protected _effect: Effect;
  60199. protected _cachedDefines: string;
  60200. /**
  60201. * Set the render list (meshes to be rendered) used in the G buffer.
  60202. */
  60203. renderList: Mesh[];
  60204. /**
  60205. * Gets wether or not G buffer are supported by the running hardware.
  60206. * This requires draw buffer supports
  60207. */
  60208. readonly isSupported: boolean;
  60209. /**
  60210. * Returns the index of the given texture type in the G-Buffer textures array
  60211. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  60212. * @returns the index of the given texture type in the G-Buffer textures array
  60213. */
  60214. getTextureIndex(textureType: number): number;
  60215. /**
  60216. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  60217. */
  60218. /**
  60219. * Sets whether or not objects positions are enabled for the G buffer.
  60220. */
  60221. enablePosition: boolean;
  60222. /**
  60223. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  60224. */
  60225. /**
  60226. * Sets wether or not objects velocities are enabled for the G buffer.
  60227. */
  60228. enableVelocity: boolean;
  60229. /**
  60230. * Gets the scene associated with the buffer.
  60231. */
  60232. readonly scene: Scene;
  60233. /**
  60234. * Gets the ratio used by the buffer during its creation.
  60235. * How big is the buffer related to the main canvas.
  60236. */
  60237. readonly ratio: number;
  60238. /** @hidden */
  60239. static _SceneComponentInitialization: (scene: Scene) => void;
  60240. /**
  60241. * Creates a new G Buffer for the scene
  60242. * @param scene The scene the buffer belongs to
  60243. * @param ratio How big is the buffer related to the main canvas.
  60244. */
  60245. constructor(scene: Scene, ratio?: number);
  60246. /**
  60247. * Checks wether everything is ready to render a submesh to the G buffer.
  60248. * @param subMesh the submesh to check readiness for
  60249. * @param useInstances is the mesh drawn using instance or not
  60250. * @returns true if ready otherwise false
  60251. */
  60252. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60253. /**
  60254. * Gets the current underlying G Buffer.
  60255. * @returns the buffer
  60256. */
  60257. getGBuffer(): MultiRenderTarget;
  60258. /**
  60259. * Gets the number of samples used to render the buffer (anti aliasing).
  60260. */
  60261. /**
  60262. * Sets the number of samples used to render the buffer (anti aliasing).
  60263. */
  60264. samples: number;
  60265. /**
  60266. * Disposes the renderer and frees up associated resources.
  60267. */
  60268. dispose(): void;
  60269. protected _createRenderTargets(): void;
  60270. private _copyBonesTransformationMatrices;
  60271. }
  60272. }
  60273. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  60274. import { Nullable } from "babylonjs/types";
  60275. import { Scene } from "babylonjs/scene";
  60276. import { ISceneComponent } from "babylonjs/sceneComponent";
  60277. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  60278. module "babylonjs/scene" {
  60279. interface Scene {
  60280. /** @hidden (Backing field) */
  60281. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60282. /**
  60283. * Gets or Sets the current geometry buffer associated to the scene.
  60284. */
  60285. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60286. /**
  60287. * Enables a GeometryBufferRender and associates it with the scene
  60288. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60289. * @returns the GeometryBufferRenderer
  60290. */
  60291. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60292. /**
  60293. * Disables the GeometryBufferRender associated with the scene
  60294. */
  60295. disableGeometryBufferRenderer(): void;
  60296. }
  60297. }
  60298. /**
  60299. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60300. * in several rendering techniques.
  60301. */
  60302. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60303. /**
  60304. * The component name helpful to identify the component in the list of scene components.
  60305. */
  60306. readonly name: string;
  60307. /**
  60308. * The scene the component belongs to.
  60309. */
  60310. scene: Scene;
  60311. /**
  60312. * Creates a new instance of the component for the given scene
  60313. * @param scene Defines the scene to register the component in
  60314. */
  60315. constructor(scene: Scene);
  60316. /**
  60317. * Registers the component in a given scene
  60318. */
  60319. register(): void;
  60320. /**
  60321. * Rebuilds the elements related to this component in case of
  60322. * context lost for instance.
  60323. */
  60324. rebuild(): void;
  60325. /**
  60326. * Disposes the component and the associated ressources
  60327. */
  60328. dispose(): void;
  60329. private _gatherRenderTargets;
  60330. }
  60331. }
  60332. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60333. /** @hidden */
  60334. export var motionBlurPixelShader: {
  60335. name: string;
  60336. shader: string;
  60337. };
  60338. }
  60339. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60340. import { Nullable } from "babylonjs/types";
  60341. import { Camera } from "babylonjs/Cameras/camera";
  60342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60343. import { Scene } from "babylonjs/scene";
  60344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60345. import "babylonjs/Animations/animatable";
  60346. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60347. import "babylonjs/Shaders/motionBlur.fragment";
  60348. import { Engine } from "babylonjs/Engines/engine";
  60349. /**
  60350. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60351. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60352. * As an example, all you have to do is to create the post-process:
  60353. * var mb = new BABYLON.MotionBlurPostProcess(
  60354. * 'mb', // The name of the effect.
  60355. * scene, // The scene containing the objects to blur according to their velocity.
  60356. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60357. * camera // The camera to apply the render pass to.
  60358. * );
  60359. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60360. */
  60361. export class MotionBlurPostProcess extends PostProcess {
  60362. /**
  60363. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60364. */
  60365. motionStrength: number;
  60366. /**
  60367. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60368. */
  60369. /**
  60370. * Sets the number of iterations to be used for motion blur quality
  60371. */
  60372. motionBlurSamples: number;
  60373. private _motionBlurSamples;
  60374. private _geometryBufferRenderer;
  60375. /**
  60376. * Creates a new instance MotionBlurPostProcess
  60377. * @param name The name of the effect.
  60378. * @param scene The scene containing the objects to blur according to their velocity.
  60379. * @param options The required width/height ratio to downsize to before computing the render pass.
  60380. * @param camera The camera to apply the render pass to.
  60381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60382. * @param engine The engine which the post process will be applied. (default: current engine)
  60383. * @param reusable If the post process can be reused on the same frame. (default: false)
  60384. * @param textureType Type of textures used when performing the post process. (default: 0)
  60385. * @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)
  60386. */
  60387. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60388. /**
  60389. * Excludes the given skinned mesh from computing bones velocities.
  60390. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  60391. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60392. */
  60393. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60394. /**
  60395. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60396. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60397. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60398. */
  60399. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60400. /**
  60401. * Disposes the post process.
  60402. * @param camera The camera to dispose the post process on.
  60403. */
  60404. dispose(camera?: Camera): void;
  60405. }
  60406. }
  60407. declare module "babylonjs/Shaders/refraction.fragment" {
  60408. /** @hidden */
  60409. export var refractionPixelShader: {
  60410. name: string;
  60411. shader: string;
  60412. };
  60413. }
  60414. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60415. import { Color3 } from "babylonjs/Maths/math.color";
  60416. import { Camera } from "babylonjs/Cameras/camera";
  60417. import { Texture } from "babylonjs/Materials/Textures/texture";
  60418. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60419. import { Engine } from "babylonjs/Engines/engine";
  60420. import "babylonjs/Shaders/refraction.fragment";
  60421. /**
  60422. * Post process which applies a refractin texture
  60423. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60424. */
  60425. export class RefractionPostProcess extends PostProcess {
  60426. /** the base color of the refraction (used to taint the rendering) */
  60427. color: Color3;
  60428. /** simulated refraction depth */
  60429. depth: number;
  60430. /** the coefficient of the base color (0 to remove base color tainting) */
  60431. colorLevel: number;
  60432. private _refTexture;
  60433. private _ownRefractionTexture;
  60434. /**
  60435. * Gets or sets the refraction texture
  60436. * Please note that you are responsible for disposing the texture if you set it manually
  60437. */
  60438. refractionTexture: Texture;
  60439. /**
  60440. * Initializes the RefractionPostProcess
  60441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60442. * @param name The name of the effect.
  60443. * @param refractionTextureUrl Url of the refraction texture to use
  60444. * @param color the base color of the refraction (used to taint the rendering)
  60445. * @param depth simulated refraction depth
  60446. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60447. * @param camera The camera to apply the render pass to.
  60448. * @param options The required width/height ratio to downsize to before computing the render pass.
  60449. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60450. * @param engine The engine which the post process will be applied. (default: current engine)
  60451. * @param reusable If the post process can be reused on the same frame. (default: false)
  60452. */
  60453. constructor(name: string, refractionTextureUrl: string,
  60454. /** the base color of the refraction (used to taint the rendering) */
  60455. color: Color3,
  60456. /** simulated refraction depth */
  60457. depth: number,
  60458. /** the coefficient of the base color (0 to remove base color tainting) */
  60459. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60460. /**
  60461. * Disposes of the post process
  60462. * @param camera Camera to dispose post process on
  60463. */
  60464. dispose(camera: Camera): void;
  60465. }
  60466. }
  60467. declare module "babylonjs/Shaders/sharpen.fragment" {
  60468. /** @hidden */
  60469. export var sharpenPixelShader: {
  60470. name: string;
  60471. shader: string;
  60472. };
  60473. }
  60474. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60475. import { Nullable } from "babylonjs/types";
  60476. import { Camera } from "babylonjs/Cameras/camera";
  60477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60478. import "babylonjs/Shaders/sharpen.fragment";
  60479. import { Engine } from "babylonjs/Engines/engine";
  60480. /**
  60481. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60482. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60483. */
  60484. export class SharpenPostProcess extends PostProcess {
  60485. /**
  60486. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60487. */
  60488. colorAmount: number;
  60489. /**
  60490. * How much sharpness should be applied (default: 0.3)
  60491. */
  60492. edgeAmount: number;
  60493. /**
  60494. * Creates a new instance ConvolutionPostProcess
  60495. * @param name The name of the effect.
  60496. * @param options The required width/height ratio to downsize to before computing the render pass.
  60497. * @param camera The camera to apply the render pass to.
  60498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60499. * @param engine The engine which the post process will be applied. (default: current engine)
  60500. * @param reusable If the post process can be reused on the same frame. (default: false)
  60501. * @param textureType Type of textures used when performing the post process. (default: 0)
  60502. * @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)
  60503. */
  60504. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60505. }
  60506. }
  60507. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60508. import { Nullable } from "babylonjs/types";
  60509. import { Camera } from "babylonjs/Cameras/camera";
  60510. import { Engine } from "babylonjs/Engines/engine";
  60511. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60512. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60513. /**
  60514. * PostProcessRenderPipeline
  60515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60516. */
  60517. export class PostProcessRenderPipeline {
  60518. private engine;
  60519. private _renderEffects;
  60520. private _renderEffectsForIsolatedPass;
  60521. /**
  60522. * List of inspectable custom properties (used by the Inspector)
  60523. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60524. */
  60525. inspectableCustomProperties: IInspectable[];
  60526. /**
  60527. * @hidden
  60528. */
  60529. protected _cameras: Camera[];
  60530. /** @hidden */
  60531. _name: string;
  60532. /**
  60533. * Gets pipeline name
  60534. */
  60535. readonly name: string;
  60536. /**
  60537. * Initializes a PostProcessRenderPipeline
  60538. * @param engine engine to add the pipeline to
  60539. * @param name name of the pipeline
  60540. */
  60541. constructor(engine: Engine, name: string);
  60542. /**
  60543. * Gets the class name
  60544. * @returns "PostProcessRenderPipeline"
  60545. */
  60546. getClassName(): string;
  60547. /**
  60548. * If all the render effects in the pipeline are supported
  60549. */
  60550. readonly isSupported: boolean;
  60551. /**
  60552. * Adds an effect to the pipeline
  60553. * @param renderEffect the effect to add
  60554. */
  60555. addEffect(renderEffect: PostProcessRenderEffect): void;
  60556. /** @hidden */
  60557. _rebuild(): void;
  60558. /** @hidden */
  60559. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60560. /** @hidden */
  60561. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60562. /** @hidden */
  60563. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60564. /** @hidden */
  60565. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60566. /** @hidden */
  60567. _attachCameras(cameras: Camera, unique: boolean): void;
  60568. /** @hidden */
  60569. _attachCameras(cameras: Camera[], unique: boolean): void;
  60570. /** @hidden */
  60571. _detachCameras(cameras: Camera): void;
  60572. /** @hidden */
  60573. _detachCameras(cameras: Nullable<Camera[]>): void;
  60574. /** @hidden */
  60575. _update(): void;
  60576. /** @hidden */
  60577. _reset(): void;
  60578. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60579. /**
  60580. * Disposes of the pipeline
  60581. */
  60582. dispose(): void;
  60583. }
  60584. }
  60585. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60586. import { Camera } from "babylonjs/Cameras/camera";
  60587. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60588. /**
  60589. * PostProcessRenderPipelineManager class
  60590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60591. */
  60592. export class PostProcessRenderPipelineManager {
  60593. private _renderPipelines;
  60594. /**
  60595. * Initializes a PostProcessRenderPipelineManager
  60596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60597. */
  60598. constructor();
  60599. /**
  60600. * Gets the list of supported render pipelines
  60601. */
  60602. readonly supportedPipelines: PostProcessRenderPipeline[];
  60603. /**
  60604. * Adds a pipeline to the manager
  60605. * @param renderPipeline The pipeline to add
  60606. */
  60607. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60608. /**
  60609. * Attaches a camera to the pipeline
  60610. * @param renderPipelineName The name of the pipeline to attach to
  60611. * @param cameras the camera to attach
  60612. * @param unique if the camera can be attached multiple times to the pipeline
  60613. */
  60614. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60615. /**
  60616. * Detaches a camera from the pipeline
  60617. * @param renderPipelineName The name of the pipeline to detach from
  60618. * @param cameras the camera to detach
  60619. */
  60620. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60621. /**
  60622. * Enables an effect by name on a pipeline
  60623. * @param renderPipelineName the name of the pipeline to enable the effect in
  60624. * @param renderEffectName the name of the effect to enable
  60625. * @param cameras the cameras that the effect should be enabled on
  60626. */
  60627. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60628. /**
  60629. * Disables an effect by name on a pipeline
  60630. * @param renderPipelineName the name of the pipeline to disable the effect in
  60631. * @param renderEffectName the name of the effect to disable
  60632. * @param cameras the cameras that the effect should be disabled on
  60633. */
  60634. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60635. /**
  60636. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60637. */
  60638. update(): void;
  60639. /** @hidden */
  60640. _rebuild(): void;
  60641. /**
  60642. * Disposes of the manager and pipelines
  60643. */
  60644. dispose(): void;
  60645. }
  60646. }
  60647. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60648. import { ISceneComponent } from "babylonjs/sceneComponent";
  60649. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60650. import { Scene } from "babylonjs/scene";
  60651. module "babylonjs/scene" {
  60652. interface Scene {
  60653. /** @hidden (Backing field) */
  60654. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60655. /**
  60656. * Gets the postprocess render pipeline manager
  60657. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60658. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60659. */
  60660. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60661. }
  60662. }
  60663. /**
  60664. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60665. */
  60666. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60667. /**
  60668. * The component name helpfull to identify the component in the list of scene components.
  60669. */
  60670. readonly name: string;
  60671. /**
  60672. * The scene the component belongs to.
  60673. */
  60674. scene: Scene;
  60675. /**
  60676. * Creates a new instance of the component for the given scene
  60677. * @param scene Defines the scene to register the component in
  60678. */
  60679. constructor(scene: Scene);
  60680. /**
  60681. * Registers the component in a given scene
  60682. */
  60683. register(): void;
  60684. /**
  60685. * Rebuilds the elements related to this component in case of
  60686. * context lost for instance.
  60687. */
  60688. rebuild(): void;
  60689. /**
  60690. * Disposes the component and the associated ressources
  60691. */
  60692. dispose(): void;
  60693. private _gatherRenderTargets;
  60694. }
  60695. }
  60696. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60697. import { Nullable } from "babylonjs/types";
  60698. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60699. import { Camera } from "babylonjs/Cameras/camera";
  60700. import { IDisposable } from "babylonjs/scene";
  60701. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60702. import { Scene } from "babylonjs/scene";
  60703. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60704. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60705. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60706. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60707. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60708. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60709. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60710. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60711. import { Animation } from "babylonjs/Animations/animation";
  60712. /**
  60713. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60714. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60715. */
  60716. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60717. private _scene;
  60718. private _camerasToBeAttached;
  60719. /**
  60720. * ID of the sharpen post process,
  60721. */
  60722. private readonly SharpenPostProcessId;
  60723. /**
  60724. * @ignore
  60725. * ID of the image processing post process;
  60726. */
  60727. readonly ImageProcessingPostProcessId: string;
  60728. /**
  60729. * @ignore
  60730. * ID of the Fast Approximate Anti-Aliasing post process;
  60731. */
  60732. readonly FxaaPostProcessId: string;
  60733. /**
  60734. * ID of the chromatic aberration post process,
  60735. */
  60736. private readonly ChromaticAberrationPostProcessId;
  60737. /**
  60738. * ID of the grain post process
  60739. */
  60740. private readonly GrainPostProcessId;
  60741. /**
  60742. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60743. */
  60744. sharpen: SharpenPostProcess;
  60745. private _sharpenEffect;
  60746. private bloom;
  60747. /**
  60748. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60749. */
  60750. depthOfField: DepthOfFieldEffect;
  60751. /**
  60752. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60753. */
  60754. fxaa: FxaaPostProcess;
  60755. /**
  60756. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60757. */
  60758. imageProcessing: ImageProcessingPostProcess;
  60759. /**
  60760. * Chromatic aberration post process which will shift rgb colors in the image
  60761. */
  60762. chromaticAberration: ChromaticAberrationPostProcess;
  60763. private _chromaticAberrationEffect;
  60764. /**
  60765. * Grain post process which add noise to the image
  60766. */
  60767. grain: GrainPostProcess;
  60768. private _grainEffect;
  60769. /**
  60770. * Glow post process which adds a glow to emissive areas of the image
  60771. */
  60772. private _glowLayer;
  60773. /**
  60774. * Animations which can be used to tweak settings over a period of time
  60775. */
  60776. animations: Animation[];
  60777. private _imageProcessingConfigurationObserver;
  60778. private _sharpenEnabled;
  60779. private _bloomEnabled;
  60780. private _depthOfFieldEnabled;
  60781. private _depthOfFieldBlurLevel;
  60782. private _fxaaEnabled;
  60783. private _imageProcessingEnabled;
  60784. private _defaultPipelineTextureType;
  60785. private _bloomScale;
  60786. private _chromaticAberrationEnabled;
  60787. private _grainEnabled;
  60788. private _buildAllowed;
  60789. /**
  60790. * Gets active scene
  60791. */
  60792. readonly scene: Scene;
  60793. /**
  60794. * Enable or disable the sharpen process from the pipeline
  60795. */
  60796. sharpenEnabled: boolean;
  60797. private _resizeObserver;
  60798. private _hardwareScaleLevel;
  60799. private _bloomKernel;
  60800. /**
  60801. * Specifies the size of the bloom blur kernel, relative to the final output size
  60802. */
  60803. bloomKernel: number;
  60804. /**
  60805. * Specifies the weight of the bloom in the final rendering
  60806. */
  60807. private _bloomWeight;
  60808. /**
  60809. * Specifies the luma threshold for the area that will be blurred by the bloom
  60810. */
  60811. private _bloomThreshold;
  60812. private _hdr;
  60813. /**
  60814. * The strength of the bloom.
  60815. */
  60816. bloomWeight: number;
  60817. /**
  60818. * The strength of the bloom.
  60819. */
  60820. bloomThreshold: number;
  60821. /**
  60822. * The scale of the bloom, lower value will provide better performance.
  60823. */
  60824. bloomScale: number;
  60825. /**
  60826. * Enable or disable the bloom from the pipeline
  60827. */
  60828. bloomEnabled: boolean;
  60829. private _rebuildBloom;
  60830. /**
  60831. * If the depth of field is enabled.
  60832. */
  60833. depthOfFieldEnabled: boolean;
  60834. /**
  60835. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60836. */
  60837. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60838. /**
  60839. * If the anti aliasing is enabled.
  60840. */
  60841. fxaaEnabled: boolean;
  60842. private _samples;
  60843. /**
  60844. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60845. */
  60846. samples: number;
  60847. /**
  60848. * If image processing is enabled.
  60849. */
  60850. imageProcessingEnabled: boolean;
  60851. /**
  60852. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60853. */
  60854. glowLayerEnabled: boolean;
  60855. /**
  60856. * Gets the glow layer (or null if not defined)
  60857. */
  60858. readonly glowLayer: Nullable<GlowLayer>;
  60859. /**
  60860. * Enable or disable the chromaticAberration process from the pipeline
  60861. */
  60862. chromaticAberrationEnabled: boolean;
  60863. /**
  60864. * Enable or disable the grain process from the pipeline
  60865. */
  60866. grainEnabled: boolean;
  60867. /**
  60868. * @constructor
  60869. * @param name - The rendering pipeline name (default: "")
  60870. * @param hdr - If high dynamic range textures should be used (default: true)
  60871. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60872. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60873. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60874. */
  60875. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60876. /**
  60877. * Get the class name
  60878. * @returns "DefaultRenderingPipeline"
  60879. */
  60880. getClassName(): string;
  60881. /**
  60882. * Force the compilation of the entire pipeline.
  60883. */
  60884. prepare(): void;
  60885. private _hasCleared;
  60886. private _prevPostProcess;
  60887. private _prevPrevPostProcess;
  60888. private _setAutoClearAndTextureSharing;
  60889. private _depthOfFieldSceneObserver;
  60890. private _buildPipeline;
  60891. private _disposePostProcesses;
  60892. /**
  60893. * Adds a camera to the pipeline
  60894. * @param camera the camera to be added
  60895. */
  60896. addCamera(camera: Camera): void;
  60897. /**
  60898. * Removes a camera from the pipeline
  60899. * @param camera the camera to remove
  60900. */
  60901. removeCamera(camera: Camera): void;
  60902. /**
  60903. * Dispose of the pipeline and stop all post processes
  60904. */
  60905. dispose(): void;
  60906. /**
  60907. * Serialize the rendering pipeline (Used when exporting)
  60908. * @returns the serialized object
  60909. */
  60910. serialize(): any;
  60911. /**
  60912. * Parse the serialized pipeline
  60913. * @param source Source pipeline.
  60914. * @param scene The scene to load the pipeline to.
  60915. * @param rootUrl The URL of the serialized pipeline.
  60916. * @returns An instantiated pipeline from the serialized object.
  60917. */
  60918. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60919. }
  60920. }
  60921. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60922. /** @hidden */
  60923. export var lensHighlightsPixelShader: {
  60924. name: string;
  60925. shader: string;
  60926. };
  60927. }
  60928. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60929. /** @hidden */
  60930. export var depthOfFieldPixelShader: {
  60931. name: string;
  60932. shader: string;
  60933. };
  60934. }
  60935. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60936. import { Camera } from "babylonjs/Cameras/camera";
  60937. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60938. import { Scene } from "babylonjs/scene";
  60939. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60940. import "babylonjs/Shaders/chromaticAberration.fragment";
  60941. import "babylonjs/Shaders/lensHighlights.fragment";
  60942. import "babylonjs/Shaders/depthOfField.fragment";
  60943. /**
  60944. * BABYLON.JS Chromatic Aberration GLSL Shader
  60945. * Author: Olivier Guyot
  60946. * Separates very slightly R, G and B colors on the edges of the screen
  60947. * Inspired by Francois Tarlier & Martins Upitis
  60948. */
  60949. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60950. /**
  60951. * @ignore
  60952. * The chromatic aberration PostProcess id in the pipeline
  60953. */
  60954. LensChromaticAberrationEffect: string;
  60955. /**
  60956. * @ignore
  60957. * The highlights enhancing PostProcess id in the pipeline
  60958. */
  60959. HighlightsEnhancingEffect: string;
  60960. /**
  60961. * @ignore
  60962. * The depth-of-field PostProcess id in the pipeline
  60963. */
  60964. LensDepthOfFieldEffect: string;
  60965. private _scene;
  60966. private _depthTexture;
  60967. private _grainTexture;
  60968. private _chromaticAberrationPostProcess;
  60969. private _highlightsPostProcess;
  60970. private _depthOfFieldPostProcess;
  60971. private _edgeBlur;
  60972. private _grainAmount;
  60973. private _chromaticAberration;
  60974. private _distortion;
  60975. private _highlightsGain;
  60976. private _highlightsThreshold;
  60977. private _dofDistance;
  60978. private _dofAperture;
  60979. private _dofDarken;
  60980. private _dofPentagon;
  60981. private _blurNoise;
  60982. /**
  60983. * @constructor
  60984. *
  60985. * Effect parameters are as follow:
  60986. * {
  60987. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60988. * edge_blur: number; // from 0 to x (1 for realism)
  60989. * distortion: number; // from 0 to x (1 for realism)
  60990. * grain_amount: number; // from 0 to 1
  60991. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60992. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60993. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60994. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60995. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60996. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60997. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60998. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60999. * }
  61000. * Note: if an effect parameter is unset, effect is disabled
  61001. *
  61002. * @param name The rendering pipeline name
  61003. * @param parameters - An object containing all parameters (see above)
  61004. * @param scene The scene linked to this pipeline
  61005. * @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)
  61006. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61007. */
  61008. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  61009. /**
  61010. * Get the class name
  61011. * @returns "LensRenderingPipeline"
  61012. */
  61013. getClassName(): string;
  61014. /**
  61015. * Gets associated scene
  61016. */
  61017. readonly scene: Scene;
  61018. /**
  61019. * Gets or sets the edge blur
  61020. */
  61021. edgeBlur: number;
  61022. /**
  61023. * Gets or sets the grain amount
  61024. */
  61025. grainAmount: number;
  61026. /**
  61027. * Gets or sets the chromatic aberration amount
  61028. */
  61029. chromaticAberration: number;
  61030. /**
  61031. * Gets or sets the depth of field aperture
  61032. */
  61033. dofAperture: number;
  61034. /**
  61035. * Gets or sets the edge distortion
  61036. */
  61037. edgeDistortion: number;
  61038. /**
  61039. * Gets or sets the depth of field distortion
  61040. */
  61041. dofDistortion: number;
  61042. /**
  61043. * Gets or sets the darken out of focus amount
  61044. */
  61045. darkenOutOfFocus: number;
  61046. /**
  61047. * Gets or sets a boolean indicating if blur noise is enabled
  61048. */
  61049. blurNoise: boolean;
  61050. /**
  61051. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  61052. */
  61053. pentagonBokeh: boolean;
  61054. /**
  61055. * Gets or sets the highlight grain amount
  61056. */
  61057. highlightsGain: number;
  61058. /**
  61059. * Gets or sets the highlight threshold
  61060. */
  61061. highlightsThreshold: number;
  61062. /**
  61063. * Sets the amount of blur at the edges
  61064. * @param amount blur amount
  61065. */
  61066. setEdgeBlur(amount: number): void;
  61067. /**
  61068. * Sets edge blur to 0
  61069. */
  61070. disableEdgeBlur(): void;
  61071. /**
  61072. * Sets the amout of grain
  61073. * @param amount Amount of grain
  61074. */
  61075. setGrainAmount(amount: number): void;
  61076. /**
  61077. * Set grain amount to 0
  61078. */
  61079. disableGrain(): void;
  61080. /**
  61081. * Sets the chromatic aberration amount
  61082. * @param amount amount of chromatic aberration
  61083. */
  61084. setChromaticAberration(amount: number): void;
  61085. /**
  61086. * Sets chromatic aberration amount to 0
  61087. */
  61088. disableChromaticAberration(): void;
  61089. /**
  61090. * Sets the EdgeDistortion amount
  61091. * @param amount amount of EdgeDistortion
  61092. */
  61093. setEdgeDistortion(amount: number): void;
  61094. /**
  61095. * Sets edge distortion to 0
  61096. */
  61097. disableEdgeDistortion(): void;
  61098. /**
  61099. * Sets the FocusDistance amount
  61100. * @param amount amount of FocusDistance
  61101. */
  61102. setFocusDistance(amount: number): void;
  61103. /**
  61104. * Disables depth of field
  61105. */
  61106. disableDepthOfField(): void;
  61107. /**
  61108. * Sets the Aperture amount
  61109. * @param amount amount of Aperture
  61110. */
  61111. setAperture(amount: number): void;
  61112. /**
  61113. * Sets the DarkenOutOfFocus amount
  61114. * @param amount amount of DarkenOutOfFocus
  61115. */
  61116. setDarkenOutOfFocus(amount: number): void;
  61117. private _pentagonBokehIsEnabled;
  61118. /**
  61119. * Creates a pentagon bokeh effect
  61120. */
  61121. enablePentagonBokeh(): void;
  61122. /**
  61123. * Disables the pentagon bokeh effect
  61124. */
  61125. disablePentagonBokeh(): void;
  61126. /**
  61127. * Enables noise blur
  61128. */
  61129. enableNoiseBlur(): void;
  61130. /**
  61131. * Disables noise blur
  61132. */
  61133. disableNoiseBlur(): void;
  61134. /**
  61135. * Sets the HighlightsGain amount
  61136. * @param amount amount of HighlightsGain
  61137. */
  61138. setHighlightsGain(amount: number): void;
  61139. /**
  61140. * Sets the HighlightsThreshold amount
  61141. * @param amount amount of HighlightsThreshold
  61142. */
  61143. setHighlightsThreshold(amount: number): void;
  61144. /**
  61145. * Disables highlights
  61146. */
  61147. disableHighlights(): void;
  61148. /**
  61149. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  61150. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  61151. */
  61152. dispose(disableDepthRender?: boolean): void;
  61153. private _createChromaticAberrationPostProcess;
  61154. private _createHighlightsPostProcess;
  61155. private _createDepthOfFieldPostProcess;
  61156. private _createGrainTexture;
  61157. }
  61158. }
  61159. declare module "babylonjs/Shaders/ssao2.fragment" {
  61160. /** @hidden */
  61161. export var ssao2PixelShader: {
  61162. name: string;
  61163. shader: string;
  61164. };
  61165. }
  61166. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  61167. /** @hidden */
  61168. export var ssaoCombinePixelShader: {
  61169. name: string;
  61170. shader: string;
  61171. };
  61172. }
  61173. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  61174. import { Camera } from "babylonjs/Cameras/camera";
  61175. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61176. import { Scene } from "babylonjs/scene";
  61177. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61178. import "babylonjs/Shaders/ssao2.fragment";
  61179. import "babylonjs/Shaders/ssaoCombine.fragment";
  61180. /**
  61181. * Render pipeline to produce ssao effect
  61182. */
  61183. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  61184. /**
  61185. * @ignore
  61186. * The PassPostProcess id in the pipeline that contains the original scene color
  61187. */
  61188. SSAOOriginalSceneColorEffect: string;
  61189. /**
  61190. * @ignore
  61191. * The SSAO PostProcess id in the pipeline
  61192. */
  61193. SSAORenderEffect: string;
  61194. /**
  61195. * @ignore
  61196. * The horizontal blur PostProcess id in the pipeline
  61197. */
  61198. SSAOBlurHRenderEffect: string;
  61199. /**
  61200. * @ignore
  61201. * The vertical blur PostProcess id in the pipeline
  61202. */
  61203. SSAOBlurVRenderEffect: string;
  61204. /**
  61205. * @ignore
  61206. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61207. */
  61208. SSAOCombineRenderEffect: string;
  61209. /**
  61210. * The output strength of the SSAO post-process. Default value is 1.0.
  61211. */
  61212. totalStrength: number;
  61213. /**
  61214. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  61215. */
  61216. maxZ: number;
  61217. /**
  61218. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  61219. */
  61220. minZAspect: number;
  61221. private _samples;
  61222. /**
  61223. * Number of samples used for the SSAO calculations. Default value is 8
  61224. */
  61225. samples: number;
  61226. private _textureSamples;
  61227. /**
  61228. * Number of samples to use for antialiasing
  61229. */
  61230. textureSamples: number;
  61231. /**
  61232. * Ratio object used for SSAO ratio and blur ratio
  61233. */
  61234. private _ratio;
  61235. /**
  61236. * Dynamically generated sphere sampler.
  61237. */
  61238. private _sampleSphere;
  61239. /**
  61240. * Blur filter offsets
  61241. */
  61242. private _samplerOffsets;
  61243. private _expensiveBlur;
  61244. /**
  61245. * If bilateral blur should be used
  61246. */
  61247. expensiveBlur: boolean;
  61248. /**
  61249. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  61250. */
  61251. radius: number;
  61252. /**
  61253. * The base color of the SSAO post-process
  61254. * The final result is "base + ssao" between [0, 1]
  61255. */
  61256. base: number;
  61257. /**
  61258. * Support test.
  61259. */
  61260. static readonly IsSupported: boolean;
  61261. private _scene;
  61262. private _depthTexture;
  61263. private _normalTexture;
  61264. private _randomTexture;
  61265. private _originalColorPostProcess;
  61266. private _ssaoPostProcess;
  61267. private _blurHPostProcess;
  61268. private _blurVPostProcess;
  61269. private _ssaoCombinePostProcess;
  61270. private _firstUpdate;
  61271. /**
  61272. * Gets active scene
  61273. */
  61274. readonly scene: Scene;
  61275. /**
  61276. * @constructor
  61277. * @param name The rendering pipeline name
  61278. * @param scene The scene linked to this pipeline
  61279. * @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 }
  61280. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61281. */
  61282. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61283. /**
  61284. * Get the class name
  61285. * @returns "SSAO2RenderingPipeline"
  61286. */
  61287. getClassName(): string;
  61288. /**
  61289. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61290. */
  61291. dispose(disableGeometryBufferRenderer?: boolean): void;
  61292. private _createBlurPostProcess;
  61293. /** @hidden */
  61294. _rebuild(): void;
  61295. private _bits;
  61296. private _radicalInverse_VdC;
  61297. private _hammersley;
  61298. private _hemisphereSample_uniform;
  61299. private _generateHemisphere;
  61300. private _createSSAOPostProcess;
  61301. private _createSSAOCombinePostProcess;
  61302. private _createRandomTexture;
  61303. /**
  61304. * Serialize the rendering pipeline (Used when exporting)
  61305. * @returns the serialized object
  61306. */
  61307. serialize(): any;
  61308. /**
  61309. * Parse the serialized pipeline
  61310. * @param source Source pipeline.
  61311. * @param scene The scene to load the pipeline to.
  61312. * @param rootUrl The URL of the serialized pipeline.
  61313. * @returns An instantiated pipeline from the serialized object.
  61314. */
  61315. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61316. }
  61317. }
  61318. declare module "babylonjs/Shaders/ssao.fragment" {
  61319. /** @hidden */
  61320. export var ssaoPixelShader: {
  61321. name: string;
  61322. shader: string;
  61323. };
  61324. }
  61325. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61326. import { Camera } from "babylonjs/Cameras/camera";
  61327. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61328. import { Scene } from "babylonjs/scene";
  61329. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61330. import "babylonjs/Shaders/ssao.fragment";
  61331. import "babylonjs/Shaders/ssaoCombine.fragment";
  61332. /**
  61333. * Render pipeline to produce ssao effect
  61334. */
  61335. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61336. /**
  61337. * @ignore
  61338. * The PassPostProcess id in the pipeline that contains the original scene color
  61339. */
  61340. SSAOOriginalSceneColorEffect: string;
  61341. /**
  61342. * @ignore
  61343. * The SSAO PostProcess id in the pipeline
  61344. */
  61345. SSAORenderEffect: string;
  61346. /**
  61347. * @ignore
  61348. * The horizontal blur PostProcess id in the pipeline
  61349. */
  61350. SSAOBlurHRenderEffect: string;
  61351. /**
  61352. * @ignore
  61353. * The vertical blur PostProcess id in the pipeline
  61354. */
  61355. SSAOBlurVRenderEffect: string;
  61356. /**
  61357. * @ignore
  61358. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61359. */
  61360. SSAOCombineRenderEffect: string;
  61361. /**
  61362. * The output strength of the SSAO post-process. Default value is 1.0.
  61363. */
  61364. totalStrength: number;
  61365. /**
  61366. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61367. */
  61368. radius: number;
  61369. /**
  61370. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61371. * Must not be equal to fallOff and superior to fallOff.
  61372. * Default value is 0.0075
  61373. */
  61374. area: number;
  61375. /**
  61376. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61377. * Must not be equal to area and inferior to area.
  61378. * Default value is 0.000001
  61379. */
  61380. fallOff: number;
  61381. /**
  61382. * The base color of the SSAO post-process
  61383. * The final result is "base + ssao" between [0, 1]
  61384. */
  61385. base: number;
  61386. private _scene;
  61387. private _depthTexture;
  61388. private _randomTexture;
  61389. private _originalColorPostProcess;
  61390. private _ssaoPostProcess;
  61391. private _blurHPostProcess;
  61392. private _blurVPostProcess;
  61393. private _ssaoCombinePostProcess;
  61394. private _firstUpdate;
  61395. /**
  61396. * Gets active scene
  61397. */
  61398. readonly scene: Scene;
  61399. /**
  61400. * @constructor
  61401. * @param name - The rendering pipeline name
  61402. * @param scene - The scene linked to this pipeline
  61403. * @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 }
  61404. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61405. */
  61406. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61407. /**
  61408. * Get the class name
  61409. * @returns "SSAORenderingPipeline"
  61410. */
  61411. getClassName(): string;
  61412. /**
  61413. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61414. */
  61415. dispose(disableDepthRender?: boolean): void;
  61416. private _createBlurPostProcess;
  61417. /** @hidden */
  61418. _rebuild(): void;
  61419. private _createSSAOPostProcess;
  61420. private _createSSAOCombinePostProcess;
  61421. private _createRandomTexture;
  61422. }
  61423. }
  61424. declare module "babylonjs/Shaders/standard.fragment" {
  61425. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61426. /** @hidden */
  61427. export var standardPixelShader: {
  61428. name: string;
  61429. shader: string;
  61430. };
  61431. }
  61432. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61433. import { Nullable } from "babylonjs/types";
  61434. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61435. import { Camera } from "babylonjs/Cameras/camera";
  61436. import { Texture } from "babylonjs/Materials/Textures/texture";
  61437. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61438. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61439. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61440. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61441. import { IDisposable } from "babylonjs/scene";
  61442. import { SpotLight } from "babylonjs/Lights/spotLight";
  61443. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61444. import { Scene } from "babylonjs/scene";
  61445. import { Animation } from "babylonjs/Animations/animation";
  61446. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61447. import "babylonjs/Shaders/standard.fragment";
  61448. /**
  61449. * Standard rendering pipeline
  61450. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61451. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61452. */
  61453. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61454. /**
  61455. * Public members
  61456. */
  61457. /**
  61458. * Post-process which contains the original scene color before the pipeline applies all the effects
  61459. */
  61460. originalPostProcess: Nullable<PostProcess>;
  61461. /**
  61462. * Post-process used to down scale an image x4
  61463. */
  61464. downSampleX4PostProcess: Nullable<PostProcess>;
  61465. /**
  61466. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61467. */
  61468. brightPassPostProcess: Nullable<PostProcess>;
  61469. /**
  61470. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61471. */
  61472. blurHPostProcesses: PostProcess[];
  61473. /**
  61474. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61475. */
  61476. blurVPostProcesses: PostProcess[];
  61477. /**
  61478. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61479. */
  61480. textureAdderPostProcess: Nullable<PostProcess>;
  61481. /**
  61482. * Post-process used to create volumetric lighting effect
  61483. */
  61484. volumetricLightPostProcess: Nullable<PostProcess>;
  61485. /**
  61486. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61487. */
  61488. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61489. /**
  61490. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61491. */
  61492. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61493. /**
  61494. * Post-process used to merge the volumetric light effect and the real scene color
  61495. */
  61496. volumetricLightMergePostProces: Nullable<PostProcess>;
  61497. /**
  61498. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61499. */
  61500. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61501. /**
  61502. * Base post-process used to calculate the average luminance of the final image for HDR
  61503. */
  61504. luminancePostProcess: Nullable<PostProcess>;
  61505. /**
  61506. * Post-processes used to create down sample post-processes in order to get
  61507. * the average luminance of the final image for HDR
  61508. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61509. */
  61510. luminanceDownSamplePostProcesses: PostProcess[];
  61511. /**
  61512. * Post-process used to create a HDR effect (light adaptation)
  61513. */
  61514. hdrPostProcess: Nullable<PostProcess>;
  61515. /**
  61516. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61517. */
  61518. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61519. /**
  61520. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61521. */
  61522. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61523. /**
  61524. * Post-process used to merge the final HDR post-process and the real scene color
  61525. */
  61526. hdrFinalPostProcess: Nullable<PostProcess>;
  61527. /**
  61528. * Post-process used to create a lens flare effect
  61529. */
  61530. lensFlarePostProcess: Nullable<PostProcess>;
  61531. /**
  61532. * Post-process that merges the result of the lens flare post-process and the real scene color
  61533. */
  61534. lensFlareComposePostProcess: Nullable<PostProcess>;
  61535. /**
  61536. * Post-process used to create a motion blur effect
  61537. */
  61538. motionBlurPostProcess: Nullable<PostProcess>;
  61539. /**
  61540. * Post-process used to create a depth of field effect
  61541. */
  61542. depthOfFieldPostProcess: Nullable<PostProcess>;
  61543. /**
  61544. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61545. */
  61546. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61547. /**
  61548. * Represents the brightness threshold in order to configure the illuminated surfaces
  61549. */
  61550. brightThreshold: number;
  61551. /**
  61552. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61553. */
  61554. blurWidth: number;
  61555. /**
  61556. * Sets if the blur for highlighted surfaces must be only horizontal
  61557. */
  61558. horizontalBlur: boolean;
  61559. /**
  61560. * Gets the overall exposure used by the pipeline
  61561. */
  61562. /**
  61563. * Sets the overall exposure used by the pipeline
  61564. */
  61565. exposure: number;
  61566. /**
  61567. * Texture used typically to simulate "dirty" on camera lens
  61568. */
  61569. lensTexture: Nullable<Texture>;
  61570. /**
  61571. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61572. */
  61573. volumetricLightCoefficient: number;
  61574. /**
  61575. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61576. */
  61577. volumetricLightPower: number;
  61578. /**
  61579. * Used the set the blur intensity to smooth the volumetric lights
  61580. */
  61581. volumetricLightBlurScale: number;
  61582. /**
  61583. * Light (spot or directional) used to generate the volumetric lights rays
  61584. * The source light must have a shadow generate so the pipeline can get its
  61585. * depth map
  61586. */
  61587. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61588. /**
  61589. * For eye adaptation, represents the minimum luminance the eye can see
  61590. */
  61591. hdrMinimumLuminance: number;
  61592. /**
  61593. * For eye adaptation, represents the decrease luminance speed
  61594. */
  61595. hdrDecreaseRate: number;
  61596. /**
  61597. * For eye adaptation, represents the increase luminance speed
  61598. */
  61599. hdrIncreaseRate: number;
  61600. /**
  61601. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61602. */
  61603. /**
  61604. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61605. */
  61606. hdrAutoExposure: boolean;
  61607. /**
  61608. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61609. */
  61610. lensColorTexture: Nullable<Texture>;
  61611. /**
  61612. * The overall strengh for the lens flare effect
  61613. */
  61614. lensFlareStrength: number;
  61615. /**
  61616. * Dispersion coefficient for lens flare ghosts
  61617. */
  61618. lensFlareGhostDispersal: number;
  61619. /**
  61620. * Main lens flare halo width
  61621. */
  61622. lensFlareHaloWidth: number;
  61623. /**
  61624. * Based on the lens distortion effect, defines how much the lens flare result
  61625. * is distorted
  61626. */
  61627. lensFlareDistortionStrength: number;
  61628. /**
  61629. * Lens star texture must be used to simulate rays on the flares and is available
  61630. * in the documentation
  61631. */
  61632. lensStarTexture: Nullable<Texture>;
  61633. /**
  61634. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61635. * flare effect by taking account of the dirt texture
  61636. */
  61637. lensFlareDirtTexture: Nullable<Texture>;
  61638. /**
  61639. * Represents the focal length for the depth of field effect
  61640. */
  61641. depthOfFieldDistance: number;
  61642. /**
  61643. * Represents the blur intensity for the blurred part of the depth of field effect
  61644. */
  61645. depthOfFieldBlurWidth: number;
  61646. /**
  61647. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61648. */
  61649. /**
  61650. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61651. */
  61652. motionStrength: number;
  61653. /**
  61654. * Gets wether or not the motion blur post-process is object based or screen based.
  61655. */
  61656. /**
  61657. * Sets wether or not the motion blur post-process should be object based or screen based
  61658. */
  61659. objectBasedMotionBlur: boolean;
  61660. /**
  61661. * List of animations for the pipeline (IAnimatable implementation)
  61662. */
  61663. animations: Animation[];
  61664. /**
  61665. * Private members
  61666. */
  61667. private _scene;
  61668. private _currentDepthOfFieldSource;
  61669. private _basePostProcess;
  61670. private _fixedExposure;
  61671. private _currentExposure;
  61672. private _hdrAutoExposure;
  61673. private _hdrCurrentLuminance;
  61674. private _motionStrength;
  61675. private _isObjectBasedMotionBlur;
  61676. private _floatTextureType;
  61677. private _ratio;
  61678. private _bloomEnabled;
  61679. private _depthOfFieldEnabled;
  61680. private _vlsEnabled;
  61681. private _lensFlareEnabled;
  61682. private _hdrEnabled;
  61683. private _motionBlurEnabled;
  61684. private _fxaaEnabled;
  61685. private _motionBlurSamples;
  61686. private _volumetricLightStepsCount;
  61687. private _samples;
  61688. /**
  61689. * @ignore
  61690. * Specifies if the bloom pipeline is enabled
  61691. */
  61692. BloomEnabled: boolean;
  61693. /**
  61694. * @ignore
  61695. * Specifies if the depth of field pipeline is enabed
  61696. */
  61697. DepthOfFieldEnabled: boolean;
  61698. /**
  61699. * @ignore
  61700. * Specifies if the lens flare pipeline is enabed
  61701. */
  61702. LensFlareEnabled: boolean;
  61703. /**
  61704. * @ignore
  61705. * Specifies if the HDR pipeline is enabled
  61706. */
  61707. HDREnabled: boolean;
  61708. /**
  61709. * @ignore
  61710. * Specifies if the volumetric lights scattering effect is enabled
  61711. */
  61712. VLSEnabled: boolean;
  61713. /**
  61714. * @ignore
  61715. * Specifies if the motion blur effect is enabled
  61716. */
  61717. MotionBlurEnabled: boolean;
  61718. /**
  61719. * Specifies if anti-aliasing is enabled
  61720. */
  61721. fxaaEnabled: boolean;
  61722. /**
  61723. * Specifies the number of steps used to calculate the volumetric lights
  61724. * Typically in interval [50, 200]
  61725. */
  61726. volumetricLightStepsCount: number;
  61727. /**
  61728. * Specifies the number of samples used for the motion blur effect
  61729. * Typically in interval [16, 64]
  61730. */
  61731. motionBlurSamples: number;
  61732. /**
  61733. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61734. */
  61735. samples: number;
  61736. /**
  61737. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61738. * @constructor
  61739. * @param name The rendering pipeline name
  61740. * @param scene The scene linked to this pipeline
  61741. * @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)
  61742. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61743. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61744. */
  61745. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61746. private _buildPipeline;
  61747. private _createDownSampleX4PostProcess;
  61748. private _createBrightPassPostProcess;
  61749. private _createBlurPostProcesses;
  61750. private _createTextureAdderPostProcess;
  61751. private _createVolumetricLightPostProcess;
  61752. private _createLuminancePostProcesses;
  61753. private _createHdrPostProcess;
  61754. private _createLensFlarePostProcess;
  61755. private _createDepthOfFieldPostProcess;
  61756. private _createMotionBlurPostProcess;
  61757. private _getDepthTexture;
  61758. private _disposePostProcesses;
  61759. /**
  61760. * Dispose of the pipeline and stop all post processes
  61761. */
  61762. dispose(): void;
  61763. /**
  61764. * Serialize the rendering pipeline (Used when exporting)
  61765. * @returns the serialized object
  61766. */
  61767. serialize(): any;
  61768. /**
  61769. * Parse the serialized pipeline
  61770. * @param source Source pipeline.
  61771. * @param scene The scene to load the pipeline to.
  61772. * @param rootUrl The URL of the serialized pipeline.
  61773. * @returns An instantiated pipeline from the serialized object.
  61774. */
  61775. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61776. /**
  61777. * Luminance steps
  61778. */
  61779. static LuminanceSteps: number;
  61780. }
  61781. }
  61782. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61783. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61784. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61785. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61786. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61787. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61788. }
  61789. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61790. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61791. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61792. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61793. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61794. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61795. }
  61796. declare module "babylonjs/Shaders/tonemap.fragment" {
  61797. /** @hidden */
  61798. export var tonemapPixelShader: {
  61799. name: string;
  61800. shader: string;
  61801. };
  61802. }
  61803. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61804. import { Camera } from "babylonjs/Cameras/camera";
  61805. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61806. import "babylonjs/Shaders/tonemap.fragment";
  61807. import { Engine } from "babylonjs/Engines/engine";
  61808. /** Defines operator used for tonemapping */
  61809. export enum TonemappingOperator {
  61810. /** Hable */
  61811. Hable = 0,
  61812. /** Reinhard */
  61813. Reinhard = 1,
  61814. /** HejiDawson */
  61815. HejiDawson = 2,
  61816. /** Photographic */
  61817. Photographic = 3
  61818. }
  61819. /**
  61820. * Defines a post process to apply tone mapping
  61821. */
  61822. export class TonemapPostProcess extends PostProcess {
  61823. private _operator;
  61824. /** Defines the required exposure adjustement */
  61825. exposureAdjustment: number;
  61826. /**
  61827. * Creates a new TonemapPostProcess
  61828. * @param name defines the name of the postprocess
  61829. * @param _operator defines the operator to use
  61830. * @param exposureAdjustment defines the required exposure adjustement
  61831. * @param camera defines the camera to use (can be null)
  61832. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61833. * @param engine defines the hosting engine (can be ignore if camera is set)
  61834. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61835. */
  61836. constructor(name: string, _operator: TonemappingOperator,
  61837. /** Defines the required exposure adjustement */
  61838. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61839. }
  61840. }
  61841. declare module "babylonjs/Shaders/depth.vertex" {
  61842. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61844. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61845. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61847. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61848. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61849. /** @hidden */
  61850. export var depthVertexShader: {
  61851. name: string;
  61852. shader: string;
  61853. };
  61854. }
  61855. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61856. /** @hidden */
  61857. export var volumetricLightScatteringPixelShader: {
  61858. name: string;
  61859. shader: string;
  61860. };
  61861. }
  61862. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  61863. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61866. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61868. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61870. /** @hidden */
  61871. export var volumetricLightScatteringPassVertexShader: {
  61872. name: string;
  61873. shader: string;
  61874. };
  61875. }
  61876. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61877. /** @hidden */
  61878. export var volumetricLightScatteringPassPixelShader: {
  61879. name: string;
  61880. shader: string;
  61881. };
  61882. }
  61883. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61884. import { Vector3 } from "babylonjs/Maths/math.vector";
  61885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61886. import { Mesh } from "babylonjs/Meshes/mesh";
  61887. import { Camera } from "babylonjs/Cameras/camera";
  61888. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61889. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61890. import { Scene } from "babylonjs/scene";
  61891. import "babylonjs/Meshes/Builders/planeBuilder";
  61892. import "babylonjs/Shaders/depth.vertex";
  61893. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61894. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  61895. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61896. import { Engine } from "babylonjs/Engines/engine";
  61897. /**
  61898. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61899. */
  61900. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61901. private _volumetricLightScatteringPass;
  61902. private _volumetricLightScatteringRTT;
  61903. private _viewPort;
  61904. private _screenCoordinates;
  61905. private _cachedDefines;
  61906. /**
  61907. * If not undefined, the mesh position is computed from the attached node position
  61908. */
  61909. attachedNode: {
  61910. position: Vector3;
  61911. };
  61912. /**
  61913. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61914. */
  61915. customMeshPosition: Vector3;
  61916. /**
  61917. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61918. */
  61919. useCustomMeshPosition: boolean;
  61920. /**
  61921. * If the post-process should inverse the light scattering direction
  61922. */
  61923. invert: boolean;
  61924. /**
  61925. * The internal mesh used by the post-process
  61926. */
  61927. mesh: Mesh;
  61928. /**
  61929. * @hidden
  61930. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61931. */
  61932. useDiffuseColor: boolean;
  61933. /**
  61934. * Array containing the excluded meshes not rendered in the internal pass
  61935. */
  61936. excludedMeshes: AbstractMesh[];
  61937. /**
  61938. * Controls the overall intensity of the post-process
  61939. */
  61940. exposure: number;
  61941. /**
  61942. * Dissipates each sample's contribution in range [0, 1]
  61943. */
  61944. decay: number;
  61945. /**
  61946. * Controls the overall intensity of each sample
  61947. */
  61948. weight: number;
  61949. /**
  61950. * Controls the density of each sample
  61951. */
  61952. density: number;
  61953. /**
  61954. * @constructor
  61955. * @param name The post-process name
  61956. * @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)
  61957. * @param camera The camera that the post-process will be attached to
  61958. * @param mesh The mesh used to create the light scattering
  61959. * @param samples The post-process quality, default 100
  61960. * @param samplingModeThe post-process filtering mode
  61961. * @param engine The babylon engine
  61962. * @param reusable If the post-process is reusable
  61963. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61964. */
  61965. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61966. /**
  61967. * Returns the string "VolumetricLightScatteringPostProcess"
  61968. * @returns "VolumetricLightScatteringPostProcess"
  61969. */
  61970. getClassName(): string;
  61971. private _isReady;
  61972. /**
  61973. * Sets the new light position for light scattering effect
  61974. * @param position The new custom light position
  61975. */
  61976. setCustomMeshPosition(position: Vector3): void;
  61977. /**
  61978. * Returns the light position for light scattering effect
  61979. * @return Vector3 The custom light position
  61980. */
  61981. getCustomMeshPosition(): Vector3;
  61982. /**
  61983. * Disposes the internal assets and detaches the post-process from the camera
  61984. */
  61985. dispose(camera: Camera): void;
  61986. /**
  61987. * Returns the render target texture used by the post-process
  61988. * @return the render target texture used by the post-process
  61989. */
  61990. getPass(): RenderTargetTexture;
  61991. private _meshExcluded;
  61992. private _createPass;
  61993. private _updateMeshScreenCoordinates;
  61994. /**
  61995. * Creates a default mesh for the Volumeric Light Scattering post-process
  61996. * @param name The mesh name
  61997. * @param scene The scene where to create the mesh
  61998. * @return the default mesh
  61999. */
  62000. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  62001. }
  62002. }
  62003. declare module "babylonjs/PostProcesses/index" {
  62004. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  62005. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  62006. export * from "babylonjs/PostProcesses/bloomEffect";
  62007. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  62008. export * from "babylonjs/PostProcesses/blurPostProcess";
  62009. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62010. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  62011. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  62012. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  62013. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62014. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  62015. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  62016. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  62017. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62018. export * from "babylonjs/PostProcesses/filterPostProcess";
  62019. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  62020. export * from "babylonjs/PostProcesses/grainPostProcess";
  62021. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  62022. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62023. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  62024. export * from "babylonjs/PostProcesses/passPostProcess";
  62025. export * from "babylonjs/PostProcesses/postProcess";
  62026. export * from "babylonjs/PostProcesses/postProcessManager";
  62027. export * from "babylonjs/PostProcesses/refractionPostProcess";
  62028. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  62029. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  62030. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  62031. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  62032. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  62033. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  62034. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  62035. }
  62036. declare module "babylonjs/Probes/index" {
  62037. export * from "babylonjs/Probes/reflectionProbe";
  62038. }
  62039. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  62040. import { Scene } from "babylonjs/scene";
  62041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62042. import { SmartArray } from "babylonjs/Misc/smartArray";
  62043. import { ISceneComponent } from "babylonjs/sceneComponent";
  62044. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  62045. import "babylonjs/Meshes/Builders/boxBuilder";
  62046. import "babylonjs/Shaders/color.fragment";
  62047. import "babylonjs/Shaders/color.vertex";
  62048. import { Color3 } from "babylonjs/Maths/math.color";
  62049. module "babylonjs/scene" {
  62050. interface Scene {
  62051. /** @hidden (Backing field) */
  62052. _boundingBoxRenderer: BoundingBoxRenderer;
  62053. /** @hidden (Backing field) */
  62054. _forceShowBoundingBoxes: boolean;
  62055. /**
  62056. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  62057. */
  62058. forceShowBoundingBoxes: boolean;
  62059. /**
  62060. * Gets the bounding box renderer associated with the scene
  62061. * @returns a BoundingBoxRenderer
  62062. */
  62063. getBoundingBoxRenderer(): BoundingBoxRenderer;
  62064. }
  62065. }
  62066. module "babylonjs/Meshes/abstractMesh" {
  62067. interface AbstractMesh {
  62068. /** @hidden (Backing field) */
  62069. _showBoundingBox: boolean;
  62070. /**
  62071. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  62072. */
  62073. showBoundingBox: boolean;
  62074. }
  62075. }
  62076. /**
  62077. * Component responsible of rendering the bounding box of the meshes in a scene.
  62078. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  62079. */
  62080. export class BoundingBoxRenderer implements ISceneComponent {
  62081. /**
  62082. * The component name helpfull to identify the component in the list of scene components.
  62083. */
  62084. readonly name: string;
  62085. /**
  62086. * The scene the component belongs to.
  62087. */
  62088. scene: Scene;
  62089. /**
  62090. * Color of the bounding box lines placed in front of an object
  62091. */
  62092. frontColor: Color3;
  62093. /**
  62094. * Color of the bounding box lines placed behind an object
  62095. */
  62096. backColor: Color3;
  62097. /**
  62098. * Defines if the renderer should show the back lines or not
  62099. */
  62100. showBackLines: boolean;
  62101. /**
  62102. * @hidden
  62103. */
  62104. renderList: SmartArray<BoundingBox>;
  62105. private _colorShader;
  62106. private _vertexBuffers;
  62107. private _indexBuffer;
  62108. private _fillIndexBuffer;
  62109. private _fillIndexData;
  62110. /**
  62111. * Instantiates a new bounding box renderer in a scene.
  62112. * @param scene the scene the renderer renders in
  62113. */
  62114. constructor(scene: Scene);
  62115. /**
  62116. * Registers the component in a given scene
  62117. */
  62118. register(): void;
  62119. private _evaluateSubMesh;
  62120. private _activeMesh;
  62121. private _prepareRessources;
  62122. private _createIndexBuffer;
  62123. /**
  62124. * Rebuilds the elements related to this component in case of
  62125. * context lost for instance.
  62126. */
  62127. rebuild(): void;
  62128. /**
  62129. * @hidden
  62130. */
  62131. reset(): void;
  62132. /**
  62133. * Render the bounding boxes of a specific rendering group
  62134. * @param renderingGroupId defines the rendering group to render
  62135. */
  62136. render(renderingGroupId: number): void;
  62137. /**
  62138. * In case of occlusion queries, we can render the occlusion bounding box through this method
  62139. * @param mesh Define the mesh to render the occlusion bounding box for
  62140. */
  62141. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  62142. /**
  62143. * Dispose and release the resources attached to this renderer.
  62144. */
  62145. dispose(): void;
  62146. }
  62147. }
  62148. declare module "babylonjs/Shaders/depth.fragment" {
  62149. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62150. /** @hidden */
  62151. export var depthPixelShader: {
  62152. name: string;
  62153. shader: string;
  62154. };
  62155. }
  62156. declare module "babylonjs/Rendering/depthRenderer" {
  62157. import { Nullable } from "babylonjs/types";
  62158. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62159. import { Scene } from "babylonjs/scene";
  62160. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62161. import { Camera } from "babylonjs/Cameras/camera";
  62162. import "babylonjs/Shaders/depth.fragment";
  62163. import "babylonjs/Shaders/depth.vertex";
  62164. /**
  62165. * This represents a depth renderer in Babylon.
  62166. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62167. */
  62168. export class DepthRenderer {
  62169. private _scene;
  62170. private _depthMap;
  62171. private _effect;
  62172. private readonly _storeNonLinearDepth;
  62173. private readonly _clearColor;
  62174. /** Get if the depth renderer is using packed depth or not */
  62175. readonly isPacked: boolean;
  62176. private _cachedDefines;
  62177. private _camera;
  62178. /**
  62179. * Specifiess that the depth renderer will only be used within
  62180. * the camera it is created for.
  62181. * This can help forcing its rendering during the camera processing.
  62182. */
  62183. useOnlyInActiveCamera: boolean;
  62184. /** @hidden */
  62185. static _SceneComponentInitialization: (scene: Scene) => void;
  62186. /**
  62187. * Instantiates a depth renderer
  62188. * @param scene The scene the renderer belongs to
  62189. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62190. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62191. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62192. */
  62193. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62194. /**
  62195. * Creates the depth rendering effect and checks if the effect is ready.
  62196. * @param subMesh The submesh to be used to render the depth map of
  62197. * @param useInstances If multiple world instances should be used
  62198. * @returns if the depth renderer is ready to render the depth map
  62199. */
  62200. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62201. /**
  62202. * Gets the texture which the depth map will be written to.
  62203. * @returns The depth map texture
  62204. */
  62205. getDepthMap(): RenderTargetTexture;
  62206. /**
  62207. * Disposes of the depth renderer.
  62208. */
  62209. dispose(): void;
  62210. }
  62211. }
  62212. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  62213. import { Nullable } from "babylonjs/types";
  62214. import { Scene } from "babylonjs/scene";
  62215. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62216. import { Camera } from "babylonjs/Cameras/camera";
  62217. import { ISceneComponent } from "babylonjs/sceneComponent";
  62218. module "babylonjs/scene" {
  62219. interface Scene {
  62220. /** @hidden (Backing field) */
  62221. _depthRenderer: {
  62222. [id: string]: DepthRenderer;
  62223. };
  62224. /**
  62225. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  62226. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  62227. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62228. * @returns the created depth renderer
  62229. */
  62230. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  62231. /**
  62232. * Disables a depth renderer for a given camera
  62233. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  62234. */
  62235. disableDepthRenderer(camera?: Nullable<Camera>): void;
  62236. }
  62237. }
  62238. /**
  62239. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  62240. * in several rendering techniques.
  62241. */
  62242. export class DepthRendererSceneComponent implements ISceneComponent {
  62243. /**
  62244. * The component name helpfull to identify the component in the list of scene components.
  62245. */
  62246. readonly name: string;
  62247. /**
  62248. * The scene the component belongs to.
  62249. */
  62250. scene: Scene;
  62251. /**
  62252. * Creates a new instance of the component for the given scene
  62253. * @param scene Defines the scene to register the component in
  62254. */
  62255. constructor(scene: Scene);
  62256. /**
  62257. * Registers the component in a given scene
  62258. */
  62259. register(): void;
  62260. /**
  62261. * Rebuilds the elements related to this component in case of
  62262. * context lost for instance.
  62263. */
  62264. rebuild(): void;
  62265. /**
  62266. * Disposes the component and the associated ressources
  62267. */
  62268. dispose(): void;
  62269. private _gatherRenderTargets;
  62270. private _gatherActiveCameraRenderTargets;
  62271. }
  62272. }
  62273. declare module "babylonjs/Shaders/outline.fragment" {
  62274. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62275. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  62276. /** @hidden */
  62277. export var outlinePixelShader: {
  62278. name: string;
  62279. shader: string;
  62280. };
  62281. }
  62282. declare module "babylonjs/Shaders/outline.vertex" {
  62283. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62284. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62286. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62287. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  62288. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62289. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62290. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62291. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  62292. /** @hidden */
  62293. export var outlineVertexShader: {
  62294. name: string;
  62295. shader: string;
  62296. };
  62297. }
  62298. declare module "babylonjs/Rendering/outlineRenderer" {
  62299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62300. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  62301. import { Scene } from "babylonjs/scene";
  62302. import { ISceneComponent } from "babylonjs/sceneComponent";
  62303. import "babylonjs/Shaders/outline.fragment";
  62304. import "babylonjs/Shaders/outline.vertex";
  62305. module "babylonjs/scene" {
  62306. interface Scene {
  62307. /** @hidden */
  62308. _outlineRenderer: OutlineRenderer;
  62309. /**
  62310. * Gets the outline renderer associated with the scene
  62311. * @returns a OutlineRenderer
  62312. */
  62313. getOutlineRenderer(): OutlineRenderer;
  62314. }
  62315. }
  62316. module "babylonjs/Meshes/abstractMesh" {
  62317. interface AbstractMesh {
  62318. /** @hidden (Backing field) */
  62319. _renderOutline: boolean;
  62320. /**
  62321. * Gets or sets a boolean indicating if the outline must be rendered as well
  62322. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62323. */
  62324. renderOutline: boolean;
  62325. /** @hidden (Backing field) */
  62326. _renderOverlay: boolean;
  62327. /**
  62328. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62329. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62330. */
  62331. renderOverlay: boolean;
  62332. }
  62333. }
  62334. /**
  62335. * This class is responsible to draw bothe outline/overlay of meshes.
  62336. * It should not be used directly but through the available method on mesh.
  62337. */
  62338. export class OutlineRenderer implements ISceneComponent {
  62339. /**
  62340. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62341. */
  62342. private static _StencilReference;
  62343. /**
  62344. * The name of the component. Each component must have a unique name.
  62345. */
  62346. name: string;
  62347. /**
  62348. * The scene the component belongs to.
  62349. */
  62350. scene: Scene;
  62351. /**
  62352. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62353. */
  62354. zOffset: number;
  62355. private _engine;
  62356. private _effect;
  62357. private _cachedDefines;
  62358. private _savedDepthWrite;
  62359. /**
  62360. * Instantiates a new outline renderer. (There could be only one per scene).
  62361. * @param scene Defines the scene it belongs to
  62362. */
  62363. constructor(scene: Scene);
  62364. /**
  62365. * Register the component to one instance of a scene.
  62366. */
  62367. register(): void;
  62368. /**
  62369. * Rebuilds the elements related to this component in case of
  62370. * context lost for instance.
  62371. */
  62372. rebuild(): void;
  62373. /**
  62374. * Disposes the component and the associated ressources.
  62375. */
  62376. dispose(): void;
  62377. /**
  62378. * Renders the outline in the canvas.
  62379. * @param subMesh Defines the sumesh to render
  62380. * @param batch Defines the batch of meshes in case of instances
  62381. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62382. */
  62383. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62384. /**
  62385. * Returns whether or not the outline renderer is ready for a given submesh.
  62386. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62387. * @param subMesh Defines the submesh to check readyness for
  62388. * @param useInstances Defines wheter wee are trying to render instances or not
  62389. * @returns true if ready otherwise false
  62390. */
  62391. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62392. private _beforeRenderingMesh;
  62393. private _afterRenderingMesh;
  62394. }
  62395. }
  62396. declare module "babylonjs/Rendering/index" {
  62397. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62398. export * from "babylonjs/Rendering/depthRenderer";
  62399. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62400. export * from "babylonjs/Rendering/edgesRenderer";
  62401. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62402. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62403. export * from "babylonjs/Rendering/outlineRenderer";
  62404. export * from "babylonjs/Rendering/renderingGroup";
  62405. export * from "babylonjs/Rendering/renderingManager";
  62406. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62407. }
  62408. declare module "babylonjs/Sprites/index" {
  62409. export * from "babylonjs/Sprites/sprite";
  62410. export * from "babylonjs/Sprites/spriteManager";
  62411. export * from "babylonjs/Sprites/spriteSceneComponent";
  62412. }
  62413. declare module "babylonjs/Misc/assetsManager" {
  62414. import { Scene } from "babylonjs/scene";
  62415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62416. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62417. import { Skeleton } from "babylonjs/Bones/skeleton";
  62418. import { Observable } from "babylonjs/Misc/observable";
  62419. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62420. import { Texture } from "babylonjs/Materials/Textures/texture";
  62421. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62422. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62423. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62424. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62425. /**
  62426. * Defines the list of states available for a task inside a AssetsManager
  62427. */
  62428. export enum AssetTaskState {
  62429. /**
  62430. * Initialization
  62431. */
  62432. INIT = 0,
  62433. /**
  62434. * Running
  62435. */
  62436. RUNNING = 1,
  62437. /**
  62438. * Done
  62439. */
  62440. DONE = 2,
  62441. /**
  62442. * Error
  62443. */
  62444. ERROR = 3
  62445. }
  62446. /**
  62447. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62448. */
  62449. export abstract class AbstractAssetTask {
  62450. /**
  62451. * Task name
  62452. */ name: string;
  62453. /**
  62454. * Callback called when the task is successful
  62455. */
  62456. onSuccess: (task: any) => void;
  62457. /**
  62458. * Callback called when the task is not successful
  62459. */
  62460. onError: (task: any, message?: string, exception?: any) => void;
  62461. /**
  62462. * Creates a new AssetsManager
  62463. * @param name defines the name of the task
  62464. */
  62465. constructor(
  62466. /**
  62467. * Task name
  62468. */ name: string);
  62469. private _isCompleted;
  62470. private _taskState;
  62471. private _errorObject;
  62472. /**
  62473. * Get if the task is completed
  62474. */
  62475. readonly isCompleted: boolean;
  62476. /**
  62477. * Gets the current state of the task
  62478. */
  62479. readonly taskState: AssetTaskState;
  62480. /**
  62481. * Gets the current error object (if task is in error)
  62482. */
  62483. readonly errorObject: {
  62484. message?: string;
  62485. exception?: any;
  62486. };
  62487. /**
  62488. * Internal only
  62489. * @hidden
  62490. */
  62491. _setErrorObject(message?: string, exception?: any): void;
  62492. /**
  62493. * Execute the current task
  62494. * @param scene defines the scene where you want your assets to be loaded
  62495. * @param onSuccess is a callback called when the task is successfully executed
  62496. * @param onError is a callback called if an error occurs
  62497. */
  62498. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62499. /**
  62500. * Execute the current task
  62501. * @param scene defines the scene where you want your assets to be loaded
  62502. * @param onSuccess is a callback called when the task is successfully executed
  62503. * @param onError is a callback called if an error occurs
  62504. */
  62505. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62506. /**
  62507. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62508. * This can be used with failed tasks that have the reason for failure fixed.
  62509. */
  62510. reset(): void;
  62511. private onErrorCallback;
  62512. private onDoneCallback;
  62513. }
  62514. /**
  62515. * Define the interface used by progress events raised during assets loading
  62516. */
  62517. export interface IAssetsProgressEvent {
  62518. /**
  62519. * Defines the number of remaining tasks to process
  62520. */
  62521. remainingCount: number;
  62522. /**
  62523. * Defines the total number of tasks
  62524. */
  62525. totalCount: number;
  62526. /**
  62527. * Defines the task that was just processed
  62528. */
  62529. task: AbstractAssetTask;
  62530. }
  62531. /**
  62532. * Class used to share progress information about assets loading
  62533. */
  62534. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62535. /**
  62536. * Defines the number of remaining tasks to process
  62537. */
  62538. remainingCount: number;
  62539. /**
  62540. * Defines the total number of tasks
  62541. */
  62542. totalCount: number;
  62543. /**
  62544. * Defines the task that was just processed
  62545. */
  62546. task: AbstractAssetTask;
  62547. /**
  62548. * Creates a AssetsProgressEvent
  62549. * @param remainingCount defines the number of remaining tasks to process
  62550. * @param totalCount defines the total number of tasks
  62551. * @param task defines the task that was just processed
  62552. */
  62553. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62554. }
  62555. /**
  62556. * Define a task used by AssetsManager to load meshes
  62557. */
  62558. export class MeshAssetTask extends AbstractAssetTask {
  62559. /**
  62560. * Defines the name of the task
  62561. */
  62562. name: string;
  62563. /**
  62564. * Defines the list of mesh's names you want to load
  62565. */
  62566. meshesNames: any;
  62567. /**
  62568. * Defines the root url to use as a base to load your meshes and associated resources
  62569. */
  62570. rootUrl: string;
  62571. /**
  62572. * Defines the filename of the scene to load from
  62573. */
  62574. sceneFilename: string;
  62575. /**
  62576. * Gets the list of loaded meshes
  62577. */
  62578. loadedMeshes: Array<AbstractMesh>;
  62579. /**
  62580. * Gets the list of loaded particle systems
  62581. */
  62582. loadedParticleSystems: Array<IParticleSystem>;
  62583. /**
  62584. * Gets the list of loaded skeletons
  62585. */
  62586. loadedSkeletons: Array<Skeleton>;
  62587. /**
  62588. * Gets the list of loaded animation groups
  62589. */
  62590. loadedAnimationGroups: Array<AnimationGroup>;
  62591. /**
  62592. * Callback called when the task is successful
  62593. */
  62594. onSuccess: (task: MeshAssetTask) => void;
  62595. /**
  62596. * Callback called when the task is successful
  62597. */
  62598. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62599. /**
  62600. * Creates a new MeshAssetTask
  62601. * @param name defines the name of the task
  62602. * @param meshesNames defines the list of mesh's names you want to load
  62603. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62604. * @param sceneFilename defines the filename of the scene to load from
  62605. */
  62606. constructor(
  62607. /**
  62608. * Defines the name of the task
  62609. */
  62610. name: string,
  62611. /**
  62612. * Defines the list of mesh's names you want to load
  62613. */
  62614. meshesNames: any,
  62615. /**
  62616. * Defines the root url to use as a base to load your meshes and associated resources
  62617. */
  62618. rootUrl: string,
  62619. /**
  62620. * Defines the filename of the scene to load from
  62621. */
  62622. sceneFilename: string);
  62623. /**
  62624. * Execute the current task
  62625. * @param scene defines the scene where you want your assets to be loaded
  62626. * @param onSuccess is a callback called when the task is successfully executed
  62627. * @param onError is a callback called if an error occurs
  62628. */
  62629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62630. }
  62631. /**
  62632. * Define a task used by AssetsManager to load text content
  62633. */
  62634. export class TextFileAssetTask extends AbstractAssetTask {
  62635. /**
  62636. * Defines the name of the task
  62637. */
  62638. name: string;
  62639. /**
  62640. * Defines the location of the file to load
  62641. */
  62642. url: string;
  62643. /**
  62644. * Gets the loaded text string
  62645. */
  62646. text: string;
  62647. /**
  62648. * Callback called when the task is successful
  62649. */
  62650. onSuccess: (task: TextFileAssetTask) => void;
  62651. /**
  62652. * Callback called when the task is successful
  62653. */
  62654. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62655. /**
  62656. * Creates a new TextFileAssetTask object
  62657. * @param name defines the name of the task
  62658. * @param url defines the location of the file to load
  62659. */
  62660. constructor(
  62661. /**
  62662. * Defines the name of the task
  62663. */
  62664. name: string,
  62665. /**
  62666. * Defines the location of the file to load
  62667. */
  62668. url: string);
  62669. /**
  62670. * Execute the current task
  62671. * @param scene defines the scene where you want your assets to be loaded
  62672. * @param onSuccess is a callback called when the task is successfully executed
  62673. * @param onError is a callback called if an error occurs
  62674. */
  62675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62676. }
  62677. /**
  62678. * Define a task used by AssetsManager to load binary data
  62679. */
  62680. export class BinaryFileAssetTask extends AbstractAssetTask {
  62681. /**
  62682. * Defines the name of the task
  62683. */
  62684. name: string;
  62685. /**
  62686. * Defines the location of the file to load
  62687. */
  62688. url: string;
  62689. /**
  62690. * Gets the lodaded data (as an array buffer)
  62691. */
  62692. data: ArrayBuffer;
  62693. /**
  62694. * Callback called when the task is successful
  62695. */
  62696. onSuccess: (task: BinaryFileAssetTask) => void;
  62697. /**
  62698. * Callback called when the task is successful
  62699. */
  62700. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62701. /**
  62702. * Creates a new BinaryFileAssetTask object
  62703. * @param name defines the name of the new task
  62704. * @param url defines the location of the file to load
  62705. */
  62706. constructor(
  62707. /**
  62708. * Defines the name of the task
  62709. */
  62710. name: string,
  62711. /**
  62712. * Defines the location of the file to load
  62713. */
  62714. url: string);
  62715. /**
  62716. * Execute the current task
  62717. * @param scene defines the scene where you want your assets to be loaded
  62718. * @param onSuccess is a callback called when the task is successfully executed
  62719. * @param onError is a callback called if an error occurs
  62720. */
  62721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62722. }
  62723. /**
  62724. * Define a task used by AssetsManager to load images
  62725. */
  62726. export class ImageAssetTask extends AbstractAssetTask {
  62727. /**
  62728. * Defines the name of the task
  62729. */
  62730. name: string;
  62731. /**
  62732. * Defines the location of the image to load
  62733. */
  62734. url: string;
  62735. /**
  62736. * Gets the loaded images
  62737. */
  62738. image: HTMLImageElement;
  62739. /**
  62740. * Callback called when the task is successful
  62741. */
  62742. onSuccess: (task: ImageAssetTask) => void;
  62743. /**
  62744. * Callback called when the task is successful
  62745. */
  62746. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62747. /**
  62748. * Creates a new ImageAssetTask
  62749. * @param name defines the name of the task
  62750. * @param url defines the location of the image to load
  62751. */
  62752. constructor(
  62753. /**
  62754. * Defines the name of the task
  62755. */
  62756. name: string,
  62757. /**
  62758. * Defines the location of the image to load
  62759. */
  62760. url: string);
  62761. /**
  62762. * Execute the current task
  62763. * @param scene defines the scene where you want your assets to be loaded
  62764. * @param onSuccess is a callback called when the task is successfully executed
  62765. * @param onError is a callback called if an error occurs
  62766. */
  62767. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62768. }
  62769. /**
  62770. * Defines the interface used by texture loading tasks
  62771. */
  62772. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62773. /**
  62774. * Gets the loaded texture
  62775. */
  62776. texture: TEX;
  62777. }
  62778. /**
  62779. * Define a task used by AssetsManager to load 2D textures
  62780. */
  62781. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62782. /**
  62783. * Defines the name of the task
  62784. */
  62785. name: string;
  62786. /**
  62787. * Defines the location of the file to load
  62788. */
  62789. url: string;
  62790. /**
  62791. * Defines if mipmap should not be generated (default is false)
  62792. */
  62793. noMipmap?: boolean | undefined;
  62794. /**
  62795. * Defines if texture must be inverted on Y axis (default is false)
  62796. */
  62797. invertY?: boolean | undefined;
  62798. /**
  62799. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62800. */
  62801. samplingMode: number;
  62802. /**
  62803. * Gets the loaded texture
  62804. */
  62805. texture: Texture;
  62806. /**
  62807. * Callback called when the task is successful
  62808. */
  62809. onSuccess: (task: TextureAssetTask) => void;
  62810. /**
  62811. * Callback called when the task is successful
  62812. */
  62813. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62814. /**
  62815. * Creates a new TextureAssetTask object
  62816. * @param name defines the name of the task
  62817. * @param url defines the location of the file to load
  62818. * @param noMipmap defines if mipmap should not be generated (default is false)
  62819. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62820. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62821. */
  62822. constructor(
  62823. /**
  62824. * Defines the name of the task
  62825. */
  62826. name: string,
  62827. /**
  62828. * Defines the location of the file to load
  62829. */
  62830. url: string,
  62831. /**
  62832. * Defines if mipmap should not be generated (default is false)
  62833. */
  62834. noMipmap?: boolean | undefined,
  62835. /**
  62836. * Defines if texture must be inverted on Y axis (default is false)
  62837. */
  62838. invertY?: boolean | undefined,
  62839. /**
  62840. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62841. */
  62842. samplingMode?: number);
  62843. /**
  62844. * Execute the current task
  62845. * @param scene defines the scene where you want your assets to be loaded
  62846. * @param onSuccess is a callback called when the task is successfully executed
  62847. * @param onError is a callback called if an error occurs
  62848. */
  62849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62850. }
  62851. /**
  62852. * Define a task used by AssetsManager to load cube textures
  62853. */
  62854. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62855. /**
  62856. * Defines the name of the task
  62857. */
  62858. name: string;
  62859. /**
  62860. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62861. */
  62862. url: string;
  62863. /**
  62864. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62865. */
  62866. extensions?: string[] | undefined;
  62867. /**
  62868. * Defines if mipmaps should not be generated (default is false)
  62869. */
  62870. noMipmap?: boolean | undefined;
  62871. /**
  62872. * Defines the explicit list of files (undefined by default)
  62873. */
  62874. files?: string[] | undefined;
  62875. /**
  62876. * Gets the loaded texture
  62877. */
  62878. texture: CubeTexture;
  62879. /**
  62880. * Callback called when the task is successful
  62881. */
  62882. onSuccess: (task: CubeTextureAssetTask) => void;
  62883. /**
  62884. * Callback called when the task is successful
  62885. */
  62886. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62887. /**
  62888. * Creates a new CubeTextureAssetTask
  62889. * @param name defines the name of the task
  62890. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62891. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62892. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62893. * @param files defines the explicit list of files (undefined by default)
  62894. */
  62895. constructor(
  62896. /**
  62897. * Defines the name of the task
  62898. */
  62899. name: string,
  62900. /**
  62901. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62902. */
  62903. url: string,
  62904. /**
  62905. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62906. */
  62907. extensions?: string[] | undefined,
  62908. /**
  62909. * Defines if mipmaps should not be generated (default is false)
  62910. */
  62911. noMipmap?: boolean | undefined,
  62912. /**
  62913. * Defines the explicit list of files (undefined by default)
  62914. */
  62915. files?: string[] | undefined);
  62916. /**
  62917. * Execute the current task
  62918. * @param scene defines the scene where you want your assets to be loaded
  62919. * @param onSuccess is a callback called when the task is successfully executed
  62920. * @param onError is a callback called if an error occurs
  62921. */
  62922. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62923. }
  62924. /**
  62925. * Define a task used by AssetsManager to load HDR cube textures
  62926. */
  62927. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62928. /**
  62929. * Defines the name of the task
  62930. */
  62931. name: string;
  62932. /**
  62933. * Defines the location of the file to load
  62934. */
  62935. url: string;
  62936. /**
  62937. * Defines the desired size (the more it increases the longer the generation will be)
  62938. */
  62939. size: number;
  62940. /**
  62941. * Defines if mipmaps should not be generated (default is false)
  62942. */
  62943. noMipmap: boolean;
  62944. /**
  62945. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62946. */
  62947. generateHarmonics: boolean;
  62948. /**
  62949. * 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)
  62950. */
  62951. gammaSpace: boolean;
  62952. /**
  62953. * Internal Use Only
  62954. */
  62955. reserved: boolean;
  62956. /**
  62957. * Gets the loaded texture
  62958. */
  62959. texture: HDRCubeTexture;
  62960. /**
  62961. * Callback called when the task is successful
  62962. */
  62963. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62964. /**
  62965. * Callback called when the task is successful
  62966. */
  62967. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62968. /**
  62969. * Creates a new HDRCubeTextureAssetTask object
  62970. * @param name defines the name of the task
  62971. * @param url defines the location of the file to load
  62972. * @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.
  62973. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62974. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62975. * @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)
  62976. * @param reserved Internal use only
  62977. */
  62978. constructor(
  62979. /**
  62980. * Defines the name of the task
  62981. */
  62982. name: string,
  62983. /**
  62984. * Defines the location of the file to load
  62985. */
  62986. url: string,
  62987. /**
  62988. * Defines the desired size (the more it increases the longer the generation will be)
  62989. */
  62990. size: number,
  62991. /**
  62992. * Defines if mipmaps should not be generated (default is false)
  62993. */
  62994. noMipmap?: boolean,
  62995. /**
  62996. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62997. */
  62998. generateHarmonics?: boolean,
  62999. /**
  63000. * 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)
  63001. */
  63002. gammaSpace?: boolean,
  63003. /**
  63004. * Internal Use Only
  63005. */
  63006. reserved?: boolean);
  63007. /**
  63008. * Execute the current task
  63009. * @param scene defines the scene where you want your assets to be loaded
  63010. * @param onSuccess is a callback called when the task is successfully executed
  63011. * @param onError is a callback called if an error occurs
  63012. */
  63013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63014. }
  63015. /**
  63016. * Define a task used by AssetsManager to load Equirectangular cube textures
  63017. */
  63018. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  63019. /**
  63020. * Defines the name of the task
  63021. */
  63022. name: string;
  63023. /**
  63024. * Defines the location of the file to load
  63025. */
  63026. url: string;
  63027. /**
  63028. * Defines the desired size (the more it increases the longer the generation will be)
  63029. */
  63030. size: number;
  63031. /**
  63032. * Defines if mipmaps should not be generated (default is false)
  63033. */
  63034. noMipmap: boolean;
  63035. /**
  63036. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63037. * but the standard material would require them in Gamma space) (default is true)
  63038. */
  63039. gammaSpace: boolean;
  63040. /**
  63041. * Gets the loaded texture
  63042. */
  63043. texture: EquiRectangularCubeTexture;
  63044. /**
  63045. * Callback called when the task is successful
  63046. */
  63047. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  63048. /**
  63049. * Callback called when the task is successful
  63050. */
  63051. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  63052. /**
  63053. * Creates a new EquiRectangularCubeTextureAssetTask object
  63054. * @param name defines the name of the task
  63055. * @param url defines the location of the file to load
  63056. * @param size defines the desired size (the more it increases the longer the generation will be)
  63057. * If the size is omitted this implies you are using a preprocessed cubemap.
  63058. * @param noMipmap defines if mipmaps should not be generated (default is false)
  63059. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  63060. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  63061. * (default is true)
  63062. */
  63063. constructor(
  63064. /**
  63065. * Defines the name of the task
  63066. */
  63067. name: string,
  63068. /**
  63069. * Defines the location of the file to load
  63070. */
  63071. url: string,
  63072. /**
  63073. * Defines the desired size (the more it increases the longer the generation will be)
  63074. */
  63075. size: number,
  63076. /**
  63077. * Defines if mipmaps should not be generated (default is false)
  63078. */
  63079. noMipmap?: boolean,
  63080. /**
  63081. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  63082. * but the standard material would require them in Gamma space) (default is true)
  63083. */
  63084. gammaSpace?: boolean);
  63085. /**
  63086. * Execute the current task
  63087. * @param scene defines the scene where you want your assets to be loaded
  63088. * @param onSuccess is a callback called when the task is successfully executed
  63089. * @param onError is a callback called if an error occurs
  63090. */
  63091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  63092. }
  63093. /**
  63094. * This class can be used to easily import assets into a scene
  63095. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  63096. */
  63097. export class AssetsManager {
  63098. private _scene;
  63099. private _isLoading;
  63100. protected _tasks: AbstractAssetTask[];
  63101. protected _waitingTasksCount: number;
  63102. protected _totalTasksCount: number;
  63103. /**
  63104. * Callback called when all tasks are processed
  63105. */
  63106. onFinish: (tasks: AbstractAssetTask[]) => void;
  63107. /**
  63108. * Callback called when a task is successful
  63109. */
  63110. onTaskSuccess: (task: AbstractAssetTask) => void;
  63111. /**
  63112. * Callback called when a task had an error
  63113. */
  63114. onTaskError: (task: AbstractAssetTask) => void;
  63115. /**
  63116. * Callback called when a task is done (whatever the result is)
  63117. */
  63118. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  63119. /**
  63120. * Observable called when all tasks are processed
  63121. */
  63122. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  63123. /**
  63124. * Observable called when a task had an error
  63125. */
  63126. onTaskErrorObservable: Observable<AbstractAssetTask>;
  63127. /**
  63128. * Observable called when all tasks were executed
  63129. */
  63130. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  63131. /**
  63132. * Observable called when a task is done (whatever the result is)
  63133. */
  63134. onProgressObservable: Observable<IAssetsProgressEvent>;
  63135. /**
  63136. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  63137. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  63138. */
  63139. useDefaultLoadingScreen: boolean;
  63140. /**
  63141. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  63142. * when all assets have been downloaded.
  63143. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  63144. */
  63145. autoHideLoadingUI: boolean;
  63146. /**
  63147. * Creates a new AssetsManager
  63148. * @param scene defines the scene to work on
  63149. */
  63150. constructor(scene: Scene);
  63151. /**
  63152. * Add a MeshAssetTask to the list of active tasks
  63153. * @param taskName defines the name of the new task
  63154. * @param meshesNames defines the name of meshes to load
  63155. * @param rootUrl defines the root url to use to locate files
  63156. * @param sceneFilename defines the filename of the scene file
  63157. * @returns a new MeshAssetTask object
  63158. */
  63159. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  63160. /**
  63161. * Add a TextFileAssetTask to the list of active tasks
  63162. * @param taskName defines the name of the new task
  63163. * @param url defines the url of the file to load
  63164. * @returns a new TextFileAssetTask object
  63165. */
  63166. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  63167. /**
  63168. * Add a BinaryFileAssetTask to the list of active tasks
  63169. * @param taskName defines the name of the new task
  63170. * @param url defines the url of the file to load
  63171. * @returns a new BinaryFileAssetTask object
  63172. */
  63173. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  63174. /**
  63175. * Add a ImageAssetTask to the list of active tasks
  63176. * @param taskName defines the name of the new task
  63177. * @param url defines the url of the file to load
  63178. * @returns a new ImageAssetTask object
  63179. */
  63180. addImageTask(taskName: string, url: string): ImageAssetTask;
  63181. /**
  63182. * Add a TextureAssetTask to the list of active tasks
  63183. * @param taskName defines the name of the new task
  63184. * @param url defines the url of the file to load
  63185. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63186. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  63187. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63188. * @returns a new TextureAssetTask object
  63189. */
  63190. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  63191. /**
  63192. * Add a CubeTextureAssetTask to the list of active tasks
  63193. * @param taskName defines the name of the new task
  63194. * @param url defines the url of the file to load
  63195. * @param extensions defines the extension to use to load the cube map (can be null)
  63196. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63197. * @param files defines the list of files to load (can be null)
  63198. * @returns a new CubeTextureAssetTask object
  63199. */
  63200. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  63201. /**
  63202. *
  63203. * Add a HDRCubeTextureAssetTask to the list of active tasks
  63204. * @param taskName defines the name of the new task
  63205. * @param url defines the url of the file to load
  63206. * @param size defines the size you want for the cubemap (can be null)
  63207. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63208. * @param generateHarmonics defines if you want to automatically generate (true by default)
  63209. * @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)
  63210. * @param reserved Internal use only
  63211. * @returns a new HDRCubeTextureAssetTask object
  63212. */
  63213. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  63214. /**
  63215. *
  63216. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  63217. * @param taskName defines the name of the new task
  63218. * @param url defines the url of the file to load
  63219. * @param size defines the size you want for the cubemap (can be null)
  63220. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  63221. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63222. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63223. * @returns a new EquiRectangularCubeTextureAssetTask object
  63224. */
  63225. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  63226. /**
  63227. * Remove a task from the assets manager.
  63228. * @param task the task to remove
  63229. */
  63230. removeTask(task: AbstractAssetTask): void;
  63231. private _decreaseWaitingTasksCount;
  63232. private _runTask;
  63233. /**
  63234. * Reset the AssetsManager and remove all tasks
  63235. * @return the current instance of the AssetsManager
  63236. */
  63237. reset(): AssetsManager;
  63238. /**
  63239. * Start the loading process
  63240. * @return the current instance of the AssetsManager
  63241. */
  63242. load(): AssetsManager;
  63243. /**
  63244. * Start the loading process as an async operation
  63245. * @return a promise returning the list of failed tasks
  63246. */
  63247. loadAsync(): Promise<void>;
  63248. }
  63249. }
  63250. declare module "babylonjs/Misc/deferred" {
  63251. /**
  63252. * Wrapper class for promise with external resolve and reject.
  63253. */
  63254. export class Deferred<T> {
  63255. /**
  63256. * The promise associated with this deferred object.
  63257. */
  63258. readonly promise: Promise<T>;
  63259. private _resolve;
  63260. private _reject;
  63261. /**
  63262. * The resolve method of the promise associated with this deferred object.
  63263. */
  63264. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  63265. /**
  63266. * The reject method of the promise associated with this deferred object.
  63267. */
  63268. readonly reject: (reason?: any) => void;
  63269. /**
  63270. * Constructor for this deferred object.
  63271. */
  63272. constructor();
  63273. }
  63274. }
  63275. declare module "babylonjs/Misc/meshExploder" {
  63276. import { Mesh } from "babylonjs/Meshes/mesh";
  63277. /**
  63278. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  63279. */
  63280. export class MeshExploder {
  63281. private _centerMesh;
  63282. private _meshes;
  63283. private _meshesOrigins;
  63284. private _toCenterVectors;
  63285. private _scaledDirection;
  63286. private _newPosition;
  63287. private _centerPosition;
  63288. /**
  63289. * Explodes meshes from a center mesh.
  63290. * @param meshes The meshes to explode.
  63291. * @param centerMesh The mesh to be center of explosion.
  63292. */
  63293. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  63294. private _setCenterMesh;
  63295. /**
  63296. * Get class name
  63297. * @returns "MeshExploder"
  63298. */
  63299. getClassName(): string;
  63300. /**
  63301. * "Exploded meshes"
  63302. * @returns Array of meshes with the centerMesh at index 0.
  63303. */
  63304. getMeshes(): Array<Mesh>;
  63305. /**
  63306. * Explodes meshes giving a specific direction
  63307. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63308. */
  63309. explode(direction?: number): void;
  63310. }
  63311. }
  63312. declare module "babylonjs/Misc/filesInput" {
  63313. import { Engine } from "babylonjs/Engines/engine";
  63314. import { Scene } from "babylonjs/scene";
  63315. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63316. /**
  63317. * Class used to help managing file picking and drag'n'drop
  63318. */
  63319. export class FilesInput {
  63320. /**
  63321. * List of files ready to be loaded
  63322. */
  63323. static readonly FilesToLoad: {
  63324. [key: string]: File;
  63325. };
  63326. /**
  63327. * Callback called when a file is processed
  63328. */
  63329. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63330. private _engine;
  63331. private _currentScene;
  63332. private _sceneLoadedCallback;
  63333. private _progressCallback;
  63334. private _additionalRenderLoopLogicCallback;
  63335. private _textureLoadingCallback;
  63336. private _startingProcessingFilesCallback;
  63337. private _onReloadCallback;
  63338. private _errorCallback;
  63339. private _elementToMonitor;
  63340. private _sceneFileToLoad;
  63341. private _filesToLoad;
  63342. /**
  63343. * Creates a new FilesInput
  63344. * @param engine defines the rendering engine
  63345. * @param scene defines the hosting scene
  63346. * @param sceneLoadedCallback callback called when scene is loaded
  63347. * @param progressCallback callback called to track progress
  63348. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63349. * @param textureLoadingCallback callback called when a texture is loading
  63350. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63351. * @param onReloadCallback callback called when a reload is requested
  63352. * @param errorCallback callback call if an error occurs
  63353. */
  63354. 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);
  63355. private _dragEnterHandler;
  63356. private _dragOverHandler;
  63357. private _dropHandler;
  63358. /**
  63359. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63360. * @param elementToMonitor defines the DOM element to track
  63361. */
  63362. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63363. /**
  63364. * Release all associated resources
  63365. */
  63366. dispose(): void;
  63367. private renderFunction;
  63368. private drag;
  63369. private drop;
  63370. private _traverseFolder;
  63371. private _processFiles;
  63372. /**
  63373. * Load files from a drop event
  63374. * @param event defines the drop event to use as source
  63375. */
  63376. loadFiles(event: any): void;
  63377. private _processReload;
  63378. /**
  63379. * Reload the current scene from the loaded files
  63380. */
  63381. reload(): void;
  63382. }
  63383. }
  63384. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63385. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63386. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63387. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63388. }
  63389. declare module "babylonjs/Misc/sceneOptimizer" {
  63390. import { Scene, IDisposable } from "babylonjs/scene";
  63391. import { Observable } from "babylonjs/Misc/observable";
  63392. /**
  63393. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63394. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63395. */
  63396. export class SceneOptimization {
  63397. /**
  63398. * Defines the priority of this optimization (0 by default which means first in the list)
  63399. */
  63400. priority: number;
  63401. /**
  63402. * Gets a string describing the action executed by the current optimization
  63403. * @returns description string
  63404. */
  63405. getDescription(): string;
  63406. /**
  63407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63408. * @param scene defines the current scene where to apply this optimization
  63409. * @param optimizer defines the current optimizer
  63410. * @returns true if everything that can be done was applied
  63411. */
  63412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63413. /**
  63414. * Creates the SceneOptimization object
  63415. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63416. * @param desc defines the description associated with the optimization
  63417. */
  63418. constructor(
  63419. /**
  63420. * Defines the priority of this optimization (0 by default which means first in the list)
  63421. */
  63422. priority?: number);
  63423. }
  63424. /**
  63425. * Defines an optimization used to reduce the size of render target textures
  63426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63427. */
  63428. export class TextureOptimization extends SceneOptimization {
  63429. /**
  63430. * Defines the priority of this optimization (0 by default which means first in the list)
  63431. */
  63432. priority: number;
  63433. /**
  63434. * 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
  63435. */
  63436. maximumSize: number;
  63437. /**
  63438. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63439. */
  63440. step: number;
  63441. /**
  63442. * Gets a string describing the action executed by the current optimization
  63443. * @returns description string
  63444. */
  63445. getDescription(): string;
  63446. /**
  63447. * Creates the TextureOptimization object
  63448. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63449. * @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
  63450. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63451. */
  63452. constructor(
  63453. /**
  63454. * Defines the priority of this optimization (0 by default which means first in the list)
  63455. */
  63456. priority?: number,
  63457. /**
  63458. * 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
  63459. */
  63460. maximumSize?: number,
  63461. /**
  63462. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63463. */
  63464. step?: number);
  63465. /**
  63466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63467. * @param scene defines the current scene where to apply this optimization
  63468. * @param optimizer defines the current optimizer
  63469. * @returns true if everything that can be done was applied
  63470. */
  63471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63472. }
  63473. /**
  63474. * Defines an optimization used to increase or decrease the rendering resolution
  63475. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63476. */
  63477. export class HardwareScalingOptimization extends SceneOptimization {
  63478. /**
  63479. * Defines the priority of this optimization (0 by default which means first in the list)
  63480. */
  63481. priority: number;
  63482. /**
  63483. * Defines the maximum scale to use (2 by default)
  63484. */
  63485. maximumScale: number;
  63486. /**
  63487. * Defines the step to use between two passes (0.5 by default)
  63488. */
  63489. step: number;
  63490. private _currentScale;
  63491. private _directionOffset;
  63492. /**
  63493. * Gets a string describing the action executed by the current optimization
  63494. * @return description string
  63495. */
  63496. getDescription(): string;
  63497. /**
  63498. * Creates the HardwareScalingOptimization object
  63499. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63500. * @param maximumScale defines the maximum scale to use (2 by default)
  63501. * @param step defines the step to use between two passes (0.5 by default)
  63502. */
  63503. constructor(
  63504. /**
  63505. * Defines the priority of this optimization (0 by default which means first in the list)
  63506. */
  63507. priority?: number,
  63508. /**
  63509. * Defines the maximum scale to use (2 by default)
  63510. */
  63511. maximumScale?: number,
  63512. /**
  63513. * Defines the step to use between two passes (0.5 by default)
  63514. */
  63515. step?: number);
  63516. /**
  63517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63518. * @param scene defines the current scene where to apply this optimization
  63519. * @param optimizer defines the current optimizer
  63520. * @returns true if everything that can be done was applied
  63521. */
  63522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63523. }
  63524. /**
  63525. * Defines an optimization used to remove shadows
  63526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63527. */
  63528. export class ShadowsOptimization extends SceneOptimization {
  63529. /**
  63530. * Gets a string describing the action executed by the current optimization
  63531. * @return description string
  63532. */
  63533. getDescription(): string;
  63534. /**
  63535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63536. * @param scene defines the current scene where to apply this optimization
  63537. * @param optimizer defines the current optimizer
  63538. * @returns true if everything that can be done was applied
  63539. */
  63540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63541. }
  63542. /**
  63543. * Defines an optimization used to turn post-processes off
  63544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63545. */
  63546. export class PostProcessesOptimization extends SceneOptimization {
  63547. /**
  63548. * Gets a string describing the action executed by the current optimization
  63549. * @return description string
  63550. */
  63551. getDescription(): string;
  63552. /**
  63553. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63554. * @param scene defines the current scene where to apply this optimization
  63555. * @param optimizer defines the current optimizer
  63556. * @returns true if everything that can be done was applied
  63557. */
  63558. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63559. }
  63560. /**
  63561. * Defines an optimization used to turn lens flares off
  63562. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63563. */
  63564. export class LensFlaresOptimization extends SceneOptimization {
  63565. /**
  63566. * Gets a string describing the action executed by the current optimization
  63567. * @return description string
  63568. */
  63569. getDescription(): string;
  63570. /**
  63571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63572. * @param scene defines the current scene where to apply this optimization
  63573. * @param optimizer defines the current optimizer
  63574. * @returns true if everything that can be done was applied
  63575. */
  63576. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63577. }
  63578. /**
  63579. * Defines an optimization based on user defined callback.
  63580. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63581. */
  63582. export class CustomOptimization extends SceneOptimization {
  63583. /**
  63584. * Callback called to apply the custom optimization.
  63585. */
  63586. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63587. /**
  63588. * Callback called to get custom description
  63589. */
  63590. onGetDescription: () => string;
  63591. /**
  63592. * Gets a string describing the action executed by the current optimization
  63593. * @returns description string
  63594. */
  63595. getDescription(): string;
  63596. /**
  63597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63598. * @param scene defines the current scene where to apply this optimization
  63599. * @param optimizer defines the current optimizer
  63600. * @returns true if everything that can be done was applied
  63601. */
  63602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63603. }
  63604. /**
  63605. * Defines an optimization used to turn particles off
  63606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63607. */
  63608. export class ParticlesOptimization extends SceneOptimization {
  63609. /**
  63610. * Gets a string describing the action executed by the current optimization
  63611. * @return description string
  63612. */
  63613. getDescription(): string;
  63614. /**
  63615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63616. * @param scene defines the current scene where to apply this optimization
  63617. * @param optimizer defines the current optimizer
  63618. * @returns true if everything that can be done was applied
  63619. */
  63620. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63621. }
  63622. /**
  63623. * Defines an optimization used to turn render targets off
  63624. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63625. */
  63626. export class RenderTargetsOptimization extends SceneOptimization {
  63627. /**
  63628. * Gets a string describing the action executed by the current optimization
  63629. * @return description string
  63630. */
  63631. getDescription(): string;
  63632. /**
  63633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63634. * @param scene defines the current scene where to apply this optimization
  63635. * @param optimizer defines the current optimizer
  63636. * @returns true if everything that can be done was applied
  63637. */
  63638. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63639. }
  63640. /**
  63641. * Defines an optimization used to merge meshes with compatible materials
  63642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63643. */
  63644. export class MergeMeshesOptimization extends SceneOptimization {
  63645. private static _UpdateSelectionTree;
  63646. /**
  63647. * Gets or sets a boolean which defines if optimization octree has to be updated
  63648. */
  63649. /**
  63650. * Gets or sets a boolean which defines if optimization octree has to be updated
  63651. */
  63652. static UpdateSelectionTree: boolean;
  63653. /**
  63654. * Gets a string describing the action executed by the current optimization
  63655. * @return description string
  63656. */
  63657. getDescription(): string;
  63658. private _canBeMerged;
  63659. /**
  63660. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63661. * @param scene defines the current scene where to apply this optimization
  63662. * @param optimizer defines the current optimizer
  63663. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63664. * @returns true if everything that can be done was applied
  63665. */
  63666. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63667. }
  63668. /**
  63669. * Defines a list of options used by SceneOptimizer
  63670. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63671. */
  63672. export class SceneOptimizerOptions {
  63673. /**
  63674. * Defines the target frame rate to reach (60 by default)
  63675. */
  63676. targetFrameRate: number;
  63677. /**
  63678. * Defines the interval between two checkes (2000ms by default)
  63679. */
  63680. trackerDuration: number;
  63681. /**
  63682. * Gets the list of optimizations to apply
  63683. */
  63684. optimizations: SceneOptimization[];
  63685. /**
  63686. * Creates a new list of options used by SceneOptimizer
  63687. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63688. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63689. */
  63690. constructor(
  63691. /**
  63692. * Defines the target frame rate to reach (60 by default)
  63693. */
  63694. targetFrameRate?: number,
  63695. /**
  63696. * Defines the interval between two checkes (2000ms by default)
  63697. */
  63698. trackerDuration?: number);
  63699. /**
  63700. * Add a new optimization
  63701. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63702. * @returns the current SceneOptimizerOptions
  63703. */
  63704. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63705. /**
  63706. * Add a new custom optimization
  63707. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63708. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63709. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63710. * @returns the current SceneOptimizerOptions
  63711. */
  63712. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63713. /**
  63714. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63715. * @param targetFrameRate defines the target frame rate (60 by default)
  63716. * @returns a SceneOptimizerOptions object
  63717. */
  63718. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63719. /**
  63720. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63721. * @param targetFrameRate defines the target frame rate (60 by default)
  63722. * @returns a SceneOptimizerOptions object
  63723. */
  63724. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63725. /**
  63726. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63727. * @param targetFrameRate defines the target frame rate (60 by default)
  63728. * @returns a SceneOptimizerOptions object
  63729. */
  63730. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63731. }
  63732. /**
  63733. * Class used to run optimizations in order to reach a target frame rate
  63734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63735. */
  63736. export class SceneOptimizer implements IDisposable {
  63737. private _isRunning;
  63738. private _options;
  63739. private _scene;
  63740. private _currentPriorityLevel;
  63741. private _targetFrameRate;
  63742. private _trackerDuration;
  63743. private _currentFrameRate;
  63744. private _sceneDisposeObserver;
  63745. private _improvementMode;
  63746. /**
  63747. * Defines an observable called when the optimizer reaches the target frame rate
  63748. */
  63749. onSuccessObservable: Observable<SceneOptimizer>;
  63750. /**
  63751. * Defines an observable called when the optimizer enables an optimization
  63752. */
  63753. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63754. /**
  63755. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63756. */
  63757. onFailureObservable: Observable<SceneOptimizer>;
  63758. /**
  63759. * Gets a boolean indicating if the optimizer is in improvement mode
  63760. */
  63761. readonly isInImprovementMode: boolean;
  63762. /**
  63763. * Gets the current priority level (0 at start)
  63764. */
  63765. readonly currentPriorityLevel: number;
  63766. /**
  63767. * Gets the current frame rate checked by the SceneOptimizer
  63768. */
  63769. readonly currentFrameRate: number;
  63770. /**
  63771. * Gets or sets the current target frame rate (60 by default)
  63772. */
  63773. /**
  63774. * Gets or sets the current target frame rate (60 by default)
  63775. */
  63776. targetFrameRate: number;
  63777. /**
  63778. * Gets or sets the current interval between two checks (every 2000ms by default)
  63779. */
  63780. /**
  63781. * Gets or sets the current interval between two checks (every 2000ms by default)
  63782. */
  63783. trackerDuration: number;
  63784. /**
  63785. * Gets the list of active optimizations
  63786. */
  63787. readonly optimizations: SceneOptimization[];
  63788. /**
  63789. * Creates a new SceneOptimizer
  63790. * @param scene defines the scene to work on
  63791. * @param options defines the options to use with the SceneOptimizer
  63792. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63793. * @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)
  63794. */
  63795. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63796. /**
  63797. * Stops the current optimizer
  63798. */
  63799. stop(): void;
  63800. /**
  63801. * Reset the optimizer to initial step (current priority level = 0)
  63802. */
  63803. reset(): void;
  63804. /**
  63805. * Start the optimizer. By default it will try to reach a specific framerate
  63806. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63807. */
  63808. start(): void;
  63809. private _checkCurrentState;
  63810. /**
  63811. * Release all resources
  63812. */
  63813. dispose(): void;
  63814. /**
  63815. * Helper function to create a SceneOptimizer with one single line of code
  63816. * @param scene defines the scene to work on
  63817. * @param options defines the options to use with the SceneOptimizer
  63818. * @param onSuccess defines a callback to call on success
  63819. * @param onFailure defines a callback to call on failure
  63820. * @returns the new SceneOptimizer object
  63821. */
  63822. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63823. }
  63824. }
  63825. declare module "babylonjs/Misc/sceneSerializer" {
  63826. import { Scene } from "babylonjs/scene";
  63827. /**
  63828. * Class used to serialize a scene into a string
  63829. */
  63830. export class SceneSerializer {
  63831. /**
  63832. * Clear cache used by a previous serialization
  63833. */
  63834. static ClearCache(): void;
  63835. /**
  63836. * Serialize a scene into a JSON compatible object
  63837. * @param scene defines the scene to serialize
  63838. * @returns a JSON compatible object
  63839. */
  63840. static Serialize(scene: Scene): any;
  63841. /**
  63842. * Serialize a mesh into a JSON compatible object
  63843. * @param toSerialize defines the mesh to serialize
  63844. * @param withParents defines if parents must be serialized as well
  63845. * @param withChildren defines if children must be serialized as well
  63846. * @returns a JSON compatible object
  63847. */
  63848. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63849. }
  63850. }
  63851. declare module "babylonjs/Misc/textureTools" {
  63852. import { Texture } from "babylonjs/Materials/Textures/texture";
  63853. /**
  63854. * Class used to host texture specific utilities
  63855. */
  63856. export class TextureTools {
  63857. /**
  63858. * Uses the GPU to create a copy texture rescaled at a given size
  63859. * @param texture Texture to copy from
  63860. * @param width defines the desired width
  63861. * @param height defines the desired height
  63862. * @param useBilinearMode defines if bilinear mode has to be used
  63863. * @return the generated texture
  63864. */
  63865. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63866. }
  63867. }
  63868. declare module "babylonjs/Misc/videoRecorder" {
  63869. import { Nullable } from "babylonjs/types";
  63870. import { Engine } from "babylonjs/Engines/engine";
  63871. /**
  63872. * This represents the different options available for the video capture.
  63873. */
  63874. export interface VideoRecorderOptions {
  63875. /** Defines the mime type of the video. */
  63876. mimeType: string;
  63877. /** Defines the FPS the video should be recorded at. */
  63878. fps: number;
  63879. /** Defines the chunk size for the recording data. */
  63880. recordChunckSize: number;
  63881. /** The audio tracks to attach to the recording. */
  63882. audioTracks?: MediaStreamTrack[];
  63883. }
  63884. /**
  63885. * This can help with recording videos from BabylonJS.
  63886. * This is based on the available WebRTC functionalities of the browser.
  63887. *
  63888. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63889. */
  63890. export class VideoRecorder {
  63891. private static readonly _defaultOptions;
  63892. /**
  63893. * Returns whether or not the VideoRecorder is available in your browser.
  63894. * @param engine Defines the Babylon Engine.
  63895. * @returns true if supported otherwise false.
  63896. */
  63897. static IsSupported(engine: Engine): boolean;
  63898. private readonly _options;
  63899. private _canvas;
  63900. private _mediaRecorder;
  63901. private _recordedChunks;
  63902. private _fileName;
  63903. private _resolve;
  63904. private _reject;
  63905. /**
  63906. * True when a recording is already in progress.
  63907. */
  63908. readonly isRecording: boolean;
  63909. /**
  63910. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63911. * @param engine Defines the BabylonJS Engine you wish to record.
  63912. * @param options Defines options that can be used to customize the capture.
  63913. */
  63914. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63915. /**
  63916. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63917. */
  63918. stopRecording(): void;
  63919. /**
  63920. * Starts recording the canvas for a max duration specified in parameters.
  63921. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63922. * If null no automatic download will start and you can rely on the promise to get the data back.
  63923. * @param maxDuration Defines the maximum recording time in seconds.
  63924. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63925. * @return A promise callback at the end of the recording with the video data in Blob.
  63926. */
  63927. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63928. /**
  63929. * Releases internal resources used during the recording.
  63930. */
  63931. dispose(): void;
  63932. private _handleDataAvailable;
  63933. private _handleError;
  63934. private _handleStop;
  63935. }
  63936. }
  63937. declare module "babylonjs/Misc/screenshotTools" {
  63938. import { Camera } from "babylonjs/Cameras/camera";
  63939. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  63940. import { Engine } from "babylonjs/Engines/engine";
  63941. /**
  63942. * Class containing a set of static utilities functions for screenshots
  63943. */
  63944. export class ScreenshotTools {
  63945. /**
  63946. * Captures a screenshot of the current rendering
  63947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63948. * @param engine defines the rendering engine
  63949. * @param camera defines the source camera
  63950. * @param size This parameter can be set to a single number or to an object with the
  63951. * following (optional) properties: precision, width, height. If a single number is passed,
  63952. * it will be used for both width and height. If an object is passed, the screenshot size
  63953. * will be derived from the parameters. The precision property is a multiplier allowing
  63954. * rendering at a higher or lower resolution
  63955. * @param successCallback defines the callback receives a single parameter which contains the
  63956. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63957. * src parameter of an <img> to display it
  63958. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63959. * Check your browser for supported MIME types
  63960. */
  63961. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  63962. /**
  63963. * Captures a screenshot of the current rendering
  63964. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63965. * @param engine defines the rendering engine
  63966. * @param camera defines the source camera
  63967. * @param size This parameter can be set to a single number or to an object with the
  63968. * following (optional) properties: precision, width, height. If a single number is passed,
  63969. * it will be used for both width and height. If an object is passed, the screenshot size
  63970. * will be derived from the parameters. The precision property is a multiplier allowing
  63971. * rendering at a higher or lower resolution
  63972. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63973. * Check your browser for supported MIME types
  63974. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63975. * to the src parameter of an <img> to display it
  63976. */
  63977. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63978. /**
  63979. * Generates an image screenshot from the specified camera.
  63980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63981. * @param engine The engine to use for rendering
  63982. * @param camera The camera to use for rendering
  63983. * @param size This parameter can be set to a single number or to an object with the
  63984. * following (optional) properties: precision, width, height. If a single number is passed,
  63985. * it will be used for both width and height. If an object is passed, the screenshot size
  63986. * will be derived from the parameters. The precision property is a multiplier allowing
  63987. * rendering at a higher or lower resolution
  63988. * @param successCallback The callback receives a single parameter which contains the
  63989. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63990. * src parameter of an <img> to display it
  63991. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63992. * Check your browser for supported MIME types
  63993. * @param samples Texture samples (default: 1)
  63994. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63995. * @param fileName A name for for the downloaded file.
  63996. */
  63997. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63998. /**
  63999. * Generates an image screenshot from the specified camera.
  64000. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  64001. * @param engine The engine to use for rendering
  64002. * @param camera The camera to use for rendering
  64003. * @param size This parameter can be set to a single number or to an object with the
  64004. * following (optional) properties: precision, width, height. If a single number is passed,
  64005. * it will be used for both width and height. If an object is passed, the screenshot size
  64006. * will be derived from the parameters. The precision property is a multiplier allowing
  64007. * rendering at a higher or lower resolution
  64008. * @param mimeType The MIME type of the screenshot image (default: image/png).
  64009. * Check your browser for supported MIME types
  64010. * @param samples Texture samples (default: 1)
  64011. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  64012. * @param fileName A name for for the downloaded file.
  64013. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  64014. * to the src parameter of an <img> to display it
  64015. */
  64016. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  64017. /**
  64018. * Gets height and width for screenshot size
  64019. * @private
  64020. */
  64021. private static _getScreenshotSize;
  64022. }
  64023. }
  64024. declare module "babylonjs/Misc/index" {
  64025. export * from "babylonjs/Misc/andOrNotEvaluator";
  64026. export * from "babylonjs/Misc/assetsManager";
  64027. export * from "babylonjs/Misc/dds";
  64028. export * from "babylonjs/Misc/decorators";
  64029. export * from "babylonjs/Misc/deferred";
  64030. export * from "babylonjs/Misc/environmentTextureTools";
  64031. export * from "babylonjs/Misc/meshExploder";
  64032. export * from "babylonjs/Misc/filesInput";
  64033. export * from "babylonjs/Misc/HighDynamicRange/index";
  64034. export * from "babylonjs/Misc/khronosTextureContainer";
  64035. export * from "babylonjs/Misc/observable";
  64036. export * from "babylonjs/Misc/performanceMonitor";
  64037. export * from "babylonjs/Misc/promise";
  64038. export * from "babylonjs/Misc/sceneOptimizer";
  64039. export * from "babylonjs/Misc/sceneSerializer";
  64040. export * from "babylonjs/Misc/smartArray";
  64041. export * from "babylonjs/Misc/stringDictionary";
  64042. export * from "babylonjs/Misc/tags";
  64043. export * from "babylonjs/Misc/textureTools";
  64044. export * from "babylonjs/Misc/tga";
  64045. export * from "babylonjs/Misc/tools";
  64046. export * from "babylonjs/Misc/videoRecorder";
  64047. export * from "babylonjs/Misc/virtualJoystick";
  64048. export * from "babylonjs/Misc/workerPool";
  64049. export * from "babylonjs/Misc/logger";
  64050. export * from "babylonjs/Misc/typeStore";
  64051. export * from "babylonjs/Misc/filesInputStore";
  64052. export * from "babylonjs/Misc/deepCopier";
  64053. export * from "babylonjs/Misc/pivotTools";
  64054. export * from "babylonjs/Misc/precisionDate";
  64055. export * from "babylonjs/Misc/screenshotTools";
  64056. export * from "babylonjs/Misc/typeStore";
  64057. export * from "babylonjs/Misc/webRequest";
  64058. export * from "babylonjs/Misc/iInspectable";
  64059. export * from "babylonjs/Misc/brdfTextureTools";
  64060. export * from "babylonjs/Misc/gradients";
  64061. export * from "babylonjs/Misc/perfCounter";
  64062. export * from "babylonjs/Misc/fileRequest";
  64063. export * from "babylonjs/Misc/customAnimationFrameRequester";
  64064. export * from "babylonjs/Misc/retryStrategy";
  64065. export * from "babylonjs/Misc/loadFileError";
  64066. }
  64067. declare module "babylonjs/index" {
  64068. export * from "babylonjs/abstractScene";
  64069. export * from "babylonjs/Actions/index";
  64070. export * from "babylonjs/Animations/index";
  64071. export * from "babylonjs/assetContainer";
  64072. export * from "babylonjs/Audio/index";
  64073. export * from "babylonjs/Behaviors/index";
  64074. export * from "babylonjs/Bones/index";
  64075. export * from "babylonjs/Cameras/index";
  64076. export * from "babylonjs/Collisions/index";
  64077. export * from "babylonjs/Culling/index";
  64078. export * from "babylonjs/Debug/index";
  64079. export * from "babylonjs/Engines/index";
  64080. export * from "babylonjs/Events/index";
  64081. export * from "babylonjs/Gamepads/index";
  64082. export * from "babylonjs/Gizmos/index";
  64083. export * from "babylonjs/Helpers/index";
  64084. export * from "babylonjs/Instrumentation/index";
  64085. export * from "babylonjs/Layers/index";
  64086. export * from "babylonjs/LensFlares/index";
  64087. export * from "babylonjs/Lights/index";
  64088. export * from "babylonjs/Loading/index";
  64089. export * from "babylonjs/Materials/index";
  64090. export * from "babylonjs/Maths/index";
  64091. export * from "babylonjs/Meshes/index";
  64092. export * from "babylonjs/Morph/index";
  64093. export * from "babylonjs/Navigation/index";
  64094. export * from "babylonjs/node";
  64095. export * from "babylonjs/Offline/index";
  64096. export * from "babylonjs/Particles/index";
  64097. export * from "babylonjs/Physics/index";
  64098. export * from "babylonjs/PostProcesses/index";
  64099. export * from "babylonjs/Probes/index";
  64100. export * from "babylonjs/Rendering/index";
  64101. export * from "babylonjs/scene";
  64102. export * from "babylonjs/sceneComponent";
  64103. export * from "babylonjs/Sprites/index";
  64104. export * from "babylonjs/States/index";
  64105. export * from "babylonjs/Misc/index";
  64106. export * from "babylonjs/types";
  64107. }
  64108. declare module "babylonjs/Animations/pathCursor" {
  64109. import { Vector3 } from "babylonjs/Maths/math.vector";
  64110. import { Path2 } from "babylonjs/Maths/math.path";
  64111. /**
  64112. * A cursor which tracks a point on a path
  64113. */
  64114. export class PathCursor {
  64115. private path;
  64116. /**
  64117. * Stores path cursor callbacks for when an onchange event is triggered
  64118. */
  64119. private _onchange;
  64120. /**
  64121. * The value of the path cursor
  64122. */
  64123. value: number;
  64124. /**
  64125. * The animation array of the path cursor
  64126. */
  64127. animations: Animation[];
  64128. /**
  64129. * Initializes the path cursor
  64130. * @param path The path to track
  64131. */
  64132. constructor(path: Path2);
  64133. /**
  64134. * Gets the cursor point on the path
  64135. * @returns A point on the path cursor at the cursor location
  64136. */
  64137. getPoint(): Vector3;
  64138. /**
  64139. * Moves the cursor ahead by the step amount
  64140. * @param step The amount to move the cursor forward
  64141. * @returns This path cursor
  64142. */
  64143. moveAhead(step?: number): PathCursor;
  64144. /**
  64145. * Moves the cursor behind by the step amount
  64146. * @param step The amount to move the cursor back
  64147. * @returns This path cursor
  64148. */
  64149. moveBack(step?: number): PathCursor;
  64150. /**
  64151. * Moves the cursor by the step amount
  64152. * If the step amount is greater than one, an exception is thrown
  64153. * @param step The amount to move the cursor
  64154. * @returns This path cursor
  64155. */
  64156. move(step: number): PathCursor;
  64157. /**
  64158. * Ensures that the value is limited between zero and one
  64159. * @returns This path cursor
  64160. */
  64161. private ensureLimits;
  64162. /**
  64163. * Runs onchange callbacks on change (used by the animation engine)
  64164. * @returns This path cursor
  64165. */
  64166. private raiseOnChange;
  64167. /**
  64168. * Executes a function on change
  64169. * @param f A path cursor onchange callback
  64170. * @returns This path cursor
  64171. */
  64172. onchange(f: (cursor: PathCursor) => void): PathCursor;
  64173. }
  64174. }
  64175. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  64176. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  64177. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  64178. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  64179. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  64180. }
  64181. declare module "babylonjs/Engines/Processors/Expressions/index" {
  64182. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  64183. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  64184. }
  64185. declare module "babylonjs/Engines/Processors/index" {
  64186. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  64187. export * from "babylonjs/Engines/Processors/Expressions/index";
  64188. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  64189. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  64190. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  64191. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  64192. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  64193. export * from "babylonjs/Engines/Processors/shaderProcessor";
  64194. }
  64195. declare module "babylonjs/Legacy/legacy" {
  64196. import * as Babylon from "babylonjs/index";
  64197. export * from "babylonjs/index";
  64198. }
  64199. declare module "babylonjs/Shaders/blur.fragment" {
  64200. /** @hidden */
  64201. export var blurPixelShader: {
  64202. name: string;
  64203. shader: string;
  64204. };
  64205. }
  64206. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  64207. /** @hidden */
  64208. export var pointCloudVertexDeclaration: {
  64209. name: string;
  64210. shader: string;
  64211. };
  64212. }
  64213. declare module "babylonjs" {
  64214. export * from "babylonjs/Legacy/legacy";
  64215. }
  64216. declare module BABYLON {
  64217. /** Alias type for value that can be null */
  64218. export type Nullable<T> = T | null;
  64219. /**
  64220. * Alias type for number that are floats
  64221. * @ignorenaming
  64222. */
  64223. export type float = number;
  64224. /**
  64225. * Alias type for number that are doubles.
  64226. * @ignorenaming
  64227. */
  64228. export type double = number;
  64229. /**
  64230. * Alias type for number that are integer
  64231. * @ignorenaming
  64232. */
  64233. export type int = number;
  64234. /** Alias type for number array or Float32Array */
  64235. export type FloatArray = number[] | Float32Array;
  64236. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  64237. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  64238. /**
  64239. * Alias for types that can be used by a Buffer or VertexBuffer.
  64240. */
  64241. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  64242. /**
  64243. * Alias type for primitive types
  64244. * @ignorenaming
  64245. */
  64246. type Primitive = undefined | null | boolean | string | number | Function;
  64247. /**
  64248. * Type modifier to make all the properties of an object Readonly
  64249. */
  64250. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  64251. /**
  64252. * Type modifier to make all the properties of an object Readonly recursively
  64253. */
  64254. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  64255. /** @hidden */
  64256. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  64257. }
  64258. /** @hidden */
  64259. /** @hidden */
  64260. type DeepImmutableObject<T> = {
  64261. readonly [K in keyof T]: DeepImmutable<T[K]>;
  64262. };
  64263. }
  64264. declare module BABYLON {
  64265. /**
  64266. * A class serves as a medium between the observable and its observers
  64267. */
  64268. export class EventState {
  64269. /**
  64270. * Create a new EventState
  64271. * @param mask defines the mask associated with this state
  64272. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64273. * @param target defines the original target of the state
  64274. * @param currentTarget defines the current target of the state
  64275. */
  64276. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64277. /**
  64278. * Initialize the current event state
  64279. * @param mask defines the mask associated with this state
  64280. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  64281. * @param target defines the original target of the state
  64282. * @param currentTarget defines the current target of the state
  64283. * @returns the current event state
  64284. */
  64285. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  64286. /**
  64287. * An Observer can set this property to true to prevent subsequent observers of being notified
  64288. */
  64289. skipNextObservers: boolean;
  64290. /**
  64291. * Get the mask value that were used to trigger the event corresponding to this EventState object
  64292. */
  64293. mask: number;
  64294. /**
  64295. * The object that originally notified the event
  64296. */
  64297. target?: any;
  64298. /**
  64299. * The current object in the bubbling phase
  64300. */
  64301. currentTarget?: any;
  64302. /**
  64303. * This will be populated with the return value of the last function that was executed.
  64304. * If it is the first function in the callback chain it will be the event data.
  64305. */
  64306. lastReturnValue?: any;
  64307. }
  64308. /**
  64309. * Represent an Observer registered to a given Observable object.
  64310. */
  64311. export class Observer<T> {
  64312. /**
  64313. * Defines the callback to call when the observer is notified
  64314. */
  64315. callback: (eventData: T, eventState: EventState) => void;
  64316. /**
  64317. * Defines the mask of the observer (used to filter notifications)
  64318. */
  64319. mask: number;
  64320. /**
  64321. * Defines the current scope used to restore the JS context
  64322. */
  64323. scope: any;
  64324. /** @hidden */
  64325. _willBeUnregistered: boolean;
  64326. /**
  64327. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64328. */
  64329. unregisterOnNextCall: boolean;
  64330. /**
  64331. * Creates a new observer
  64332. * @param callback defines the callback to call when the observer is notified
  64333. * @param mask defines the mask of the observer (used to filter notifications)
  64334. * @param scope defines the current scope used to restore the JS context
  64335. */
  64336. constructor(
  64337. /**
  64338. * Defines the callback to call when the observer is notified
  64339. */
  64340. callback: (eventData: T, eventState: EventState) => void,
  64341. /**
  64342. * Defines the mask of the observer (used to filter notifications)
  64343. */
  64344. mask: number,
  64345. /**
  64346. * Defines the current scope used to restore the JS context
  64347. */
  64348. scope?: any);
  64349. }
  64350. /**
  64351. * Represent a list of observers registered to multiple Observables object.
  64352. */
  64353. export class MultiObserver<T> {
  64354. private _observers;
  64355. private _observables;
  64356. /**
  64357. * Release associated resources
  64358. */
  64359. dispose(): void;
  64360. /**
  64361. * Raise a callback when one of the observable will notify
  64362. * @param observables defines a list of observables to watch
  64363. * @param callback defines the callback to call on notification
  64364. * @param mask defines the mask used to filter notifications
  64365. * @param scope defines the current scope used to restore the JS context
  64366. * @returns the new MultiObserver
  64367. */
  64368. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64369. }
  64370. /**
  64371. * The Observable class is a simple implementation of the Observable pattern.
  64372. *
  64373. * 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.
  64374. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64375. * 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).
  64376. * 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.
  64377. */
  64378. export class Observable<T> {
  64379. private _observers;
  64380. private _eventState;
  64381. private _onObserverAdded;
  64382. /**
  64383. * Gets the list of observers
  64384. */
  64385. readonly observers: Array<Observer<T>>;
  64386. /**
  64387. * Creates a new observable
  64388. * @param onObserverAdded defines a callback to call when a new observer is added
  64389. */
  64390. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64391. /**
  64392. * Create a new Observer with the specified callback
  64393. * @param callback the callback that will be executed for that Observer
  64394. * @param mask the mask used to filter observers
  64395. * @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.
  64396. * @param scope optional scope for the callback to be called from
  64397. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64398. * @returns the new observer created for the callback
  64399. */
  64400. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64401. /**
  64402. * Create a new Observer with the specified callback and unregisters after the next notification
  64403. * @param callback the callback that will be executed for that Observer
  64404. * @returns the new observer created for the callback
  64405. */
  64406. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64407. /**
  64408. * Remove an Observer from the Observable object
  64409. * @param observer the instance of the Observer to remove
  64410. * @returns false if it doesn't belong to this Observable
  64411. */
  64412. remove(observer: Nullable<Observer<T>>): boolean;
  64413. /**
  64414. * Remove a callback from the Observable object
  64415. * @param callback the callback to remove
  64416. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64417. * @returns false if it doesn't belong to this Observable
  64418. */
  64419. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64420. private _deferUnregister;
  64421. private _remove;
  64422. /**
  64423. * Moves the observable to the top of the observer list making it get called first when notified
  64424. * @param observer the observer to move
  64425. */
  64426. makeObserverTopPriority(observer: Observer<T>): void;
  64427. /**
  64428. * Moves the observable to the bottom of the observer list making it get called last when notified
  64429. * @param observer the observer to move
  64430. */
  64431. makeObserverBottomPriority(observer: Observer<T>): void;
  64432. /**
  64433. * Notify all Observers by calling their respective callback with the given data
  64434. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64435. * @param eventData defines the data to send to all observers
  64436. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64437. * @param target defines the original target of the state
  64438. * @param currentTarget defines the current target of the state
  64439. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64440. */
  64441. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64442. /**
  64443. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64444. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64445. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64446. * and it is crucial that all callbacks will be executed.
  64447. * The order of the callbacks is kept, callbacks are not executed parallel.
  64448. *
  64449. * @param eventData The data to be sent to each callback
  64450. * @param mask is used to filter observers defaults to -1
  64451. * @param target defines the callback target (see EventState)
  64452. * @param currentTarget defines he current object in the bubbling phase
  64453. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64454. */
  64455. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64456. /**
  64457. * Notify a specific observer
  64458. * @param observer defines the observer to notify
  64459. * @param eventData defines the data to be sent to each callback
  64460. * @param mask is used to filter observers defaults to -1
  64461. */
  64462. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64463. /**
  64464. * Gets a boolean indicating if the observable has at least one observer
  64465. * @returns true is the Observable has at least one Observer registered
  64466. */
  64467. hasObservers(): boolean;
  64468. /**
  64469. * Clear the list of observers
  64470. */
  64471. clear(): void;
  64472. /**
  64473. * Clone the current observable
  64474. * @returns a new observable
  64475. */
  64476. clone(): Observable<T>;
  64477. /**
  64478. * Does this observable handles observer registered with a given mask
  64479. * @param mask defines the mask to be tested
  64480. * @return whether or not one observer registered with the given mask is handeled
  64481. **/
  64482. hasSpecificMask(mask?: number): boolean;
  64483. }
  64484. }
  64485. declare module BABYLON {
  64486. /**
  64487. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64488. * Babylon.js
  64489. */
  64490. export class DomManagement {
  64491. /**
  64492. * Checks if the window object exists
  64493. * @returns true if the window object exists
  64494. */
  64495. static IsWindowObjectExist(): boolean;
  64496. /**
  64497. * Extracts text content from a DOM element hierarchy
  64498. * @param element defines the root element
  64499. * @returns a string
  64500. */
  64501. static GetDOMTextContent(element: HTMLElement): string;
  64502. }
  64503. }
  64504. declare module BABYLON {
  64505. /**
  64506. * Logger used througouht the application to allow configuration of
  64507. * the log level required for the messages.
  64508. */
  64509. export class Logger {
  64510. /**
  64511. * No log
  64512. */
  64513. static readonly NoneLogLevel: number;
  64514. /**
  64515. * Only message logs
  64516. */
  64517. static readonly MessageLogLevel: number;
  64518. /**
  64519. * Only warning logs
  64520. */
  64521. static readonly WarningLogLevel: number;
  64522. /**
  64523. * Only error logs
  64524. */
  64525. static readonly ErrorLogLevel: number;
  64526. /**
  64527. * All logs
  64528. */
  64529. static readonly AllLogLevel: number;
  64530. private static _LogCache;
  64531. /**
  64532. * Gets a value indicating the number of loading errors
  64533. * @ignorenaming
  64534. */
  64535. static errorsCount: number;
  64536. /**
  64537. * Callback called when a new log is added
  64538. */
  64539. static OnNewCacheEntry: (entry: string) => void;
  64540. private static _AddLogEntry;
  64541. private static _FormatMessage;
  64542. private static _LogDisabled;
  64543. private static _LogEnabled;
  64544. private static _WarnDisabled;
  64545. private static _WarnEnabled;
  64546. private static _ErrorDisabled;
  64547. private static _ErrorEnabled;
  64548. /**
  64549. * Log a message to the console
  64550. */
  64551. static Log: (message: string) => void;
  64552. /**
  64553. * Write a warning message to the console
  64554. */
  64555. static Warn: (message: string) => void;
  64556. /**
  64557. * Write an error message to the console
  64558. */
  64559. static Error: (message: string) => void;
  64560. /**
  64561. * Gets current log cache (list of logs)
  64562. */
  64563. static readonly LogCache: string;
  64564. /**
  64565. * Clears the log cache
  64566. */
  64567. static ClearLogCache(): void;
  64568. /**
  64569. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64570. */
  64571. static LogLevels: number;
  64572. }
  64573. }
  64574. declare module BABYLON {
  64575. /** @hidden */
  64576. export class _TypeStore {
  64577. /** @hidden */
  64578. static RegisteredTypes: {
  64579. [key: string]: Object;
  64580. };
  64581. /** @hidden */
  64582. static GetClass(fqdn: string): any;
  64583. }
  64584. }
  64585. declare module BABYLON {
  64586. /**
  64587. * Class containing a set of static utilities functions for deep copy.
  64588. */
  64589. export class DeepCopier {
  64590. /**
  64591. * Tries to copy an object by duplicating every property
  64592. * @param source defines the source object
  64593. * @param destination defines the target object
  64594. * @param doNotCopyList defines a list of properties to avoid
  64595. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64596. */
  64597. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64598. }
  64599. }
  64600. declare module BABYLON {
  64601. /**
  64602. * Class containing a set of static utilities functions for precision date
  64603. */
  64604. export class PrecisionDate {
  64605. /**
  64606. * Gets either window.performance.now() if supported or Date.now() else
  64607. */
  64608. static readonly Now: number;
  64609. }
  64610. }
  64611. declare module BABYLON {
  64612. /** @hidden */
  64613. export class _DevTools {
  64614. static WarnImport(name: string): string;
  64615. }
  64616. }
  64617. declare module BABYLON {
  64618. /**
  64619. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64620. */
  64621. export class WebRequest {
  64622. private _xhr;
  64623. /**
  64624. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64625. * i.e. when loading files, where the server/service expects an Authorization header
  64626. */
  64627. static CustomRequestHeaders: {
  64628. [key: string]: string;
  64629. };
  64630. /**
  64631. * Add callback functions in this array to update all the requests before they get sent to the network
  64632. */
  64633. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64634. private _injectCustomRequestHeaders;
  64635. /**
  64636. * Gets or sets a function to be called when loading progress changes
  64637. */
  64638. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64639. /**
  64640. * Returns client's state
  64641. */
  64642. readonly readyState: number;
  64643. /**
  64644. * Returns client's status
  64645. */
  64646. readonly status: number;
  64647. /**
  64648. * Returns client's status as a text
  64649. */
  64650. readonly statusText: string;
  64651. /**
  64652. * Returns client's response
  64653. */
  64654. readonly response: any;
  64655. /**
  64656. * Returns client's response url
  64657. */
  64658. readonly responseURL: string;
  64659. /**
  64660. * Returns client's response as text
  64661. */
  64662. readonly responseText: string;
  64663. /**
  64664. * Gets or sets the expected response type
  64665. */
  64666. responseType: XMLHttpRequestResponseType;
  64667. /** @hidden */
  64668. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64669. /** @hidden */
  64670. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64671. /**
  64672. * Cancels any network activity
  64673. */
  64674. abort(): void;
  64675. /**
  64676. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64677. * @param body defines an optional request body
  64678. */
  64679. send(body?: Document | BodyInit | null): void;
  64680. /**
  64681. * Sets the request method, request URL
  64682. * @param method defines the method to use (GET, POST, etc..)
  64683. * @param url defines the url to connect with
  64684. */
  64685. open(method: string, url: string): void;
  64686. }
  64687. }
  64688. declare module BABYLON {
  64689. /**
  64690. * File request interface
  64691. */
  64692. export interface IFileRequest {
  64693. /**
  64694. * Raised when the request is complete (success or error).
  64695. */
  64696. onCompleteObservable: Observable<IFileRequest>;
  64697. /**
  64698. * Aborts the request for a file.
  64699. */
  64700. abort: () => void;
  64701. }
  64702. }
  64703. declare module BABYLON {
  64704. /**
  64705. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64706. */
  64707. export class PerformanceMonitor {
  64708. private _enabled;
  64709. private _rollingFrameTime;
  64710. private _lastFrameTimeMs;
  64711. /**
  64712. * constructor
  64713. * @param frameSampleSize The number of samples required to saturate the sliding window
  64714. */
  64715. constructor(frameSampleSize?: number);
  64716. /**
  64717. * Samples current frame
  64718. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64719. */
  64720. sampleFrame(timeMs?: number): void;
  64721. /**
  64722. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64723. */
  64724. readonly averageFrameTime: number;
  64725. /**
  64726. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64727. */
  64728. readonly averageFrameTimeVariance: number;
  64729. /**
  64730. * Returns the frame time of the most recent frame
  64731. */
  64732. readonly instantaneousFrameTime: number;
  64733. /**
  64734. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64735. */
  64736. readonly averageFPS: number;
  64737. /**
  64738. * Returns the average framerate in frames per second using the most recent frame time
  64739. */
  64740. readonly instantaneousFPS: number;
  64741. /**
  64742. * Returns true if enough samples have been taken to completely fill the sliding window
  64743. */
  64744. readonly isSaturated: boolean;
  64745. /**
  64746. * Enables contributions to the sliding window sample set
  64747. */
  64748. enable(): void;
  64749. /**
  64750. * Disables contributions to the sliding window sample set
  64751. * Samples will not be interpolated over the disabled period
  64752. */
  64753. disable(): void;
  64754. /**
  64755. * Returns true if sampling is enabled
  64756. */
  64757. readonly isEnabled: boolean;
  64758. /**
  64759. * Resets performance monitor
  64760. */
  64761. reset(): void;
  64762. }
  64763. /**
  64764. * RollingAverage
  64765. *
  64766. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64767. */
  64768. export class RollingAverage {
  64769. /**
  64770. * Current average
  64771. */
  64772. average: number;
  64773. /**
  64774. * Current variance
  64775. */
  64776. variance: number;
  64777. protected _samples: Array<number>;
  64778. protected _sampleCount: number;
  64779. protected _pos: number;
  64780. protected _m2: number;
  64781. /**
  64782. * constructor
  64783. * @param length The number of samples required to saturate the sliding window
  64784. */
  64785. constructor(length: number);
  64786. /**
  64787. * Adds a sample to the sample set
  64788. * @param v The sample value
  64789. */
  64790. add(v: number): void;
  64791. /**
  64792. * Returns previously added values or null if outside of history or outside the sliding window domain
  64793. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64794. * @return Value previously recorded with add() or null if outside of range
  64795. */
  64796. history(i: number): number;
  64797. /**
  64798. * Returns true if enough samples have been taken to completely fill the sliding window
  64799. * @return true if sample-set saturated
  64800. */
  64801. isSaturated(): boolean;
  64802. /**
  64803. * Resets the rolling average (equivalent to 0 samples taken so far)
  64804. */
  64805. reset(): void;
  64806. /**
  64807. * Wraps a value around the sample range boundaries
  64808. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64809. * @return Wrapped position in sample range
  64810. */
  64811. protected _wrapPosition(i: number): number;
  64812. }
  64813. }
  64814. declare module BABYLON {
  64815. /**
  64816. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64817. * The underlying implementation relies on an associative array to ensure the best performances.
  64818. * The value can be anything including 'null' but except 'undefined'
  64819. */
  64820. export class StringDictionary<T> {
  64821. /**
  64822. * This will clear this dictionary and copy the content from the 'source' one.
  64823. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64824. * @param source the dictionary to take the content from and copy to this dictionary
  64825. */
  64826. copyFrom(source: StringDictionary<T>): void;
  64827. /**
  64828. * Get a value based from its key
  64829. * @param key the given key to get the matching value from
  64830. * @return the value if found, otherwise undefined is returned
  64831. */
  64832. get(key: string): T | undefined;
  64833. /**
  64834. * Get a value from its key or add it if it doesn't exist.
  64835. * This method will ensure you that a given key/data will be present in the dictionary.
  64836. * @param key the given key to get the matching value from
  64837. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64838. * The factory will only be invoked if there's no data for the given key.
  64839. * @return the value corresponding to the key.
  64840. */
  64841. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64842. /**
  64843. * Get a value from its key if present in the dictionary otherwise add it
  64844. * @param key the key to get the value from
  64845. * @param val if there's no such key/value pair in the dictionary add it with this value
  64846. * @return the value corresponding to the key
  64847. */
  64848. getOrAdd(key: string, val: T): T;
  64849. /**
  64850. * Check if there's a given key in the dictionary
  64851. * @param key the key to check for
  64852. * @return true if the key is present, false otherwise
  64853. */
  64854. contains(key: string): boolean;
  64855. /**
  64856. * Add a new key and its corresponding value
  64857. * @param key the key to add
  64858. * @param value the value corresponding to the key
  64859. * @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
  64860. */
  64861. add(key: string, value: T): boolean;
  64862. /**
  64863. * Update a specific value associated to a key
  64864. * @param key defines the key to use
  64865. * @param value defines the value to store
  64866. * @returns true if the value was updated (or false if the key was not found)
  64867. */
  64868. set(key: string, value: T): boolean;
  64869. /**
  64870. * Get the element of the given key and remove it from the dictionary
  64871. * @param key defines the key to search
  64872. * @returns the value associated with the key or null if not found
  64873. */
  64874. getAndRemove(key: string): Nullable<T>;
  64875. /**
  64876. * Remove a key/value from the dictionary.
  64877. * @param key the key to remove
  64878. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64879. */
  64880. remove(key: string): boolean;
  64881. /**
  64882. * Clear the whole content of the dictionary
  64883. */
  64884. clear(): void;
  64885. /**
  64886. * Gets the current count
  64887. */
  64888. readonly count: number;
  64889. /**
  64890. * Execute a callback on each key/val of the dictionary.
  64891. * Note that you can remove any element in this dictionary in the callback implementation
  64892. * @param callback the callback to execute on a given key/value pair
  64893. */
  64894. forEach(callback: (key: string, val: T) => void): void;
  64895. /**
  64896. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64897. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64898. * Note that you can remove any element in this dictionary in the callback implementation
  64899. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64900. * @returns the first item
  64901. */
  64902. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64903. private _count;
  64904. private _data;
  64905. }
  64906. }
  64907. declare module BABYLON {
  64908. /**
  64909. * Class used to store gfx data (like WebGLBuffer)
  64910. */
  64911. export class DataBuffer {
  64912. /**
  64913. * Gets or sets the number of objects referencing this buffer
  64914. */
  64915. references: number;
  64916. /** Gets or sets the size of the underlying buffer */
  64917. capacity: number;
  64918. /**
  64919. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64920. */
  64921. is32Bits: boolean;
  64922. /**
  64923. * Gets the underlying buffer
  64924. */
  64925. readonly underlyingResource: any;
  64926. }
  64927. }
  64928. declare module BABYLON {
  64929. /**
  64930. * Class used to store data that will be store in GPU memory
  64931. */
  64932. export class Buffer {
  64933. private _engine;
  64934. private _buffer;
  64935. /** @hidden */
  64936. _data: Nullable<DataArray>;
  64937. private _updatable;
  64938. private _instanced;
  64939. /**
  64940. * Gets the byte stride.
  64941. */
  64942. readonly byteStride: number;
  64943. /**
  64944. * Constructor
  64945. * @param engine the engine
  64946. * @param data the data to use for this buffer
  64947. * @param updatable whether the data is updatable
  64948. * @param stride the stride (optional)
  64949. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64950. * @param instanced whether the buffer is instanced (optional)
  64951. * @param useBytes set to true if the stride in in bytes (optional)
  64952. */
  64953. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64954. /**
  64955. * Create a new VertexBuffer based on the current buffer
  64956. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64957. * @param offset defines offset in the buffer (0 by default)
  64958. * @param size defines the size in floats of attributes (position is 3 for instance)
  64959. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64960. * @param instanced defines if the vertex buffer contains indexed data
  64961. * @param useBytes defines if the offset and stride are in bytes
  64962. * @returns the new vertex buffer
  64963. */
  64964. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64965. /**
  64966. * Gets a boolean indicating if the Buffer is updatable?
  64967. * @returns true if the buffer is updatable
  64968. */
  64969. isUpdatable(): boolean;
  64970. /**
  64971. * Gets current buffer's data
  64972. * @returns a DataArray or null
  64973. */
  64974. getData(): Nullable<DataArray>;
  64975. /**
  64976. * Gets underlying native buffer
  64977. * @returns underlying native buffer
  64978. */
  64979. getBuffer(): Nullable<DataBuffer>;
  64980. /**
  64981. * Gets the stride in float32 units (i.e. byte stride / 4).
  64982. * May not be an integer if the byte stride is not divisible by 4.
  64983. * DEPRECATED. Use byteStride instead.
  64984. * @returns the stride in float32 units
  64985. */
  64986. getStrideSize(): number;
  64987. /**
  64988. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64989. * @param data defines the data to store
  64990. */
  64991. create(data?: Nullable<DataArray>): void;
  64992. /** @hidden */
  64993. _rebuild(): void;
  64994. /**
  64995. * Update current buffer data
  64996. * @param data defines the data to store
  64997. */
  64998. update(data: DataArray): void;
  64999. /**
  65000. * Updates the data directly.
  65001. * @param data the new data
  65002. * @param offset the new offset
  65003. * @param vertexCount the vertex count (optional)
  65004. * @param useBytes set to true if the offset is in bytes
  65005. */
  65006. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65007. /**
  65008. * Release all resources
  65009. */
  65010. dispose(): void;
  65011. }
  65012. /**
  65013. * Specialized buffer used to store vertex data
  65014. */
  65015. export class VertexBuffer {
  65016. /** @hidden */
  65017. _buffer: Buffer;
  65018. private _kind;
  65019. private _size;
  65020. private _ownsBuffer;
  65021. private _instanced;
  65022. private _instanceDivisor;
  65023. /**
  65024. * The byte type.
  65025. */
  65026. static readonly BYTE: number;
  65027. /**
  65028. * The unsigned byte type.
  65029. */
  65030. static readonly UNSIGNED_BYTE: number;
  65031. /**
  65032. * The short type.
  65033. */
  65034. static readonly SHORT: number;
  65035. /**
  65036. * The unsigned short type.
  65037. */
  65038. static readonly UNSIGNED_SHORT: number;
  65039. /**
  65040. * The integer type.
  65041. */
  65042. static readonly INT: number;
  65043. /**
  65044. * The unsigned integer type.
  65045. */
  65046. static readonly UNSIGNED_INT: number;
  65047. /**
  65048. * The float type.
  65049. */
  65050. static readonly FLOAT: number;
  65051. /**
  65052. * Gets or sets the instance divisor when in instanced mode
  65053. */
  65054. instanceDivisor: number;
  65055. /**
  65056. * Gets the byte stride.
  65057. */
  65058. readonly byteStride: number;
  65059. /**
  65060. * Gets the byte offset.
  65061. */
  65062. readonly byteOffset: number;
  65063. /**
  65064. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65065. */
  65066. readonly normalized: boolean;
  65067. /**
  65068. * Gets the data type of each component in the array.
  65069. */
  65070. readonly type: number;
  65071. /**
  65072. * Constructor
  65073. * @param engine the engine
  65074. * @param data the data to use for this vertex buffer
  65075. * @param kind the vertex buffer kind
  65076. * @param updatable whether the data is updatable
  65077. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65078. * @param stride the stride (optional)
  65079. * @param instanced whether the buffer is instanced (optional)
  65080. * @param offset the offset of the data (optional)
  65081. * @param size the number of components (optional)
  65082. * @param type the type of the component (optional)
  65083. * @param normalized whether the data contains normalized data (optional)
  65084. * @param useBytes set to true if stride and offset are in bytes (optional)
  65085. */
  65086. 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);
  65087. /** @hidden */
  65088. _rebuild(): void;
  65089. /**
  65090. * Returns the kind of the VertexBuffer (string)
  65091. * @returns a string
  65092. */
  65093. getKind(): string;
  65094. /**
  65095. * Gets a boolean indicating if the VertexBuffer is updatable?
  65096. * @returns true if the buffer is updatable
  65097. */
  65098. isUpdatable(): boolean;
  65099. /**
  65100. * Gets current buffer's data
  65101. * @returns a DataArray or null
  65102. */
  65103. getData(): Nullable<DataArray>;
  65104. /**
  65105. * Gets underlying native buffer
  65106. * @returns underlying native buffer
  65107. */
  65108. getBuffer(): Nullable<DataBuffer>;
  65109. /**
  65110. * Gets the stride in float32 units (i.e. byte stride / 4).
  65111. * May not be an integer if the byte stride is not divisible by 4.
  65112. * DEPRECATED. Use byteStride instead.
  65113. * @returns the stride in float32 units
  65114. */
  65115. getStrideSize(): number;
  65116. /**
  65117. * Returns the offset as a multiple of the type byte length.
  65118. * DEPRECATED. Use byteOffset instead.
  65119. * @returns the offset in bytes
  65120. */
  65121. getOffset(): number;
  65122. /**
  65123. * Returns the number of components per vertex attribute (integer)
  65124. * @returns the size in float
  65125. */
  65126. getSize(): number;
  65127. /**
  65128. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65129. * @returns true if this buffer is instanced
  65130. */
  65131. getIsInstanced(): boolean;
  65132. /**
  65133. * Returns the instancing divisor, zero for non-instanced (integer).
  65134. * @returns a number
  65135. */
  65136. getInstanceDivisor(): number;
  65137. /**
  65138. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65139. * @param data defines the data to store
  65140. */
  65141. create(data?: DataArray): void;
  65142. /**
  65143. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65144. * This function will create a new buffer if the current one is not updatable
  65145. * @param data defines the data to store
  65146. */
  65147. update(data: DataArray): void;
  65148. /**
  65149. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65150. * Returns the directly updated WebGLBuffer.
  65151. * @param data the new data
  65152. * @param offset the new offset
  65153. * @param useBytes set to true if the offset is in bytes
  65154. */
  65155. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65156. /**
  65157. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65158. */
  65159. dispose(): void;
  65160. /**
  65161. * Enumerates each value of this vertex buffer as numbers.
  65162. * @param count the number of values to enumerate
  65163. * @param callback the callback function called for each value
  65164. */
  65165. forEach(count: number, callback: (value: number, index: number) => void): void;
  65166. /**
  65167. * Positions
  65168. */
  65169. static readonly PositionKind: string;
  65170. /**
  65171. * Normals
  65172. */
  65173. static readonly NormalKind: string;
  65174. /**
  65175. * Tangents
  65176. */
  65177. static readonly TangentKind: string;
  65178. /**
  65179. * Texture coordinates
  65180. */
  65181. static readonly UVKind: string;
  65182. /**
  65183. * Texture coordinates 2
  65184. */
  65185. static readonly UV2Kind: string;
  65186. /**
  65187. * Texture coordinates 3
  65188. */
  65189. static readonly UV3Kind: string;
  65190. /**
  65191. * Texture coordinates 4
  65192. */
  65193. static readonly UV4Kind: string;
  65194. /**
  65195. * Texture coordinates 5
  65196. */
  65197. static readonly UV5Kind: string;
  65198. /**
  65199. * Texture coordinates 6
  65200. */
  65201. static readonly UV6Kind: string;
  65202. /**
  65203. * Colors
  65204. */
  65205. static readonly ColorKind: string;
  65206. /**
  65207. * Matrix indices (for bones)
  65208. */
  65209. static readonly MatricesIndicesKind: string;
  65210. /**
  65211. * Matrix weights (for bones)
  65212. */
  65213. static readonly MatricesWeightsKind: string;
  65214. /**
  65215. * Additional matrix indices (for bones)
  65216. */
  65217. static readonly MatricesIndicesExtraKind: string;
  65218. /**
  65219. * Additional matrix weights (for bones)
  65220. */
  65221. static readonly MatricesWeightsExtraKind: string;
  65222. /**
  65223. * Deduces the stride given a kind.
  65224. * @param kind The kind string to deduce
  65225. * @returns The deduced stride
  65226. */
  65227. static DeduceStride(kind: string): number;
  65228. /**
  65229. * Gets the byte length of the given type.
  65230. * @param type the type
  65231. * @returns the number of bytes
  65232. */
  65233. static GetTypeByteLength(type: number): number;
  65234. /**
  65235. * Enumerates each value of the given parameters as numbers.
  65236. * @param data the data to enumerate
  65237. * @param byteOffset the byte offset of the data
  65238. * @param byteStride the byte stride of the data
  65239. * @param componentCount the number of components per element
  65240. * @param componentType the type of the component
  65241. * @param count the number of values to enumerate
  65242. * @param normalized whether the data is normalized
  65243. * @param callback the callback function called for each value
  65244. */
  65245. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65246. private static _GetFloatValue;
  65247. }
  65248. }
  65249. declare module BABYLON {
  65250. /**
  65251. * Scalar computation library
  65252. */
  65253. export class Scalar {
  65254. /**
  65255. * Two pi constants convenient for computation.
  65256. */
  65257. static TwoPi: number;
  65258. /**
  65259. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65260. * @param a number
  65261. * @param b number
  65262. * @param epsilon (default = 1.401298E-45)
  65263. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  65264. */
  65265. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  65266. /**
  65267. * Returns a string : the upper case translation of the number i to hexadecimal.
  65268. * @param i number
  65269. * @returns the upper case translation of the number i to hexadecimal.
  65270. */
  65271. static ToHex(i: number): string;
  65272. /**
  65273. * Returns -1 if value is negative and +1 is value is positive.
  65274. * @param value the value
  65275. * @returns the value itself if it's equal to zero.
  65276. */
  65277. static Sign(value: number): number;
  65278. /**
  65279. * Returns the value itself if it's between min and max.
  65280. * Returns min if the value is lower than min.
  65281. * Returns max if the value is greater than max.
  65282. * @param value the value to clmap
  65283. * @param min the min value to clamp to (default: 0)
  65284. * @param max the max value to clamp to (default: 1)
  65285. * @returns the clamped value
  65286. */
  65287. static Clamp(value: number, min?: number, max?: number): number;
  65288. /**
  65289. * the log2 of value.
  65290. * @param value the value to compute log2 of
  65291. * @returns the log2 of value.
  65292. */
  65293. static Log2(value: number): number;
  65294. /**
  65295. * Loops the value, so that it is never larger than length and never smaller than 0.
  65296. *
  65297. * This is similar to the modulo operator but it works with floating point numbers.
  65298. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  65299. * With t = 5 and length = 2.5, the result would be 0.0.
  65300. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  65301. * @param value the value
  65302. * @param length the length
  65303. * @returns the looped value
  65304. */
  65305. static Repeat(value: number, length: number): number;
  65306. /**
  65307. * Normalize the value between 0.0 and 1.0 using min and max values
  65308. * @param value value to normalize
  65309. * @param min max to normalize between
  65310. * @param max min to normalize between
  65311. * @returns the normalized value
  65312. */
  65313. static Normalize(value: number, min: number, max: number): number;
  65314. /**
  65315. * Denormalize the value from 0.0 and 1.0 using min and max values
  65316. * @param normalized value to denormalize
  65317. * @param min max to denormalize between
  65318. * @param max min to denormalize between
  65319. * @returns the denormalized value
  65320. */
  65321. static Denormalize(normalized: number, min: number, max: number): number;
  65322. /**
  65323. * Calculates the shortest difference between two given angles given in degrees.
  65324. * @param current current angle in degrees
  65325. * @param target target angle in degrees
  65326. * @returns the delta
  65327. */
  65328. static DeltaAngle(current: number, target: number): number;
  65329. /**
  65330. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65331. * @param tx value
  65332. * @param length length
  65333. * @returns The returned value will move back and forth between 0 and length
  65334. */
  65335. static PingPong(tx: number, length: number): number;
  65336. /**
  65337. * Interpolates between min and max with smoothing at the limits.
  65338. *
  65339. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65340. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65341. * @param from from
  65342. * @param to to
  65343. * @param tx value
  65344. * @returns the smooth stepped value
  65345. */
  65346. static SmoothStep(from: number, to: number, tx: number): number;
  65347. /**
  65348. * Moves a value current towards target.
  65349. *
  65350. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65351. * Negative values of maxDelta pushes the value away from target.
  65352. * @param current current value
  65353. * @param target target value
  65354. * @param maxDelta max distance to move
  65355. * @returns resulting value
  65356. */
  65357. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65358. /**
  65359. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65360. *
  65361. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65362. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65363. * @param current current value
  65364. * @param target target value
  65365. * @param maxDelta max distance to move
  65366. * @returns resulting angle
  65367. */
  65368. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65369. /**
  65370. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65371. * @param start start value
  65372. * @param end target value
  65373. * @param amount amount to lerp between
  65374. * @returns the lerped value
  65375. */
  65376. static Lerp(start: number, end: number, amount: number): number;
  65377. /**
  65378. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65379. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65380. * @param start start value
  65381. * @param end target value
  65382. * @param amount amount to lerp between
  65383. * @returns the lerped value
  65384. */
  65385. static LerpAngle(start: number, end: number, amount: number): number;
  65386. /**
  65387. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65388. * @param a start value
  65389. * @param b target value
  65390. * @param value value between a and b
  65391. * @returns the inverseLerp value
  65392. */
  65393. static InverseLerp(a: number, b: number, value: number): number;
  65394. /**
  65395. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65396. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65397. * @param value1 spline value
  65398. * @param tangent1 spline value
  65399. * @param value2 spline value
  65400. * @param tangent2 spline value
  65401. * @param amount input value
  65402. * @returns hermite result
  65403. */
  65404. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65405. /**
  65406. * Returns a random float number between and min and max values
  65407. * @param min min value of random
  65408. * @param max max value of random
  65409. * @returns random value
  65410. */
  65411. static RandomRange(min: number, max: number): number;
  65412. /**
  65413. * This function returns percentage of a number in a given range.
  65414. *
  65415. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65416. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65417. * @param number to convert to percentage
  65418. * @param min min range
  65419. * @param max max range
  65420. * @returns the percentage
  65421. */
  65422. static RangeToPercent(number: number, min: number, max: number): number;
  65423. /**
  65424. * This function returns number that corresponds to the percentage in a given range.
  65425. *
  65426. * PercentToRange(0.34,0,100) will return 34.
  65427. * @param percent to convert to number
  65428. * @param min min range
  65429. * @param max max range
  65430. * @returns the number
  65431. */
  65432. static PercentToRange(percent: number, min: number, max: number): number;
  65433. /**
  65434. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65435. * @param angle The angle to normalize in radian.
  65436. * @return The converted angle.
  65437. */
  65438. static NormalizeRadians(angle: number): number;
  65439. }
  65440. }
  65441. declare module BABYLON {
  65442. /**
  65443. * Constant used to convert a value to gamma space
  65444. * @ignorenaming
  65445. */
  65446. export const ToGammaSpace: number;
  65447. /**
  65448. * Constant used to convert a value to linear space
  65449. * @ignorenaming
  65450. */
  65451. export const ToLinearSpace = 2.2;
  65452. /**
  65453. * Constant used to define the minimal number value in Babylon.js
  65454. * @ignorenaming
  65455. */
  65456. let Epsilon: number;
  65457. }
  65458. declare module BABYLON {
  65459. /**
  65460. * Class used to represent a viewport on screen
  65461. */
  65462. export class Viewport {
  65463. /** viewport left coordinate */
  65464. x: number;
  65465. /** viewport top coordinate */
  65466. y: number;
  65467. /**viewport width */
  65468. width: number;
  65469. /** viewport height */
  65470. height: number;
  65471. /**
  65472. * Creates a Viewport object located at (x, y) and sized (width, height)
  65473. * @param x defines viewport left coordinate
  65474. * @param y defines viewport top coordinate
  65475. * @param width defines the viewport width
  65476. * @param height defines the viewport height
  65477. */
  65478. constructor(
  65479. /** viewport left coordinate */
  65480. x: number,
  65481. /** viewport top coordinate */
  65482. y: number,
  65483. /**viewport width */
  65484. width: number,
  65485. /** viewport height */
  65486. height: number);
  65487. /**
  65488. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65489. * @param renderWidth defines the rendering width
  65490. * @param renderHeight defines the rendering height
  65491. * @returns a new Viewport
  65492. */
  65493. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65494. /**
  65495. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65496. * @param renderWidth defines the rendering width
  65497. * @param renderHeight defines the rendering height
  65498. * @param ref defines the target viewport
  65499. * @returns the current viewport
  65500. */
  65501. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65502. /**
  65503. * Returns a new Viewport copied from the current one
  65504. * @returns a new Viewport
  65505. */
  65506. clone(): Viewport;
  65507. }
  65508. }
  65509. declare module BABYLON {
  65510. /**
  65511. * Class containing a set of static utilities functions for arrays.
  65512. */
  65513. export class ArrayTools {
  65514. /**
  65515. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65516. * @param size the number of element to construct and put in the array
  65517. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65518. * @returns a new array filled with new objects
  65519. */
  65520. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65521. }
  65522. }
  65523. declare module BABYLON {
  65524. /**
  65525. * @hidden
  65526. */
  65527. export interface IColor4Like {
  65528. r: float;
  65529. g: float;
  65530. b: float;
  65531. a: float;
  65532. }
  65533. /**
  65534. * @hidden
  65535. */
  65536. export interface IColor3Like {
  65537. r: float;
  65538. g: float;
  65539. b: float;
  65540. }
  65541. /**
  65542. * @hidden
  65543. */
  65544. export interface IVector4Like {
  65545. x: float;
  65546. y: float;
  65547. z: float;
  65548. w: float;
  65549. }
  65550. /**
  65551. * @hidden
  65552. */
  65553. export interface IVector3Like {
  65554. x: float;
  65555. y: float;
  65556. z: float;
  65557. }
  65558. /**
  65559. * @hidden
  65560. */
  65561. export interface IVector2Like {
  65562. x: float;
  65563. y: float;
  65564. }
  65565. /**
  65566. * @hidden
  65567. */
  65568. export interface IMatrixLike {
  65569. toArray(): DeepImmutable<Float32Array>;
  65570. updateFlag: int;
  65571. }
  65572. /**
  65573. * @hidden
  65574. */
  65575. export interface IViewportLike {
  65576. x: float;
  65577. y: float;
  65578. width: float;
  65579. height: float;
  65580. }
  65581. /**
  65582. * @hidden
  65583. */
  65584. export interface IPlaneLike {
  65585. normal: IVector3Like;
  65586. d: float;
  65587. normalize(): void;
  65588. }
  65589. }
  65590. declare module BABYLON {
  65591. /**
  65592. * Class representing a vector containing 2 coordinates
  65593. */
  65594. export class Vector2 {
  65595. /** defines the first coordinate */
  65596. x: number;
  65597. /** defines the second coordinate */
  65598. y: number;
  65599. /**
  65600. * Creates a new Vector2 from the given x and y coordinates
  65601. * @param x defines the first coordinate
  65602. * @param y defines the second coordinate
  65603. */
  65604. constructor(
  65605. /** defines the first coordinate */
  65606. x?: number,
  65607. /** defines the second coordinate */
  65608. y?: number);
  65609. /**
  65610. * Gets a string with the Vector2 coordinates
  65611. * @returns a string with the Vector2 coordinates
  65612. */
  65613. toString(): string;
  65614. /**
  65615. * Gets class name
  65616. * @returns the string "Vector2"
  65617. */
  65618. getClassName(): string;
  65619. /**
  65620. * Gets current vector hash code
  65621. * @returns the Vector2 hash code as a number
  65622. */
  65623. getHashCode(): number;
  65624. /**
  65625. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65626. * @param array defines the source array
  65627. * @param index defines the offset in source array
  65628. * @returns the current Vector2
  65629. */
  65630. toArray(array: FloatArray, index?: number): Vector2;
  65631. /**
  65632. * Copy the current vector to an array
  65633. * @returns a new array with 2 elements: the Vector2 coordinates.
  65634. */
  65635. asArray(): number[];
  65636. /**
  65637. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65638. * @param source defines the source Vector2
  65639. * @returns the current updated Vector2
  65640. */
  65641. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65642. /**
  65643. * Sets the Vector2 coordinates with the given floats
  65644. * @param x defines the first coordinate
  65645. * @param y defines the second coordinate
  65646. * @returns the current updated Vector2
  65647. */
  65648. copyFromFloats(x: number, y: number): Vector2;
  65649. /**
  65650. * Sets the Vector2 coordinates with the given floats
  65651. * @param x defines the first coordinate
  65652. * @param y defines the second coordinate
  65653. * @returns the current updated Vector2
  65654. */
  65655. set(x: number, y: number): Vector2;
  65656. /**
  65657. * Add another vector with the current one
  65658. * @param otherVector defines the other vector
  65659. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65660. */
  65661. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65662. /**
  65663. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65664. * @param otherVector defines the other vector
  65665. * @param result defines the target vector
  65666. * @returns the unmodified current Vector2
  65667. */
  65668. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65669. /**
  65670. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65671. * @param otherVector defines the other vector
  65672. * @returns the current updated Vector2
  65673. */
  65674. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65675. /**
  65676. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65677. * @param otherVector defines the other vector
  65678. * @returns a new Vector2
  65679. */
  65680. addVector3(otherVector: Vector3): Vector2;
  65681. /**
  65682. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65683. * @param otherVector defines the other vector
  65684. * @returns a new Vector2
  65685. */
  65686. subtract(otherVector: Vector2): Vector2;
  65687. /**
  65688. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65689. * @param otherVector defines the other vector
  65690. * @param result defines the target vector
  65691. * @returns the unmodified current Vector2
  65692. */
  65693. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65694. /**
  65695. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65696. * @param otherVector defines the other vector
  65697. * @returns the current updated Vector2
  65698. */
  65699. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65700. /**
  65701. * Multiplies in place the current Vector2 coordinates by the given ones
  65702. * @param otherVector defines the other vector
  65703. * @returns the current updated Vector2
  65704. */
  65705. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65706. /**
  65707. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65708. * @param otherVector defines the other vector
  65709. * @returns a new Vector2
  65710. */
  65711. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65712. /**
  65713. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65714. * @param otherVector defines the other vector
  65715. * @param result defines the target vector
  65716. * @returns the unmodified current Vector2
  65717. */
  65718. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65719. /**
  65720. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65721. * @param x defines the first coordinate
  65722. * @param y defines the second coordinate
  65723. * @returns a new Vector2
  65724. */
  65725. multiplyByFloats(x: number, y: number): Vector2;
  65726. /**
  65727. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65728. * @param otherVector defines the other vector
  65729. * @returns a new Vector2
  65730. */
  65731. divide(otherVector: Vector2): Vector2;
  65732. /**
  65733. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65734. * @param otherVector defines the other vector
  65735. * @param result defines the target vector
  65736. * @returns the unmodified current Vector2
  65737. */
  65738. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65739. /**
  65740. * Divides the current Vector2 coordinates by the given ones
  65741. * @param otherVector defines the other vector
  65742. * @returns the current updated Vector2
  65743. */
  65744. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65745. /**
  65746. * Gets a new Vector2 with current Vector2 negated coordinates
  65747. * @returns a new Vector2
  65748. */
  65749. negate(): Vector2;
  65750. /**
  65751. * Multiply the Vector2 coordinates by scale
  65752. * @param scale defines the scaling factor
  65753. * @returns the current updated Vector2
  65754. */
  65755. scaleInPlace(scale: number): Vector2;
  65756. /**
  65757. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65758. * @param scale defines the scaling factor
  65759. * @returns a new Vector2
  65760. */
  65761. scale(scale: number): Vector2;
  65762. /**
  65763. * Scale the current Vector2 values by a factor to a given Vector2
  65764. * @param scale defines the scale factor
  65765. * @param result defines the Vector2 object where to store the result
  65766. * @returns the unmodified current Vector2
  65767. */
  65768. scaleToRef(scale: number, result: Vector2): Vector2;
  65769. /**
  65770. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65771. * @param scale defines the scale factor
  65772. * @param result defines the Vector2 object where to store the result
  65773. * @returns the unmodified current Vector2
  65774. */
  65775. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65776. /**
  65777. * Gets a boolean if two vectors are equals
  65778. * @param otherVector defines the other vector
  65779. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65780. */
  65781. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65782. /**
  65783. * Gets a boolean if two vectors are equals (using an epsilon value)
  65784. * @param otherVector defines the other vector
  65785. * @param epsilon defines the minimal distance to consider equality
  65786. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65787. */
  65788. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65789. /**
  65790. * Gets a new Vector2 from current Vector2 floored values
  65791. * @returns a new Vector2
  65792. */
  65793. floor(): Vector2;
  65794. /**
  65795. * Gets a new Vector2 from current Vector2 floored values
  65796. * @returns a new Vector2
  65797. */
  65798. fract(): Vector2;
  65799. /**
  65800. * Gets the length of the vector
  65801. * @returns the vector length (float)
  65802. */
  65803. length(): number;
  65804. /**
  65805. * Gets the vector squared length
  65806. * @returns the vector squared length (float)
  65807. */
  65808. lengthSquared(): number;
  65809. /**
  65810. * Normalize the vector
  65811. * @returns the current updated Vector2
  65812. */
  65813. normalize(): Vector2;
  65814. /**
  65815. * Gets a new Vector2 copied from the Vector2
  65816. * @returns a new Vector2
  65817. */
  65818. clone(): Vector2;
  65819. /**
  65820. * Gets a new Vector2(0, 0)
  65821. * @returns a new Vector2
  65822. */
  65823. static Zero(): Vector2;
  65824. /**
  65825. * Gets a new Vector2(1, 1)
  65826. * @returns a new Vector2
  65827. */
  65828. static One(): Vector2;
  65829. /**
  65830. * Gets a new Vector2 set from the given index element of the given array
  65831. * @param array defines the data source
  65832. * @param offset defines the offset in the data source
  65833. * @returns a new Vector2
  65834. */
  65835. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65836. /**
  65837. * Sets "result" from the given index element of the given array
  65838. * @param array defines the data source
  65839. * @param offset defines the offset in the data source
  65840. * @param result defines the target vector
  65841. */
  65842. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65843. /**
  65844. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65845. * @param value1 defines 1st point of control
  65846. * @param value2 defines 2nd point of control
  65847. * @param value3 defines 3rd point of control
  65848. * @param value4 defines 4th point of control
  65849. * @param amount defines the interpolation factor
  65850. * @returns a new Vector2
  65851. */
  65852. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65853. /**
  65854. * 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".
  65855. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65856. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65857. * @param value defines the value to clamp
  65858. * @param min defines the lower limit
  65859. * @param max defines the upper limit
  65860. * @returns a new Vector2
  65861. */
  65862. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65863. /**
  65864. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65865. * @param value1 defines the 1st control point
  65866. * @param tangent1 defines the outgoing tangent
  65867. * @param value2 defines the 2nd control point
  65868. * @param tangent2 defines the incoming tangent
  65869. * @param amount defines the interpolation factor
  65870. * @returns a new Vector2
  65871. */
  65872. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65873. /**
  65874. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65875. * @param start defines the start vector
  65876. * @param end defines the end vector
  65877. * @param amount defines the interpolation factor
  65878. * @returns a new Vector2
  65879. */
  65880. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65881. /**
  65882. * Gets the dot product of the vector "left" and the vector "right"
  65883. * @param left defines first vector
  65884. * @param right defines second vector
  65885. * @returns the dot product (float)
  65886. */
  65887. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65888. /**
  65889. * Returns a new Vector2 equal to the normalized given vector
  65890. * @param vector defines the vector to normalize
  65891. * @returns a new Vector2
  65892. */
  65893. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65894. /**
  65895. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65896. * @param left defines 1st vector
  65897. * @param right defines 2nd vector
  65898. * @returns a new Vector2
  65899. */
  65900. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65901. /**
  65902. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65903. * @param left defines 1st vector
  65904. * @param right defines 2nd vector
  65905. * @returns a new Vector2
  65906. */
  65907. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65908. /**
  65909. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65910. * @param vector defines the vector to transform
  65911. * @param transformation defines the matrix to apply
  65912. * @returns a new Vector2
  65913. */
  65914. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65915. /**
  65916. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65917. * @param vector defines the vector to transform
  65918. * @param transformation defines the matrix to apply
  65919. * @param result defines the target vector
  65920. */
  65921. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65922. /**
  65923. * Determines if a given vector is included in a triangle
  65924. * @param p defines the vector to test
  65925. * @param p0 defines 1st triangle point
  65926. * @param p1 defines 2nd triangle point
  65927. * @param p2 defines 3rd triangle point
  65928. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65929. */
  65930. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65931. /**
  65932. * Gets the distance between the vectors "value1" and "value2"
  65933. * @param value1 defines first vector
  65934. * @param value2 defines second vector
  65935. * @returns the distance between vectors
  65936. */
  65937. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65938. /**
  65939. * Returns the squared distance between the vectors "value1" and "value2"
  65940. * @param value1 defines first vector
  65941. * @param value2 defines second vector
  65942. * @returns the squared distance between vectors
  65943. */
  65944. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65945. /**
  65946. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65947. * @param value1 defines first vector
  65948. * @param value2 defines second vector
  65949. * @returns a new Vector2
  65950. */
  65951. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65952. /**
  65953. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65954. * @param p defines the middle point
  65955. * @param segA defines one point of the segment
  65956. * @param segB defines the other point of the segment
  65957. * @returns the shortest distance
  65958. */
  65959. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65960. }
  65961. /**
  65962. * Classed used to store (x,y,z) vector representation
  65963. * A Vector3 is the main object used in 3D geometry
  65964. * It can represent etiher the coordinates of a point the space, either a direction
  65965. * Reminder: js uses a left handed forward facing system
  65966. */
  65967. export class Vector3 {
  65968. /**
  65969. * Defines the first coordinates (on X axis)
  65970. */
  65971. x: number;
  65972. /**
  65973. * Defines the second coordinates (on Y axis)
  65974. */
  65975. y: number;
  65976. /**
  65977. * Defines the third coordinates (on Z axis)
  65978. */
  65979. z: number;
  65980. private static _UpReadOnly;
  65981. private static _ZeroReadOnly;
  65982. /**
  65983. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65984. * @param x defines the first coordinates (on X axis)
  65985. * @param y defines the second coordinates (on Y axis)
  65986. * @param z defines the third coordinates (on Z axis)
  65987. */
  65988. constructor(
  65989. /**
  65990. * Defines the first coordinates (on X axis)
  65991. */
  65992. x?: number,
  65993. /**
  65994. * Defines the second coordinates (on Y axis)
  65995. */
  65996. y?: number,
  65997. /**
  65998. * Defines the third coordinates (on Z axis)
  65999. */
  66000. z?: number);
  66001. /**
  66002. * Creates a string representation of the Vector3
  66003. * @returns a string with the Vector3 coordinates.
  66004. */
  66005. toString(): string;
  66006. /**
  66007. * Gets the class name
  66008. * @returns the string "Vector3"
  66009. */
  66010. getClassName(): string;
  66011. /**
  66012. * Creates the Vector3 hash code
  66013. * @returns a number which tends to be unique between Vector3 instances
  66014. */
  66015. getHashCode(): number;
  66016. /**
  66017. * Creates an array containing three elements : the coordinates of the Vector3
  66018. * @returns a new array of numbers
  66019. */
  66020. asArray(): number[];
  66021. /**
  66022. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  66023. * @param array defines the destination array
  66024. * @param index defines the offset in the destination array
  66025. * @returns the current Vector3
  66026. */
  66027. toArray(array: FloatArray, index?: number): Vector3;
  66028. /**
  66029. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  66030. * @returns a new Quaternion object, computed from the Vector3 coordinates
  66031. */
  66032. toQuaternion(): Quaternion;
  66033. /**
  66034. * Adds the given vector to the current Vector3
  66035. * @param otherVector defines the second operand
  66036. * @returns the current updated Vector3
  66037. */
  66038. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66039. /**
  66040. * Adds the given coordinates to the current Vector3
  66041. * @param x defines the x coordinate of the operand
  66042. * @param y defines the y coordinate of the operand
  66043. * @param z defines the z coordinate of the operand
  66044. * @returns the current updated Vector3
  66045. */
  66046. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66047. /**
  66048. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  66049. * @param otherVector defines the second operand
  66050. * @returns the resulting Vector3
  66051. */
  66052. add(otherVector: DeepImmutable<Vector3>): Vector3;
  66053. /**
  66054. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  66055. * @param otherVector defines the second operand
  66056. * @param result defines the Vector3 object where to store the result
  66057. * @returns the current Vector3
  66058. */
  66059. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66060. /**
  66061. * Subtract the given vector from the current Vector3
  66062. * @param otherVector defines the second operand
  66063. * @returns the current updated Vector3
  66064. */
  66065. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66066. /**
  66067. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  66068. * @param otherVector defines the second operand
  66069. * @returns the resulting Vector3
  66070. */
  66071. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  66072. /**
  66073. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  66074. * @param otherVector defines the second operand
  66075. * @param result defines the Vector3 object where to store the result
  66076. * @returns the current Vector3
  66077. */
  66078. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66079. /**
  66080. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  66081. * @param x defines the x coordinate of the operand
  66082. * @param y defines the y coordinate of the operand
  66083. * @param z defines the z coordinate of the operand
  66084. * @returns the resulting Vector3
  66085. */
  66086. subtractFromFloats(x: number, y: number, z: number): Vector3;
  66087. /**
  66088. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  66089. * @param x defines the x coordinate of the operand
  66090. * @param y defines the y coordinate of the operand
  66091. * @param z defines the z coordinate of the operand
  66092. * @param result defines the Vector3 object where to store the result
  66093. * @returns the current Vector3
  66094. */
  66095. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  66096. /**
  66097. * Gets a new Vector3 set with the current Vector3 negated coordinates
  66098. * @returns a new Vector3
  66099. */
  66100. negate(): Vector3;
  66101. /**
  66102. * Multiplies the Vector3 coordinates by the float "scale"
  66103. * @param scale defines the multiplier factor
  66104. * @returns the current updated Vector3
  66105. */
  66106. scaleInPlace(scale: number): Vector3;
  66107. /**
  66108. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  66109. * @param scale defines the multiplier factor
  66110. * @returns a new Vector3
  66111. */
  66112. scale(scale: number): Vector3;
  66113. /**
  66114. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  66115. * @param scale defines the multiplier factor
  66116. * @param result defines the Vector3 object where to store the result
  66117. * @returns the current Vector3
  66118. */
  66119. scaleToRef(scale: number, result: Vector3): Vector3;
  66120. /**
  66121. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  66122. * @param scale defines the scale factor
  66123. * @param result defines the Vector3 object where to store the result
  66124. * @returns the unmodified current Vector3
  66125. */
  66126. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  66127. /**
  66128. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  66129. * @param otherVector defines the second operand
  66130. * @returns true if both vectors are equals
  66131. */
  66132. equals(otherVector: DeepImmutable<Vector3>): boolean;
  66133. /**
  66134. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  66135. * @param otherVector defines the second operand
  66136. * @param epsilon defines the minimal distance to define values as equals
  66137. * @returns true if both vectors are distant less than epsilon
  66138. */
  66139. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  66140. /**
  66141. * Returns true if the current Vector3 coordinates equals the given floats
  66142. * @param x defines the x coordinate of the operand
  66143. * @param y defines the y coordinate of the operand
  66144. * @param z defines the z coordinate of the operand
  66145. * @returns true if both vectors are equals
  66146. */
  66147. equalsToFloats(x: number, y: number, z: number): boolean;
  66148. /**
  66149. * Multiplies the current Vector3 coordinates by the given ones
  66150. * @param otherVector defines the second operand
  66151. * @returns the current updated Vector3
  66152. */
  66153. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  66154. /**
  66155. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  66156. * @param otherVector defines the second operand
  66157. * @returns the new Vector3
  66158. */
  66159. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  66160. /**
  66161. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  66162. * @param otherVector defines the second operand
  66163. * @param result defines the Vector3 object where to store the result
  66164. * @returns the current Vector3
  66165. */
  66166. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66167. /**
  66168. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  66169. * @param x defines the x coordinate of the operand
  66170. * @param y defines the y coordinate of the operand
  66171. * @param z defines the z coordinate of the operand
  66172. * @returns the new Vector3
  66173. */
  66174. multiplyByFloats(x: number, y: number, z: number): Vector3;
  66175. /**
  66176. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  66177. * @param otherVector defines the second operand
  66178. * @returns the new Vector3
  66179. */
  66180. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  66181. /**
  66182. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  66183. * @param otherVector defines the second operand
  66184. * @param result defines the Vector3 object where to store the result
  66185. * @returns the current Vector3
  66186. */
  66187. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  66188. /**
  66189. * Divides the current Vector3 coordinates by the given ones.
  66190. * @param otherVector defines the second operand
  66191. * @returns the current updated Vector3
  66192. */
  66193. divideInPlace(otherVector: Vector3): Vector3;
  66194. /**
  66195. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  66196. * @param other defines the second operand
  66197. * @returns the current updated Vector3
  66198. */
  66199. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66200. /**
  66201. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  66202. * @param other defines the second operand
  66203. * @returns the current updated Vector3
  66204. */
  66205. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  66206. /**
  66207. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  66208. * @param x defines the x coordinate of the operand
  66209. * @param y defines the y coordinate of the operand
  66210. * @param z defines the z coordinate of the operand
  66211. * @returns the current updated Vector3
  66212. */
  66213. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66214. /**
  66215. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  66216. * @param x defines the x coordinate of the operand
  66217. * @param y defines the y coordinate of the operand
  66218. * @param z defines the z coordinate of the operand
  66219. * @returns the current updated Vector3
  66220. */
  66221. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  66222. /**
  66223. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  66224. * Check if is non uniform within a certain amount of decimal places to account for this
  66225. * @param epsilon the amount the values can differ
  66226. * @returns if the the vector is non uniform to a certain number of decimal places
  66227. */
  66228. isNonUniformWithinEpsilon(epsilon: number): boolean;
  66229. /**
  66230. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  66231. */
  66232. readonly isNonUniform: boolean;
  66233. /**
  66234. * Gets a new Vector3 from current Vector3 floored values
  66235. * @returns a new Vector3
  66236. */
  66237. floor(): Vector3;
  66238. /**
  66239. * Gets a new Vector3 from current Vector3 floored values
  66240. * @returns a new Vector3
  66241. */
  66242. fract(): Vector3;
  66243. /**
  66244. * Gets the length of the Vector3
  66245. * @returns the length of the Vector3
  66246. */
  66247. length(): number;
  66248. /**
  66249. * Gets the squared length of the Vector3
  66250. * @returns squared length of the Vector3
  66251. */
  66252. lengthSquared(): number;
  66253. /**
  66254. * Normalize the current Vector3.
  66255. * Please note that this is an in place operation.
  66256. * @returns the current updated Vector3
  66257. */
  66258. normalize(): Vector3;
  66259. /**
  66260. * Reorders the x y z properties of the vector in place
  66261. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  66262. * @returns the current updated vector
  66263. */
  66264. reorderInPlace(order: string): this;
  66265. /**
  66266. * Rotates the vector around 0,0,0 by a quaternion
  66267. * @param quaternion the rotation quaternion
  66268. * @param result vector to store the result
  66269. * @returns the resulting vector
  66270. */
  66271. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  66272. /**
  66273. * Rotates a vector around a given point
  66274. * @param quaternion the rotation quaternion
  66275. * @param point the point to rotate around
  66276. * @param result vector to store the result
  66277. * @returns the resulting vector
  66278. */
  66279. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  66280. /**
  66281. * Normalize the current Vector3 with the given input length.
  66282. * Please note that this is an in place operation.
  66283. * @param len the length of the vector
  66284. * @returns the current updated Vector3
  66285. */
  66286. normalizeFromLength(len: number): Vector3;
  66287. /**
  66288. * Normalize the current Vector3 to a new vector
  66289. * @returns the new Vector3
  66290. */
  66291. normalizeToNew(): Vector3;
  66292. /**
  66293. * Normalize the current Vector3 to the reference
  66294. * @param reference define the Vector3 to update
  66295. * @returns the updated Vector3
  66296. */
  66297. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  66298. /**
  66299. * Creates a new Vector3 copied from the current Vector3
  66300. * @returns the new Vector3
  66301. */
  66302. clone(): Vector3;
  66303. /**
  66304. * Copies the given vector coordinates to the current Vector3 ones
  66305. * @param source defines the source Vector3
  66306. * @returns the current updated Vector3
  66307. */
  66308. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66309. /**
  66310. * Copies the given floats to the current Vector3 coordinates
  66311. * @param x defines the x coordinate of the operand
  66312. * @param y defines the y coordinate of the operand
  66313. * @param z defines the z coordinate of the operand
  66314. * @returns the current updated Vector3
  66315. */
  66316. copyFromFloats(x: number, y: number, z: number): Vector3;
  66317. /**
  66318. * Copies the given floats to the current Vector3 coordinates
  66319. * @param x defines the x coordinate of the operand
  66320. * @param y defines the y coordinate of the operand
  66321. * @param z defines the z coordinate of the operand
  66322. * @returns the current updated Vector3
  66323. */
  66324. set(x: number, y: number, z: number): Vector3;
  66325. /**
  66326. * Copies the given float to the current Vector3 coordinates
  66327. * @param v defines the x, y and z coordinates of the operand
  66328. * @returns the current updated Vector3
  66329. */
  66330. setAll(v: number): Vector3;
  66331. /**
  66332. * Get the clip factor between two vectors
  66333. * @param vector0 defines the first operand
  66334. * @param vector1 defines the second operand
  66335. * @param axis defines the axis to use
  66336. * @param size defines the size along the axis
  66337. * @returns the clip factor
  66338. */
  66339. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66340. /**
  66341. * Get angle between two vectors
  66342. * @param vector0 angle between vector0 and vector1
  66343. * @param vector1 angle between vector0 and vector1
  66344. * @param normal direction of the normal
  66345. * @return the angle between vector0 and vector1
  66346. */
  66347. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66348. /**
  66349. * Returns a new Vector3 set from the index "offset" of the given array
  66350. * @param array defines the source array
  66351. * @param offset defines the offset in the source array
  66352. * @returns the new Vector3
  66353. */
  66354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66355. /**
  66356. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66357. * This function is deprecated. Use FromArray instead
  66358. * @param array defines the source array
  66359. * @param offset defines the offset in the source array
  66360. * @returns the new Vector3
  66361. */
  66362. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66363. /**
  66364. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66365. * @param array defines the source array
  66366. * @param offset defines the offset in the source array
  66367. * @param result defines the Vector3 where to store the result
  66368. */
  66369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66370. /**
  66371. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66372. * This function is deprecated. Use FromArrayToRef instead.
  66373. * @param array defines the source array
  66374. * @param offset defines the offset in the source array
  66375. * @param result defines the Vector3 where to store the result
  66376. */
  66377. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66378. /**
  66379. * Sets the given vector "result" with the given floats.
  66380. * @param x defines the x coordinate of the source
  66381. * @param y defines the y coordinate of the source
  66382. * @param z defines the z coordinate of the source
  66383. * @param result defines the Vector3 where to store the result
  66384. */
  66385. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66386. /**
  66387. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66388. * @returns a new empty Vector3
  66389. */
  66390. static Zero(): Vector3;
  66391. /**
  66392. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66393. * @returns a new unit Vector3
  66394. */
  66395. static One(): Vector3;
  66396. /**
  66397. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66398. * @returns a new up Vector3
  66399. */
  66400. static Up(): Vector3;
  66401. /**
  66402. * Gets a up Vector3 that must not be updated
  66403. */
  66404. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66405. /**
  66406. * Gets a zero Vector3 that must not be updated
  66407. */
  66408. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66409. /**
  66410. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66411. * @returns a new down Vector3
  66412. */
  66413. static Down(): Vector3;
  66414. /**
  66415. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66416. * @returns a new forward Vector3
  66417. */
  66418. static Forward(): Vector3;
  66419. /**
  66420. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66421. * @returns a new forward Vector3
  66422. */
  66423. static Backward(): Vector3;
  66424. /**
  66425. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66426. * @returns a new right Vector3
  66427. */
  66428. static Right(): Vector3;
  66429. /**
  66430. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66431. * @returns a new left Vector3
  66432. */
  66433. static Left(): Vector3;
  66434. /**
  66435. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66436. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66437. * @param vector defines the Vector3 to transform
  66438. * @param transformation defines the transformation matrix
  66439. * @returns the transformed Vector3
  66440. */
  66441. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66442. /**
  66443. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66444. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66445. * @param vector defines the Vector3 to transform
  66446. * @param transformation defines the transformation matrix
  66447. * @param result defines the Vector3 where to store the result
  66448. */
  66449. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66450. /**
  66451. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66452. * This method computes tranformed coordinates only, not transformed direction vectors
  66453. * @param x define the x coordinate of the source vector
  66454. * @param y define the y coordinate of the source vector
  66455. * @param z define the z coordinate of the source vector
  66456. * @param transformation defines the transformation matrix
  66457. * @param result defines the Vector3 where to store the result
  66458. */
  66459. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66460. /**
  66461. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66462. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66463. * @param vector defines the Vector3 to transform
  66464. * @param transformation defines the transformation matrix
  66465. * @returns the new Vector3
  66466. */
  66467. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66468. /**
  66469. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66470. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66471. * @param vector defines the Vector3 to transform
  66472. * @param transformation defines the transformation matrix
  66473. * @param result defines the Vector3 where to store the result
  66474. */
  66475. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66476. /**
  66477. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66478. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66479. * @param x define the x coordinate of the source vector
  66480. * @param y define the y coordinate of the source vector
  66481. * @param z define the z coordinate of the source vector
  66482. * @param transformation defines the transformation matrix
  66483. * @param result defines the Vector3 where to store the result
  66484. */
  66485. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66486. /**
  66487. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66488. * @param value1 defines the first control point
  66489. * @param value2 defines the second control point
  66490. * @param value3 defines the third control point
  66491. * @param value4 defines the fourth control point
  66492. * @param amount defines the amount on the spline to use
  66493. * @returns the new Vector3
  66494. */
  66495. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66496. /**
  66497. * 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"
  66498. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66499. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66500. * @param value defines the current value
  66501. * @param min defines the lower range value
  66502. * @param max defines the upper range value
  66503. * @returns the new Vector3
  66504. */
  66505. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66506. /**
  66507. * 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"
  66508. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66509. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66510. * @param value defines the current value
  66511. * @param min defines the lower range value
  66512. * @param max defines the upper range value
  66513. * @param result defines the Vector3 where to store the result
  66514. */
  66515. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66516. /**
  66517. * Checks if a given vector is inside a specific range
  66518. * @param v defines the vector to test
  66519. * @param min defines the minimum range
  66520. * @param max defines the maximum range
  66521. */
  66522. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66523. /**
  66524. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66525. * @param value1 defines the first control point
  66526. * @param tangent1 defines the first tangent vector
  66527. * @param value2 defines the second control point
  66528. * @param tangent2 defines the second tangent vector
  66529. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66530. * @returns the new Vector3
  66531. */
  66532. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66533. /**
  66534. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66535. * @param start defines the start value
  66536. * @param end defines the end value
  66537. * @param amount max defines amount between both (between 0 and 1)
  66538. * @returns the new Vector3
  66539. */
  66540. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66541. /**
  66542. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66543. * @param start defines the start value
  66544. * @param end defines the end value
  66545. * @param amount max defines amount between both (between 0 and 1)
  66546. * @param result defines the Vector3 where to store the result
  66547. */
  66548. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66549. /**
  66550. * Returns the dot product (float) between the vectors "left" and "right"
  66551. * @param left defines the left operand
  66552. * @param right defines the right operand
  66553. * @returns the dot product
  66554. */
  66555. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66556. /**
  66557. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66558. * The cross product is then orthogonal to both "left" and "right"
  66559. * @param left defines the left operand
  66560. * @param right defines the right operand
  66561. * @returns the cross product
  66562. */
  66563. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66564. /**
  66565. * Sets the given vector "result" with the cross product of "left" and "right"
  66566. * The cross product is then orthogonal to both "left" and "right"
  66567. * @param left defines the left operand
  66568. * @param right defines the right operand
  66569. * @param result defines the Vector3 where to store the result
  66570. */
  66571. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66572. /**
  66573. * Returns a new Vector3 as the normalization of the given vector
  66574. * @param vector defines the Vector3 to normalize
  66575. * @returns the new Vector3
  66576. */
  66577. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66578. /**
  66579. * Sets the given vector "result" with the normalization of the given first vector
  66580. * @param vector defines the Vector3 to normalize
  66581. * @param result defines the Vector3 where to store the result
  66582. */
  66583. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66584. /**
  66585. * Project a Vector3 onto screen space
  66586. * @param vector defines the Vector3 to project
  66587. * @param world defines the world matrix to use
  66588. * @param transform defines the transform (view x projection) matrix to use
  66589. * @param viewport defines the screen viewport to use
  66590. * @returns the new Vector3
  66591. */
  66592. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66593. /** @hidden */
  66594. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66595. /**
  66596. * Unproject from screen space to object space
  66597. * @param source defines the screen space Vector3 to use
  66598. * @param viewportWidth defines the current width of the viewport
  66599. * @param viewportHeight defines the current height of the viewport
  66600. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66601. * @param transform defines the transform (view x projection) matrix to use
  66602. * @returns the new Vector3
  66603. */
  66604. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66605. /**
  66606. * Unproject from screen space to object space
  66607. * @param source defines the screen space Vector3 to use
  66608. * @param viewportWidth defines the current width of the viewport
  66609. * @param viewportHeight defines the current height of the viewport
  66610. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66611. * @param view defines the view matrix to use
  66612. * @param projection defines the projection matrix to use
  66613. * @returns the new Vector3
  66614. */
  66615. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66616. /**
  66617. * Unproject from screen space to object space
  66618. * @param source defines the screen space Vector3 to use
  66619. * @param viewportWidth defines the current width of the viewport
  66620. * @param viewportHeight defines the current height of the viewport
  66621. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66622. * @param view defines the view matrix to use
  66623. * @param projection defines the projection matrix to use
  66624. * @param result defines the Vector3 where to store the result
  66625. */
  66626. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66627. /**
  66628. * Unproject from screen space to object space
  66629. * @param sourceX defines the screen space x coordinate to use
  66630. * @param sourceY defines the screen space y coordinate to use
  66631. * @param sourceZ defines the screen space z coordinate to use
  66632. * @param viewportWidth defines the current width of the viewport
  66633. * @param viewportHeight defines the current height of the viewport
  66634. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66635. * @param view defines the view matrix to use
  66636. * @param projection defines the projection matrix to use
  66637. * @param result defines the Vector3 where to store the result
  66638. */
  66639. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66640. /**
  66641. * Gets the minimal coordinate values between two Vector3
  66642. * @param left defines the first operand
  66643. * @param right defines the second operand
  66644. * @returns the new Vector3
  66645. */
  66646. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66647. /**
  66648. * Gets the maximal coordinate values between two Vector3
  66649. * @param left defines the first operand
  66650. * @param right defines the second operand
  66651. * @returns the new Vector3
  66652. */
  66653. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66654. /**
  66655. * Returns the distance between the vectors "value1" and "value2"
  66656. * @param value1 defines the first operand
  66657. * @param value2 defines the second operand
  66658. * @returns the distance
  66659. */
  66660. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66661. /**
  66662. * Returns the squared distance between the vectors "value1" and "value2"
  66663. * @param value1 defines the first operand
  66664. * @param value2 defines the second operand
  66665. * @returns the squared distance
  66666. */
  66667. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66668. /**
  66669. * Returns a new Vector3 located at the center between "value1" and "value2"
  66670. * @param value1 defines the first operand
  66671. * @param value2 defines the second operand
  66672. * @returns the new Vector3
  66673. */
  66674. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66675. /**
  66676. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66677. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66678. * to something in order to rotate it from its local system to the given target system
  66679. * Note: axis1, axis2 and axis3 are normalized during this operation
  66680. * @param axis1 defines the first axis
  66681. * @param axis2 defines the second axis
  66682. * @param axis3 defines the third axis
  66683. * @returns a new Vector3
  66684. */
  66685. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66686. /**
  66687. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66688. * @param axis1 defines the first axis
  66689. * @param axis2 defines the second axis
  66690. * @param axis3 defines the third axis
  66691. * @param ref defines the Vector3 where to store the result
  66692. */
  66693. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66694. }
  66695. /**
  66696. * Vector4 class created for EulerAngle class conversion to Quaternion
  66697. */
  66698. export class Vector4 {
  66699. /** x value of the vector */
  66700. x: number;
  66701. /** y value of the vector */
  66702. y: number;
  66703. /** z value of the vector */
  66704. z: number;
  66705. /** w value of the vector */
  66706. w: number;
  66707. /**
  66708. * Creates a Vector4 object from the given floats.
  66709. * @param x x value of the vector
  66710. * @param y y value of the vector
  66711. * @param z z value of the vector
  66712. * @param w w value of the vector
  66713. */
  66714. constructor(
  66715. /** x value of the vector */
  66716. x: number,
  66717. /** y value of the vector */
  66718. y: number,
  66719. /** z value of the vector */
  66720. z: number,
  66721. /** w value of the vector */
  66722. w: number);
  66723. /**
  66724. * Returns the string with the Vector4 coordinates.
  66725. * @returns a string containing all the vector values
  66726. */
  66727. toString(): string;
  66728. /**
  66729. * Returns the string "Vector4".
  66730. * @returns "Vector4"
  66731. */
  66732. getClassName(): string;
  66733. /**
  66734. * Returns the Vector4 hash code.
  66735. * @returns a unique hash code
  66736. */
  66737. getHashCode(): number;
  66738. /**
  66739. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66740. * @returns the resulting array
  66741. */
  66742. asArray(): number[];
  66743. /**
  66744. * Populates the given array from the given index with the Vector4 coordinates.
  66745. * @param array array to populate
  66746. * @param index index of the array to start at (default: 0)
  66747. * @returns the Vector4.
  66748. */
  66749. toArray(array: FloatArray, index?: number): Vector4;
  66750. /**
  66751. * Adds the given vector to the current Vector4.
  66752. * @param otherVector the vector to add
  66753. * @returns the updated Vector4.
  66754. */
  66755. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66756. /**
  66757. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66758. * @param otherVector the vector to add
  66759. * @returns the resulting vector
  66760. */
  66761. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66762. /**
  66763. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66764. * @param otherVector the vector to add
  66765. * @param result the vector to store the result
  66766. * @returns the current Vector4.
  66767. */
  66768. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66769. /**
  66770. * Subtract in place the given vector from the current Vector4.
  66771. * @param otherVector the vector to subtract
  66772. * @returns the updated Vector4.
  66773. */
  66774. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66775. /**
  66776. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66777. * @param otherVector the vector to add
  66778. * @returns the new vector with the result
  66779. */
  66780. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66781. /**
  66782. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66783. * @param otherVector the vector to subtract
  66784. * @param result the vector to store the result
  66785. * @returns the current Vector4.
  66786. */
  66787. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66788. /**
  66789. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66790. */
  66791. /**
  66792. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66793. * @param x value to subtract
  66794. * @param y value to subtract
  66795. * @param z value to subtract
  66796. * @param w value to subtract
  66797. * @returns new vector containing the result
  66798. */
  66799. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66800. /**
  66801. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66802. * @param x value to subtract
  66803. * @param y value to subtract
  66804. * @param z value to subtract
  66805. * @param w value to subtract
  66806. * @param result the vector to store the result in
  66807. * @returns the current Vector4.
  66808. */
  66809. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66810. /**
  66811. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66812. * @returns a new vector with the negated values
  66813. */
  66814. negate(): Vector4;
  66815. /**
  66816. * Multiplies the current Vector4 coordinates by scale (float).
  66817. * @param scale the number to scale with
  66818. * @returns the updated Vector4.
  66819. */
  66820. scaleInPlace(scale: number): Vector4;
  66821. /**
  66822. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66823. * @param scale the number to scale with
  66824. * @returns a new vector with the result
  66825. */
  66826. scale(scale: number): Vector4;
  66827. /**
  66828. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66829. * @param scale the number to scale with
  66830. * @param result a vector to store the result in
  66831. * @returns the current Vector4.
  66832. */
  66833. scaleToRef(scale: number, result: Vector4): Vector4;
  66834. /**
  66835. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66836. * @param scale defines the scale factor
  66837. * @param result defines the Vector4 object where to store the result
  66838. * @returns the unmodified current Vector4
  66839. */
  66840. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66841. /**
  66842. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66843. * @param otherVector the vector to compare against
  66844. * @returns true if they are equal
  66845. */
  66846. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66847. /**
  66848. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66849. * @param otherVector vector to compare against
  66850. * @param epsilon (Default: very small number)
  66851. * @returns true if they are equal
  66852. */
  66853. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66854. /**
  66855. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66856. * @param x x value to compare against
  66857. * @param y y value to compare against
  66858. * @param z z value to compare against
  66859. * @param w w value to compare against
  66860. * @returns true if equal
  66861. */
  66862. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66863. /**
  66864. * Multiplies in place the current Vector4 by the given one.
  66865. * @param otherVector vector to multiple with
  66866. * @returns the updated Vector4.
  66867. */
  66868. multiplyInPlace(otherVector: Vector4): Vector4;
  66869. /**
  66870. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66871. * @param otherVector vector to multiple with
  66872. * @returns resulting new vector
  66873. */
  66874. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66875. /**
  66876. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66877. * @param otherVector vector to multiple with
  66878. * @param result vector to store the result
  66879. * @returns the current Vector4.
  66880. */
  66881. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66882. /**
  66883. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66884. * @param x x value multiply with
  66885. * @param y y value multiply with
  66886. * @param z z value multiply with
  66887. * @param w w value multiply with
  66888. * @returns resulting new vector
  66889. */
  66890. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66891. /**
  66892. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66893. * @param otherVector vector to devide with
  66894. * @returns resulting new vector
  66895. */
  66896. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66897. /**
  66898. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66899. * @param otherVector vector to devide with
  66900. * @param result vector to store the result
  66901. * @returns the current Vector4.
  66902. */
  66903. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66904. /**
  66905. * Divides the current Vector3 coordinates by the given ones.
  66906. * @param otherVector vector to devide with
  66907. * @returns the updated Vector3.
  66908. */
  66909. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66910. /**
  66911. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66912. * @param other defines the second operand
  66913. * @returns the current updated Vector4
  66914. */
  66915. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66916. /**
  66917. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66918. * @param other defines the second operand
  66919. * @returns the current updated Vector4
  66920. */
  66921. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66922. /**
  66923. * Gets a new Vector4 from current Vector4 floored values
  66924. * @returns a new Vector4
  66925. */
  66926. floor(): Vector4;
  66927. /**
  66928. * Gets a new Vector4 from current Vector3 floored values
  66929. * @returns a new Vector4
  66930. */
  66931. fract(): Vector4;
  66932. /**
  66933. * Returns the Vector4 length (float).
  66934. * @returns the length
  66935. */
  66936. length(): number;
  66937. /**
  66938. * Returns the Vector4 squared length (float).
  66939. * @returns the length squared
  66940. */
  66941. lengthSquared(): number;
  66942. /**
  66943. * Normalizes in place the Vector4.
  66944. * @returns the updated Vector4.
  66945. */
  66946. normalize(): Vector4;
  66947. /**
  66948. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66949. * @returns this converted to a new vector3
  66950. */
  66951. toVector3(): Vector3;
  66952. /**
  66953. * Returns a new Vector4 copied from the current one.
  66954. * @returns the new cloned vector
  66955. */
  66956. clone(): Vector4;
  66957. /**
  66958. * Updates the current Vector4 with the given one coordinates.
  66959. * @param source the source vector to copy from
  66960. * @returns the updated Vector4.
  66961. */
  66962. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66963. /**
  66964. * Updates the current Vector4 coordinates with the given floats.
  66965. * @param x float to copy from
  66966. * @param y float to copy from
  66967. * @param z float to copy from
  66968. * @param w float to copy from
  66969. * @returns the updated Vector4.
  66970. */
  66971. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66972. /**
  66973. * Updates the current Vector4 coordinates with the given floats.
  66974. * @param x float to set from
  66975. * @param y float to set from
  66976. * @param z float to set from
  66977. * @param w float to set from
  66978. * @returns the updated Vector4.
  66979. */
  66980. set(x: number, y: number, z: number, w: number): Vector4;
  66981. /**
  66982. * Copies the given float to the current Vector3 coordinates
  66983. * @param v defines the x, y, z and w coordinates of the operand
  66984. * @returns the current updated Vector3
  66985. */
  66986. setAll(v: number): Vector4;
  66987. /**
  66988. * Returns a new Vector4 set from the starting index of the given array.
  66989. * @param array the array to pull values from
  66990. * @param offset the offset into the array to start at
  66991. * @returns the new vector
  66992. */
  66993. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66994. /**
  66995. * Updates the given vector "result" from the starting index of the given array.
  66996. * @param array the array to pull values from
  66997. * @param offset the offset into the array to start at
  66998. * @param result the vector to store the result in
  66999. */
  67000. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  67001. /**
  67002. * Updates the given vector "result" from the starting index of the given Float32Array.
  67003. * @param array the array to pull values from
  67004. * @param offset the offset into the array to start at
  67005. * @param result the vector to store the result in
  67006. */
  67007. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  67008. /**
  67009. * Updates the given vector "result" coordinates from the given floats.
  67010. * @param x float to set from
  67011. * @param y float to set from
  67012. * @param z float to set from
  67013. * @param w float to set from
  67014. * @param result the vector to the floats in
  67015. */
  67016. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  67017. /**
  67018. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  67019. * @returns the new vector
  67020. */
  67021. static Zero(): Vector4;
  67022. /**
  67023. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  67024. * @returns the new vector
  67025. */
  67026. static One(): Vector4;
  67027. /**
  67028. * Returns a new normalized Vector4 from the given one.
  67029. * @param vector the vector to normalize
  67030. * @returns the vector
  67031. */
  67032. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  67033. /**
  67034. * Updates the given vector "result" from the normalization of the given one.
  67035. * @param vector the vector to normalize
  67036. * @param result the vector to store the result in
  67037. */
  67038. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  67039. /**
  67040. * Returns a vector with the minimum values from the left and right vectors
  67041. * @param left left vector to minimize
  67042. * @param right right vector to minimize
  67043. * @returns a new vector with the minimum of the left and right vector values
  67044. */
  67045. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67046. /**
  67047. * Returns a vector with the maximum values from the left and right vectors
  67048. * @param left left vector to maximize
  67049. * @param right right vector to maximize
  67050. * @returns a new vector with the maximum of the left and right vector values
  67051. */
  67052. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  67053. /**
  67054. * Returns the distance (float) between the vectors "value1" and "value2".
  67055. * @param value1 value to calulate the distance between
  67056. * @param value2 value to calulate the distance between
  67057. * @return the distance between the two vectors
  67058. */
  67059. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67060. /**
  67061. * Returns the squared distance (float) between the vectors "value1" and "value2".
  67062. * @param value1 value to calulate the distance between
  67063. * @param value2 value to calulate the distance between
  67064. * @return the distance between the two vectors squared
  67065. */
  67066. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  67067. /**
  67068. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  67069. * @param value1 value to calulate the center between
  67070. * @param value2 value to calulate the center between
  67071. * @return the center between the two vectors
  67072. */
  67073. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  67074. /**
  67075. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  67076. * This methods computes transformed normalized direction vectors only.
  67077. * @param vector the vector to transform
  67078. * @param transformation the transformation matrix to apply
  67079. * @returns the new vector
  67080. */
  67081. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  67082. /**
  67083. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  67084. * This methods computes transformed normalized direction vectors only.
  67085. * @param vector the vector to transform
  67086. * @param transformation the transformation matrix to apply
  67087. * @param result the vector to store the result in
  67088. */
  67089. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67090. /**
  67091. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  67092. * This methods computes transformed normalized direction vectors only.
  67093. * @param x value to transform
  67094. * @param y value to transform
  67095. * @param z value to transform
  67096. * @param w value to transform
  67097. * @param transformation the transformation matrix to apply
  67098. * @param result the vector to store the results in
  67099. */
  67100. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  67101. /**
  67102. * Creates a new Vector4 from a Vector3
  67103. * @param source defines the source data
  67104. * @param w defines the 4th component (default is 0)
  67105. * @returns a new Vector4
  67106. */
  67107. static FromVector3(source: Vector3, w?: number): Vector4;
  67108. }
  67109. /**
  67110. * Class used to store quaternion data
  67111. * @see https://en.wikipedia.org/wiki/Quaternion
  67112. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  67113. */
  67114. export class Quaternion {
  67115. /** defines the first component (0 by default) */
  67116. x: number;
  67117. /** defines the second component (0 by default) */
  67118. y: number;
  67119. /** defines the third component (0 by default) */
  67120. z: number;
  67121. /** defines the fourth component (1.0 by default) */
  67122. w: number;
  67123. /**
  67124. * Creates a new Quaternion from the given floats
  67125. * @param x defines the first component (0 by default)
  67126. * @param y defines the second component (0 by default)
  67127. * @param z defines the third component (0 by default)
  67128. * @param w defines the fourth component (1.0 by default)
  67129. */
  67130. constructor(
  67131. /** defines the first component (0 by default) */
  67132. x?: number,
  67133. /** defines the second component (0 by default) */
  67134. y?: number,
  67135. /** defines the third component (0 by default) */
  67136. z?: number,
  67137. /** defines the fourth component (1.0 by default) */
  67138. w?: number);
  67139. /**
  67140. * Gets a string representation for the current quaternion
  67141. * @returns a string with the Quaternion coordinates
  67142. */
  67143. toString(): string;
  67144. /**
  67145. * Gets the class name of the quaternion
  67146. * @returns the string "Quaternion"
  67147. */
  67148. getClassName(): string;
  67149. /**
  67150. * Gets a hash code for this quaternion
  67151. * @returns the quaternion hash code
  67152. */
  67153. getHashCode(): number;
  67154. /**
  67155. * Copy the quaternion to an array
  67156. * @returns a new array populated with 4 elements from the quaternion coordinates
  67157. */
  67158. asArray(): number[];
  67159. /**
  67160. * Check if two quaternions are equals
  67161. * @param otherQuaternion defines the second operand
  67162. * @return true if the current quaternion and the given one coordinates are strictly equals
  67163. */
  67164. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  67165. /**
  67166. * Clone the current quaternion
  67167. * @returns a new quaternion copied from the current one
  67168. */
  67169. clone(): Quaternion;
  67170. /**
  67171. * Copy a quaternion to the current one
  67172. * @param other defines the other quaternion
  67173. * @returns the updated current quaternion
  67174. */
  67175. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  67176. /**
  67177. * Updates the current quaternion with the given float coordinates
  67178. * @param x defines the x coordinate
  67179. * @param y defines the y coordinate
  67180. * @param z defines the z coordinate
  67181. * @param w defines the w coordinate
  67182. * @returns the updated current quaternion
  67183. */
  67184. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  67185. /**
  67186. * Updates the current quaternion from the given float coordinates
  67187. * @param x defines the x coordinate
  67188. * @param y defines the y coordinate
  67189. * @param z defines the z coordinate
  67190. * @param w defines the w coordinate
  67191. * @returns the updated current quaternion
  67192. */
  67193. set(x: number, y: number, z: number, w: number): Quaternion;
  67194. /**
  67195. * Adds two quaternions
  67196. * @param other defines the second operand
  67197. * @returns a new quaternion as the addition result of the given one and the current quaternion
  67198. */
  67199. add(other: DeepImmutable<Quaternion>): Quaternion;
  67200. /**
  67201. * Add a quaternion to the current one
  67202. * @param other defines the quaternion to add
  67203. * @returns the current quaternion
  67204. */
  67205. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  67206. /**
  67207. * Subtract two quaternions
  67208. * @param other defines the second operand
  67209. * @returns a new quaternion as the subtraction result of the given one from the current one
  67210. */
  67211. subtract(other: Quaternion): Quaternion;
  67212. /**
  67213. * Multiplies the current quaternion by a scale factor
  67214. * @param value defines the scale factor
  67215. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  67216. */
  67217. scale(value: number): Quaternion;
  67218. /**
  67219. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  67220. * @param scale defines the scale factor
  67221. * @param result defines the Quaternion object where to store the result
  67222. * @returns the unmodified current quaternion
  67223. */
  67224. scaleToRef(scale: number, result: Quaternion): Quaternion;
  67225. /**
  67226. * Multiplies in place the current quaternion by a scale factor
  67227. * @param value defines the scale factor
  67228. * @returns the current modified quaternion
  67229. */
  67230. scaleInPlace(value: number): Quaternion;
  67231. /**
  67232. * Scale the current quaternion values by a factor and add the result to a given quaternion
  67233. * @param scale defines the scale factor
  67234. * @param result defines the Quaternion object where to store the result
  67235. * @returns the unmodified current quaternion
  67236. */
  67237. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  67238. /**
  67239. * Multiplies two quaternions
  67240. * @param q1 defines the second operand
  67241. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  67242. */
  67243. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  67244. /**
  67245. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  67246. * @param q1 defines the second operand
  67247. * @param result defines the target quaternion
  67248. * @returns the current quaternion
  67249. */
  67250. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  67251. /**
  67252. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  67253. * @param q1 defines the second operand
  67254. * @returns the currentupdated quaternion
  67255. */
  67256. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  67257. /**
  67258. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  67259. * @param ref defines the target quaternion
  67260. * @returns the current quaternion
  67261. */
  67262. conjugateToRef(ref: Quaternion): Quaternion;
  67263. /**
  67264. * Conjugates in place (1-q) the current quaternion
  67265. * @returns the current updated quaternion
  67266. */
  67267. conjugateInPlace(): Quaternion;
  67268. /**
  67269. * Conjugates in place (1-q) the current quaternion
  67270. * @returns a new quaternion
  67271. */
  67272. conjugate(): Quaternion;
  67273. /**
  67274. * Gets length of current quaternion
  67275. * @returns the quaternion length (float)
  67276. */
  67277. length(): number;
  67278. /**
  67279. * Normalize in place the current quaternion
  67280. * @returns the current updated quaternion
  67281. */
  67282. normalize(): Quaternion;
  67283. /**
  67284. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  67285. * @param order is a reserved parameter and is ignore for now
  67286. * @returns a new Vector3 containing the Euler angles
  67287. */
  67288. toEulerAngles(order?: string): Vector3;
  67289. /**
  67290. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  67291. * @param result defines the vector which will be filled with the Euler angles
  67292. * @param order is a reserved parameter and is ignore for now
  67293. * @returns the current unchanged quaternion
  67294. */
  67295. toEulerAnglesToRef(result: Vector3): Quaternion;
  67296. /**
  67297. * Updates the given rotation matrix with the current quaternion values
  67298. * @param result defines the target matrix
  67299. * @returns the current unchanged quaternion
  67300. */
  67301. toRotationMatrix(result: Matrix): Quaternion;
  67302. /**
  67303. * Updates the current quaternion from the given rotation matrix values
  67304. * @param matrix defines the source matrix
  67305. * @returns the current updated quaternion
  67306. */
  67307. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67308. /**
  67309. * Creates a new quaternion from a rotation matrix
  67310. * @param matrix defines the source matrix
  67311. * @returns a new quaternion created from the given rotation matrix values
  67312. */
  67313. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67314. /**
  67315. * Updates the given quaternion with the given rotation matrix values
  67316. * @param matrix defines the source matrix
  67317. * @param result defines the target quaternion
  67318. */
  67319. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67320. /**
  67321. * Returns the dot product (float) between the quaternions "left" and "right"
  67322. * @param left defines the left operand
  67323. * @param right defines the right operand
  67324. * @returns the dot product
  67325. */
  67326. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67327. /**
  67328. * Checks if the two quaternions are close to each other
  67329. * @param quat0 defines the first quaternion to check
  67330. * @param quat1 defines the second quaternion to check
  67331. * @returns true if the two quaternions are close to each other
  67332. */
  67333. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67334. /**
  67335. * Creates an empty quaternion
  67336. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67337. */
  67338. static Zero(): Quaternion;
  67339. /**
  67340. * Inverse a given quaternion
  67341. * @param q defines the source quaternion
  67342. * @returns a new quaternion as the inverted current quaternion
  67343. */
  67344. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67345. /**
  67346. * Inverse a given quaternion
  67347. * @param q defines the source quaternion
  67348. * @param result the quaternion the result will be stored in
  67349. * @returns the result quaternion
  67350. */
  67351. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67352. /**
  67353. * Creates an identity quaternion
  67354. * @returns the identity quaternion
  67355. */
  67356. static Identity(): Quaternion;
  67357. /**
  67358. * Gets a boolean indicating if the given quaternion is identity
  67359. * @param quaternion defines the quaternion to check
  67360. * @returns true if the quaternion is identity
  67361. */
  67362. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67363. /**
  67364. * Creates a quaternion from a rotation around an axis
  67365. * @param axis defines the axis to use
  67366. * @param angle defines the angle to use
  67367. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67368. */
  67369. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67370. /**
  67371. * Creates a rotation around an axis and stores it into the given quaternion
  67372. * @param axis defines the axis to use
  67373. * @param angle defines the angle to use
  67374. * @param result defines the target quaternion
  67375. * @returns the target quaternion
  67376. */
  67377. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67378. /**
  67379. * Creates a new quaternion from data stored into an array
  67380. * @param array defines the data source
  67381. * @param offset defines the offset in the source array where the data starts
  67382. * @returns a new quaternion
  67383. */
  67384. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67385. /**
  67386. * Create a quaternion from Euler rotation angles
  67387. * @param x Pitch
  67388. * @param y Yaw
  67389. * @param z Roll
  67390. * @returns the new Quaternion
  67391. */
  67392. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67393. /**
  67394. * Updates a quaternion from Euler rotation angles
  67395. * @param x Pitch
  67396. * @param y Yaw
  67397. * @param z Roll
  67398. * @param result the quaternion to store the result
  67399. * @returns the updated quaternion
  67400. */
  67401. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67402. /**
  67403. * Create a quaternion from Euler rotation vector
  67404. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67405. * @returns the new Quaternion
  67406. */
  67407. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67408. /**
  67409. * Updates a quaternion from Euler rotation vector
  67410. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67411. * @param result the quaternion to store the result
  67412. * @returns the updated quaternion
  67413. */
  67414. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67415. /**
  67416. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67417. * @param yaw defines the rotation around Y axis
  67418. * @param pitch defines the rotation around X axis
  67419. * @param roll defines the rotation around Z axis
  67420. * @returns the new quaternion
  67421. */
  67422. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67423. /**
  67424. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67425. * @param yaw defines the rotation around Y axis
  67426. * @param pitch defines the rotation around X axis
  67427. * @param roll defines the rotation around Z axis
  67428. * @param result defines the target quaternion
  67429. */
  67430. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67431. /**
  67432. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67433. * @param alpha defines the rotation around first axis
  67434. * @param beta defines the rotation around second axis
  67435. * @param gamma defines the rotation around third axis
  67436. * @returns the new quaternion
  67437. */
  67438. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67439. /**
  67440. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67441. * @param alpha defines the rotation around first axis
  67442. * @param beta defines the rotation around second axis
  67443. * @param gamma defines the rotation around third axis
  67444. * @param result defines the target quaternion
  67445. */
  67446. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67447. /**
  67448. * 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)
  67449. * @param axis1 defines the first axis
  67450. * @param axis2 defines the second axis
  67451. * @param axis3 defines the third axis
  67452. * @returns the new quaternion
  67453. */
  67454. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67455. /**
  67456. * 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
  67457. * @param axis1 defines the first axis
  67458. * @param axis2 defines the second axis
  67459. * @param axis3 defines the third axis
  67460. * @param ref defines the target quaternion
  67461. */
  67462. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67463. /**
  67464. * Interpolates between two quaternions
  67465. * @param left defines first quaternion
  67466. * @param right defines second quaternion
  67467. * @param amount defines the gradient to use
  67468. * @returns the new interpolated quaternion
  67469. */
  67470. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67471. /**
  67472. * Interpolates between two quaternions and stores it into a target quaternion
  67473. * @param left defines first quaternion
  67474. * @param right defines second quaternion
  67475. * @param amount defines the gradient to use
  67476. * @param result defines the target quaternion
  67477. */
  67478. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67479. /**
  67480. * Interpolate between two quaternions using Hermite interpolation
  67481. * @param value1 defines first quaternion
  67482. * @param tangent1 defines the incoming tangent
  67483. * @param value2 defines second quaternion
  67484. * @param tangent2 defines the outgoing tangent
  67485. * @param amount defines the target quaternion
  67486. * @returns the new interpolated quaternion
  67487. */
  67488. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67489. }
  67490. /**
  67491. * Class used to store matrix data (4x4)
  67492. */
  67493. export class Matrix {
  67494. private static _updateFlagSeed;
  67495. private static _identityReadOnly;
  67496. private _isIdentity;
  67497. private _isIdentityDirty;
  67498. private _isIdentity3x2;
  67499. private _isIdentity3x2Dirty;
  67500. /**
  67501. * Gets the update flag of the matrix which is an unique number for the matrix.
  67502. * It will be incremented every time the matrix data change.
  67503. * You can use it to speed the comparison between two versions of the same matrix.
  67504. */
  67505. updateFlag: number;
  67506. private readonly _m;
  67507. /**
  67508. * Gets the internal data of the matrix
  67509. */
  67510. readonly m: DeepImmutable<Float32Array>;
  67511. /** @hidden */
  67512. _markAsUpdated(): void;
  67513. /** @hidden */
  67514. private _updateIdentityStatus;
  67515. /**
  67516. * Creates an empty matrix (filled with zeros)
  67517. */
  67518. constructor();
  67519. /**
  67520. * Check if the current matrix is identity
  67521. * @returns true is the matrix is the identity matrix
  67522. */
  67523. isIdentity(): boolean;
  67524. /**
  67525. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67526. * @returns true is the matrix is the identity matrix
  67527. */
  67528. isIdentityAs3x2(): boolean;
  67529. /**
  67530. * Gets the determinant of the matrix
  67531. * @returns the matrix determinant
  67532. */
  67533. determinant(): number;
  67534. /**
  67535. * Returns the matrix as a Float32Array
  67536. * @returns the matrix underlying array
  67537. */
  67538. toArray(): DeepImmutable<Float32Array>;
  67539. /**
  67540. * Returns the matrix as a Float32Array
  67541. * @returns the matrix underlying array.
  67542. */
  67543. asArray(): DeepImmutable<Float32Array>;
  67544. /**
  67545. * Inverts the current matrix in place
  67546. * @returns the current inverted matrix
  67547. */
  67548. invert(): Matrix;
  67549. /**
  67550. * Sets all the matrix elements to zero
  67551. * @returns the current matrix
  67552. */
  67553. reset(): Matrix;
  67554. /**
  67555. * Adds the current matrix with a second one
  67556. * @param other defines the matrix to add
  67557. * @returns a new matrix as the addition of the current matrix and the given one
  67558. */
  67559. add(other: DeepImmutable<Matrix>): Matrix;
  67560. /**
  67561. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67562. * @param other defines the matrix to add
  67563. * @param result defines the target matrix
  67564. * @returns the current matrix
  67565. */
  67566. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67567. /**
  67568. * Adds in place the given matrix to the current matrix
  67569. * @param other defines the second operand
  67570. * @returns the current updated matrix
  67571. */
  67572. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67573. /**
  67574. * Sets the given matrix to the current inverted Matrix
  67575. * @param other defines the target matrix
  67576. * @returns the unmodified current matrix
  67577. */
  67578. invertToRef(other: Matrix): Matrix;
  67579. /**
  67580. * add a value at the specified position in the current Matrix
  67581. * @param index the index of the value within the matrix. between 0 and 15.
  67582. * @param value the value to be added
  67583. * @returns the current updated matrix
  67584. */
  67585. addAtIndex(index: number, value: number): Matrix;
  67586. /**
  67587. * mutiply the specified position in the current Matrix by a value
  67588. * @param index the index of the value within the matrix. between 0 and 15.
  67589. * @param value the value to be added
  67590. * @returns the current updated matrix
  67591. */
  67592. multiplyAtIndex(index: number, value: number): Matrix;
  67593. /**
  67594. * Inserts the translation vector (using 3 floats) in the current matrix
  67595. * @param x defines the 1st component of the translation
  67596. * @param y defines the 2nd component of the translation
  67597. * @param z defines the 3rd component of the translation
  67598. * @returns the current updated matrix
  67599. */
  67600. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67601. /**
  67602. * Adds the translation vector (using 3 floats) in the current matrix
  67603. * @param x defines the 1st component of the translation
  67604. * @param y defines the 2nd component of the translation
  67605. * @param z defines the 3rd component of the translation
  67606. * @returns the current updated matrix
  67607. */
  67608. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67609. /**
  67610. * Inserts the translation vector in the current matrix
  67611. * @param vector3 defines the translation to insert
  67612. * @returns the current updated matrix
  67613. */
  67614. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67615. /**
  67616. * Gets the translation value of the current matrix
  67617. * @returns a new Vector3 as the extracted translation from the matrix
  67618. */
  67619. getTranslation(): Vector3;
  67620. /**
  67621. * Fill a Vector3 with the extracted translation from the matrix
  67622. * @param result defines the Vector3 where to store the translation
  67623. * @returns the current matrix
  67624. */
  67625. getTranslationToRef(result: Vector3): Matrix;
  67626. /**
  67627. * Remove rotation and scaling part from the matrix
  67628. * @returns the updated matrix
  67629. */
  67630. removeRotationAndScaling(): Matrix;
  67631. /**
  67632. * Multiply two matrices
  67633. * @param other defines the second operand
  67634. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67635. */
  67636. multiply(other: DeepImmutable<Matrix>): Matrix;
  67637. /**
  67638. * Copy the current matrix from the given one
  67639. * @param other defines the source matrix
  67640. * @returns the current updated matrix
  67641. */
  67642. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67643. /**
  67644. * Populates the given array from the starting index with the current matrix values
  67645. * @param array defines the target array
  67646. * @param offset defines the offset in the target array where to start storing values
  67647. * @returns the current matrix
  67648. */
  67649. copyToArray(array: Float32Array, offset?: number): Matrix;
  67650. /**
  67651. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67652. * @param other defines the second operand
  67653. * @param result defines the matrix where to store the multiplication
  67654. * @returns the current matrix
  67655. */
  67656. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67657. /**
  67658. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67659. * @param other defines the second operand
  67660. * @param result defines the array where to store the multiplication
  67661. * @param offset defines the offset in the target array where to start storing values
  67662. * @returns the current matrix
  67663. */
  67664. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67665. /**
  67666. * Check equality between this matrix and a second one
  67667. * @param value defines the second matrix to compare
  67668. * @returns true is the current matrix and the given one values are strictly equal
  67669. */
  67670. equals(value: DeepImmutable<Matrix>): boolean;
  67671. /**
  67672. * Clone the current matrix
  67673. * @returns a new matrix from the current matrix
  67674. */
  67675. clone(): Matrix;
  67676. /**
  67677. * Returns the name of the current matrix class
  67678. * @returns the string "Matrix"
  67679. */
  67680. getClassName(): string;
  67681. /**
  67682. * Gets the hash code of the current matrix
  67683. * @returns the hash code
  67684. */
  67685. getHashCode(): number;
  67686. /**
  67687. * Decomposes the current Matrix into a translation, rotation and scaling components
  67688. * @param scale defines the scale vector3 given as a reference to update
  67689. * @param rotation defines the rotation quaternion given as a reference to update
  67690. * @param translation defines the translation vector3 given as a reference to update
  67691. * @returns true if operation was successful
  67692. */
  67693. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67694. /**
  67695. * Gets specific row of the matrix
  67696. * @param index defines the number of the row to get
  67697. * @returns the index-th row of the current matrix as a new Vector4
  67698. */
  67699. getRow(index: number): Nullable<Vector4>;
  67700. /**
  67701. * Sets the index-th row of the current matrix to the vector4 values
  67702. * @param index defines the number of the row to set
  67703. * @param row defines the target vector4
  67704. * @returns the updated current matrix
  67705. */
  67706. setRow(index: number, row: Vector4): Matrix;
  67707. /**
  67708. * Compute the transpose of the matrix
  67709. * @returns the new transposed matrix
  67710. */
  67711. transpose(): Matrix;
  67712. /**
  67713. * Compute the transpose of the matrix and store it in a given matrix
  67714. * @param result defines the target matrix
  67715. * @returns the current matrix
  67716. */
  67717. transposeToRef(result: Matrix): Matrix;
  67718. /**
  67719. * Sets the index-th row of the current matrix with the given 4 x float values
  67720. * @param index defines the row index
  67721. * @param x defines the x component to set
  67722. * @param y defines the y component to set
  67723. * @param z defines the z component to set
  67724. * @param w defines the w component to set
  67725. * @returns the updated current matrix
  67726. */
  67727. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67728. /**
  67729. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67730. * @param scale defines the scale factor
  67731. * @returns a new matrix
  67732. */
  67733. scale(scale: number): Matrix;
  67734. /**
  67735. * Scale the current matrix values by a factor to a given result matrix
  67736. * @param scale defines the scale factor
  67737. * @param result defines the matrix to store the result
  67738. * @returns the current matrix
  67739. */
  67740. scaleToRef(scale: number, result: Matrix): Matrix;
  67741. /**
  67742. * Scale the current matrix values by a factor and add the result to a given matrix
  67743. * @param scale defines the scale factor
  67744. * @param result defines the Matrix to store the result
  67745. * @returns the current matrix
  67746. */
  67747. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67748. /**
  67749. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67750. * @param ref matrix to store the result
  67751. */
  67752. toNormalMatrix(ref: Matrix): void;
  67753. /**
  67754. * Gets only rotation part of the current matrix
  67755. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67756. */
  67757. getRotationMatrix(): Matrix;
  67758. /**
  67759. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67760. * @param result defines the target matrix to store data to
  67761. * @returns the current matrix
  67762. */
  67763. getRotationMatrixToRef(result: Matrix): Matrix;
  67764. /**
  67765. * Toggles model matrix from being right handed to left handed in place and vice versa
  67766. */
  67767. toggleModelMatrixHandInPlace(): void;
  67768. /**
  67769. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67770. */
  67771. toggleProjectionMatrixHandInPlace(): void;
  67772. /**
  67773. * Creates a matrix from an array
  67774. * @param array defines the source array
  67775. * @param offset defines an offset in the source array
  67776. * @returns a new Matrix set from the starting index of the given array
  67777. */
  67778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67779. /**
  67780. * Copy the content of an array into a given matrix
  67781. * @param array defines the source array
  67782. * @param offset defines an offset in the source array
  67783. * @param result defines the target matrix
  67784. */
  67785. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67786. /**
  67787. * Stores an array into a matrix after having multiplied each component by a given factor
  67788. * @param array defines the source array
  67789. * @param offset defines the offset in the source array
  67790. * @param scale defines the scaling factor
  67791. * @param result defines the target matrix
  67792. */
  67793. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67794. /**
  67795. * Gets an identity matrix that must not be updated
  67796. */
  67797. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67798. /**
  67799. * Stores a list of values (16) inside a given matrix
  67800. * @param initialM11 defines 1st value of 1st row
  67801. * @param initialM12 defines 2nd value of 1st row
  67802. * @param initialM13 defines 3rd value of 1st row
  67803. * @param initialM14 defines 4th value of 1st row
  67804. * @param initialM21 defines 1st value of 2nd row
  67805. * @param initialM22 defines 2nd value of 2nd row
  67806. * @param initialM23 defines 3rd value of 2nd row
  67807. * @param initialM24 defines 4th value of 2nd row
  67808. * @param initialM31 defines 1st value of 3rd row
  67809. * @param initialM32 defines 2nd value of 3rd row
  67810. * @param initialM33 defines 3rd value of 3rd row
  67811. * @param initialM34 defines 4th value of 3rd row
  67812. * @param initialM41 defines 1st value of 4th row
  67813. * @param initialM42 defines 2nd value of 4th row
  67814. * @param initialM43 defines 3rd value of 4th row
  67815. * @param initialM44 defines 4th value of 4th row
  67816. * @param result defines the target matrix
  67817. */
  67818. 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;
  67819. /**
  67820. * Creates new matrix from a list of values (16)
  67821. * @param initialM11 defines 1st value of 1st row
  67822. * @param initialM12 defines 2nd value of 1st row
  67823. * @param initialM13 defines 3rd value of 1st row
  67824. * @param initialM14 defines 4th value of 1st row
  67825. * @param initialM21 defines 1st value of 2nd row
  67826. * @param initialM22 defines 2nd value of 2nd row
  67827. * @param initialM23 defines 3rd value of 2nd row
  67828. * @param initialM24 defines 4th value of 2nd row
  67829. * @param initialM31 defines 1st value of 3rd row
  67830. * @param initialM32 defines 2nd value of 3rd row
  67831. * @param initialM33 defines 3rd value of 3rd row
  67832. * @param initialM34 defines 4th value of 3rd row
  67833. * @param initialM41 defines 1st value of 4th row
  67834. * @param initialM42 defines 2nd value of 4th row
  67835. * @param initialM43 defines 3rd value of 4th row
  67836. * @param initialM44 defines 4th value of 4th row
  67837. * @returns the new matrix
  67838. */
  67839. 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;
  67840. /**
  67841. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67842. * @param scale defines the scale vector3
  67843. * @param rotation defines the rotation quaternion
  67844. * @param translation defines the translation vector3
  67845. * @returns a new matrix
  67846. */
  67847. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67848. /**
  67849. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67850. * @param scale defines the scale vector3
  67851. * @param rotation defines the rotation quaternion
  67852. * @param translation defines the translation vector3
  67853. * @param result defines the target matrix
  67854. */
  67855. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67856. /**
  67857. * Creates a new identity matrix
  67858. * @returns a new identity matrix
  67859. */
  67860. static Identity(): Matrix;
  67861. /**
  67862. * Creates a new identity matrix and stores the result in a given matrix
  67863. * @param result defines the target matrix
  67864. */
  67865. static IdentityToRef(result: Matrix): void;
  67866. /**
  67867. * Creates a new zero matrix
  67868. * @returns a new zero matrix
  67869. */
  67870. static Zero(): Matrix;
  67871. /**
  67872. * Creates a new rotation matrix for "angle" radians around the X axis
  67873. * @param angle defines the angle (in radians) to use
  67874. * @return the new matrix
  67875. */
  67876. static RotationX(angle: number): Matrix;
  67877. /**
  67878. * Creates a new matrix as the invert of a given matrix
  67879. * @param source defines the source matrix
  67880. * @returns the new matrix
  67881. */
  67882. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67883. /**
  67884. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67885. * @param angle defines the angle (in radians) to use
  67886. * @param result defines the target matrix
  67887. */
  67888. static RotationXToRef(angle: number, result: Matrix): void;
  67889. /**
  67890. * Creates a new rotation matrix for "angle" radians around the Y axis
  67891. * @param angle defines the angle (in radians) to use
  67892. * @return the new matrix
  67893. */
  67894. static RotationY(angle: number): Matrix;
  67895. /**
  67896. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67897. * @param angle defines the angle (in radians) to use
  67898. * @param result defines the target matrix
  67899. */
  67900. static RotationYToRef(angle: number, result: Matrix): void;
  67901. /**
  67902. * Creates a new rotation matrix for "angle" radians around the Z axis
  67903. * @param angle defines the angle (in radians) to use
  67904. * @return the new matrix
  67905. */
  67906. static RotationZ(angle: number): Matrix;
  67907. /**
  67908. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67909. * @param angle defines the angle (in radians) to use
  67910. * @param result defines the target matrix
  67911. */
  67912. static RotationZToRef(angle: number, result: Matrix): void;
  67913. /**
  67914. * Creates a new rotation matrix for "angle" radians around the given axis
  67915. * @param axis defines the axis to use
  67916. * @param angle defines the angle (in radians) to use
  67917. * @return the new matrix
  67918. */
  67919. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67920. /**
  67921. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67922. * @param axis defines the axis to use
  67923. * @param angle defines the angle (in radians) to use
  67924. * @param result defines the target matrix
  67925. */
  67926. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67927. /**
  67928. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67929. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67930. * @param from defines the vector to align
  67931. * @param to defines the vector to align to
  67932. * @param result defines the target matrix
  67933. */
  67934. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67935. /**
  67936. * Creates a rotation matrix
  67937. * @param yaw defines the yaw angle in radians (Y axis)
  67938. * @param pitch defines the pitch angle in radians (X axis)
  67939. * @param roll defines the roll angle in radians (X axis)
  67940. * @returns the new rotation matrix
  67941. */
  67942. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67943. /**
  67944. * Creates a rotation matrix and stores it in a given matrix
  67945. * @param yaw defines the yaw angle in radians (Y axis)
  67946. * @param pitch defines the pitch angle in radians (X axis)
  67947. * @param roll defines the roll angle in radians (X axis)
  67948. * @param result defines the target matrix
  67949. */
  67950. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67951. /**
  67952. * Creates a scaling matrix
  67953. * @param x defines the scale factor on X axis
  67954. * @param y defines the scale factor on Y axis
  67955. * @param z defines the scale factor on Z axis
  67956. * @returns the new matrix
  67957. */
  67958. static Scaling(x: number, y: number, z: number): Matrix;
  67959. /**
  67960. * Creates a scaling matrix and stores it in a given matrix
  67961. * @param x defines the scale factor on X axis
  67962. * @param y defines the scale factor on Y axis
  67963. * @param z defines the scale factor on Z axis
  67964. * @param result defines the target matrix
  67965. */
  67966. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67967. /**
  67968. * Creates a translation matrix
  67969. * @param x defines the translation on X axis
  67970. * @param y defines the translation on Y axis
  67971. * @param z defines the translationon Z axis
  67972. * @returns the new matrix
  67973. */
  67974. static Translation(x: number, y: number, z: number): Matrix;
  67975. /**
  67976. * Creates a translation matrix and stores it in a given matrix
  67977. * @param x defines the translation on X axis
  67978. * @param y defines the translation on Y axis
  67979. * @param z defines the translationon Z axis
  67980. * @param result defines the target matrix
  67981. */
  67982. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67983. /**
  67984. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67985. * @param startValue defines the start value
  67986. * @param endValue defines the end value
  67987. * @param gradient defines the gradient factor
  67988. * @returns the new matrix
  67989. */
  67990. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67991. /**
  67992. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67993. * @param startValue defines the start value
  67994. * @param endValue defines the end value
  67995. * @param gradient defines the gradient factor
  67996. * @param result defines the Matrix object where to store data
  67997. */
  67998. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67999. /**
  68000. * Builds a new matrix whose values are computed by:
  68001. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68002. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68003. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68004. * @param startValue defines the first matrix
  68005. * @param endValue defines the second matrix
  68006. * @param gradient defines the gradient between the two matrices
  68007. * @returns the new matrix
  68008. */
  68009. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  68010. /**
  68011. * Update a matrix to values which are computed by:
  68012. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  68013. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  68014. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  68015. * @param startValue defines the first matrix
  68016. * @param endValue defines the second matrix
  68017. * @param gradient defines the gradient between the two matrices
  68018. * @param result defines the target matrix
  68019. */
  68020. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  68021. /**
  68022. * 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"
  68023. * This function works in left handed mode
  68024. * @param eye defines the final position of the entity
  68025. * @param target defines where the entity should look at
  68026. * @param up defines the up vector for the entity
  68027. * @returns the new matrix
  68028. */
  68029. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68030. /**
  68031. * 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".
  68032. * This function works in left handed mode
  68033. * @param eye defines the final position of the entity
  68034. * @param target defines where the entity should look at
  68035. * @param up defines the up vector for the entity
  68036. * @param result defines the target matrix
  68037. */
  68038. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68039. /**
  68040. * 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"
  68041. * This function works in right handed mode
  68042. * @param eye defines the final position of the entity
  68043. * @param target defines where the entity should look at
  68044. * @param up defines the up vector for the entity
  68045. * @returns the new matrix
  68046. */
  68047. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  68048. /**
  68049. * 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".
  68050. * This function works in right handed mode
  68051. * @param eye defines the final position of the entity
  68052. * @param target defines where the entity should look at
  68053. * @param up defines the up vector for the entity
  68054. * @param result defines the target matrix
  68055. */
  68056. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  68057. /**
  68058. * Create a left-handed orthographic projection matrix
  68059. * @param width defines the viewport width
  68060. * @param height defines the viewport height
  68061. * @param znear defines the near clip plane
  68062. * @param zfar defines the far clip plane
  68063. * @returns a new matrix as a left-handed orthographic projection matrix
  68064. */
  68065. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68066. /**
  68067. * Store a left-handed orthographic projection to a given matrix
  68068. * @param width defines the viewport width
  68069. * @param height defines the viewport height
  68070. * @param znear defines the near clip plane
  68071. * @param zfar defines the far clip plane
  68072. * @param result defines the target matrix
  68073. */
  68074. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  68075. /**
  68076. * Create a left-handed orthographic projection matrix
  68077. * @param left defines the viewport left coordinate
  68078. * @param right defines the viewport right coordinate
  68079. * @param bottom defines the viewport bottom coordinate
  68080. * @param top defines the viewport top coordinate
  68081. * @param znear defines the near clip plane
  68082. * @param zfar defines the far clip plane
  68083. * @returns a new matrix as a left-handed orthographic projection matrix
  68084. */
  68085. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68086. /**
  68087. * Stores a left-handed orthographic projection into a given matrix
  68088. * @param left defines the viewport left coordinate
  68089. * @param right defines the viewport right coordinate
  68090. * @param bottom defines the viewport bottom coordinate
  68091. * @param top defines the viewport top coordinate
  68092. * @param znear defines the near clip plane
  68093. * @param zfar defines the far clip plane
  68094. * @param result defines the target matrix
  68095. */
  68096. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68097. /**
  68098. * Creates a right-handed orthographic projection matrix
  68099. * @param left defines the viewport left coordinate
  68100. * @param right defines the viewport right coordinate
  68101. * @param bottom defines the viewport bottom coordinate
  68102. * @param top defines the viewport top coordinate
  68103. * @param znear defines the near clip plane
  68104. * @param zfar defines the far clip plane
  68105. * @returns a new matrix as a right-handed orthographic projection matrix
  68106. */
  68107. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  68108. /**
  68109. * Stores a right-handed orthographic projection into a given matrix
  68110. * @param left defines the viewport left coordinate
  68111. * @param right defines the viewport right coordinate
  68112. * @param bottom defines the viewport bottom coordinate
  68113. * @param top defines the viewport top coordinate
  68114. * @param znear defines the near clip plane
  68115. * @param zfar defines the far clip plane
  68116. * @param result defines the target matrix
  68117. */
  68118. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  68119. /**
  68120. * Creates a left-handed perspective projection matrix
  68121. * @param width defines the viewport width
  68122. * @param height defines the viewport height
  68123. * @param znear defines the near clip plane
  68124. * @param zfar defines the far clip plane
  68125. * @returns a new matrix as a left-handed perspective projection matrix
  68126. */
  68127. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  68128. /**
  68129. * Creates a left-handed perspective projection matrix
  68130. * @param fov defines the horizontal field of view
  68131. * @param aspect defines the aspect ratio
  68132. * @param znear defines the near clip plane
  68133. * @param zfar defines the far clip plane
  68134. * @returns a new matrix as a left-handed perspective projection matrix
  68135. */
  68136. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68137. /**
  68138. * Stores a left-handed perspective projection into a given matrix
  68139. * @param fov defines the horizontal field of view
  68140. * @param aspect defines the aspect ratio
  68141. * @param znear defines the near clip plane
  68142. * @param zfar defines the far clip plane
  68143. * @param result defines the target matrix
  68144. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68145. */
  68146. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68147. /**
  68148. * Creates a right-handed perspective projection matrix
  68149. * @param fov defines the horizontal field of view
  68150. * @param aspect defines the aspect ratio
  68151. * @param znear defines the near clip plane
  68152. * @param zfar defines the far clip plane
  68153. * @returns a new matrix as a right-handed perspective projection matrix
  68154. */
  68155. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  68156. /**
  68157. * Stores a right-handed perspective projection into a given matrix
  68158. * @param fov defines the horizontal field of view
  68159. * @param aspect defines the aspect ratio
  68160. * @param znear defines the near clip plane
  68161. * @param zfar defines the far clip plane
  68162. * @param result defines the target matrix
  68163. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  68164. */
  68165. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  68166. /**
  68167. * Stores a perspective projection for WebVR info a given matrix
  68168. * @param fov defines the field of view
  68169. * @param znear defines the near clip plane
  68170. * @param zfar defines the far clip plane
  68171. * @param result defines the target matrix
  68172. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  68173. */
  68174. static PerspectiveFovWebVRToRef(fov: {
  68175. upDegrees: number;
  68176. downDegrees: number;
  68177. leftDegrees: number;
  68178. rightDegrees: number;
  68179. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  68180. /**
  68181. * Computes a complete transformation matrix
  68182. * @param viewport defines the viewport to use
  68183. * @param world defines the world matrix
  68184. * @param view defines the view matrix
  68185. * @param projection defines the projection matrix
  68186. * @param zmin defines the near clip plane
  68187. * @param zmax defines the far clip plane
  68188. * @returns the transformation matrix
  68189. */
  68190. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  68191. /**
  68192. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  68193. * @param matrix defines the matrix to use
  68194. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  68195. */
  68196. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  68197. /**
  68198. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  68199. * @param matrix defines the matrix to use
  68200. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  68201. */
  68202. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  68203. /**
  68204. * Compute the transpose of a given matrix
  68205. * @param matrix defines the matrix to transpose
  68206. * @returns the new matrix
  68207. */
  68208. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  68209. /**
  68210. * Compute the transpose of a matrix and store it in a target matrix
  68211. * @param matrix defines the matrix to transpose
  68212. * @param result defines the target matrix
  68213. */
  68214. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  68215. /**
  68216. * Computes a reflection matrix from a plane
  68217. * @param plane defines the reflection plane
  68218. * @returns a new matrix
  68219. */
  68220. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  68221. /**
  68222. * Computes a reflection matrix from a plane
  68223. * @param plane defines the reflection plane
  68224. * @param result defines the target matrix
  68225. */
  68226. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  68227. /**
  68228. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  68229. * @param xaxis defines the value of the 1st axis
  68230. * @param yaxis defines the value of the 2nd axis
  68231. * @param zaxis defines the value of the 3rd axis
  68232. * @param result defines the target matrix
  68233. */
  68234. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  68235. /**
  68236. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  68237. * @param quat defines the quaternion to use
  68238. * @param result defines the target matrix
  68239. */
  68240. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  68241. }
  68242. /**
  68243. * @hidden
  68244. */
  68245. export class TmpVectors {
  68246. static Vector2: Vector2[];
  68247. static Vector3: Vector3[];
  68248. static Vector4: Vector4[];
  68249. static Quaternion: Quaternion[];
  68250. static Matrix: Matrix[];
  68251. }
  68252. }
  68253. declare module BABYLON {
  68254. /** Defines the cross module used constants to avoid circular dependncies */
  68255. export class Constants {
  68256. /** Defines that alpha blending is disabled */
  68257. static readonly ALPHA_DISABLE: number;
  68258. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68259. static readonly ALPHA_ADD: number;
  68260. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68261. static readonly ALPHA_COMBINE: number;
  68262. /** Defines that alpha blending to DEST - SRC * DEST */
  68263. static readonly ALPHA_SUBTRACT: number;
  68264. /** Defines that alpha blending to SRC * DEST */
  68265. static readonly ALPHA_MULTIPLY: number;
  68266. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  68267. static readonly ALPHA_MAXIMIZED: number;
  68268. /** Defines that alpha blending to SRC + DEST */
  68269. static readonly ALPHA_ONEONE: number;
  68270. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  68271. static readonly ALPHA_PREMULTIPLIED: number;
  68272. /**
  68273. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  68274. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  68275. */
  68276. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  68277. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  68278. static readonly ALPHA_INTERPOLATE: number;
  68279. /**
  68280. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  68281. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  68282. */
  68283. static readonly ALPHA_SCREENMODE: number;
  68284. /** Defines that the ressource is not delayed*/
  68285. static readonly DELAYLOADSTATE_NONE: number;
  68286. /** Defines that the ressource was successfully delay loaded */
  68287. static readonly DELAYLOADSTATE_LOADED: number;
  68288. /** Defines that the ressource is currently delay loading */
  68289. static readonly DELAYLOADSTATE_LOADING: number;
  68290. /** Defines that the ressource is delayed and has not started loading */
  68291. static readonly DELAYLOADSTATE_NOTLOADED: number;
  68292. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  68293. static readonly NEVER: number;
  68294. /** 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 */
  68295. static readonly ALWAYS: number;
  68296. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  68297. static readonly LESS: number;
  68298. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  68299. static readonly EQUAL: number;
  68300. /** 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 */
  68301. static readonly LEQUAL: number;
  68302. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  68303. static readonly GREATER: number;
  68304. /** 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 */
  68305. static readonly GEQUAL: number;
  68306. /** 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 */
  68307. static readonly NOTEQUAL: number;
  68308. /** Passed to stencilOperation to specify that stencil value must be kept */
  68309. static readonly KEEP: number;
  68310. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68311. static readonly REPLACE: number;
  68312. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68313. static readonly INCR: number;
  68314. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68315. static readonly DECR: number;
  68316. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68317. static readonly INVERT: number;
  68318. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68319. static readonly INCR_WRAP: number;
  68320. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68321. static readonly DECR_WRAP: number;
  68322. /** Texture is not repeating outside of 0..1 UVs */
  68323. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68324. /** Texture is repeating outside of 0..1 UVs */
  68325. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68326. /** Texture is repeating and mirrored */
  68327. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68328. /** ALPHA */
  68329. static readonly TEXTUREFORMAT_ALPHA: number;
  68330. /** LUMINANCE */
  68331. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68332. /** LUMINANCE_ALPHA */
  68333. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68334. /** RGB */
  68335. static readonly TEXTUREFORMAT_RGB: number;
  68336. /** RGBA */
  68337. static readonly TEXTUREFORMAT_RGBA: number;
  68338. /** RED */
  68339. static readonly TEXTUREFORMAT_RED: number;
  68340. /** RED (2nd reference) */
  68341. static readonly TEXTUREFORMAT_R: number;
  68342. /** RG */
  68343. static readonly TEXTUREFORMAT_RG: number;
  68344. /** RED_INTEGER */
  68345. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68346. /** RED_INTEGER (2nd reference) */
  68347. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68348. /** RG_INTEGER */
  68349. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68350. /** RGB_INTEGER */
  68351. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68352. /** RGBA_INTEGER */
  68353. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68354. /** UNSIGNED_BYTE */
  68355. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68356. /** UNSIGNED_BYTE (2nd reference) */
  68357. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68358. /** FLOAT */
  68359. static readonly TEXTURETYPE_FLOAT: number;
  68360. /** HALF_FLOAT */
  68361. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68362. /** BYTE */
  68363. static readonly TEXTURETYPE_BYTE: number;
  68364. /** SHORT */
  68365. static readonly TEXTURETYPE_SHORT: number;
  68366. /** UNSIGNED_SHORT */
  68367. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68368. /** INT */
  68369. static readonly TEXTURETYPE_INT: number;
  68370. /** UNSIGNED_INT */
  68371. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68372. /** UNSIGNED_SHORT_4_4_4_4 */
  68373. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68374. /** UNSIGNED_SHORT_5_5_5_1 */
  68375. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68376. /** UNSIGNED_SHORT_5_6_5 */
  68377. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68378. /** UNSIGNED_INT_2_10_10_10_REV */
  68379. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68380. /** UNSIGNED_INT_24_8 */
  68381. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68382. /** UNSIGNED_INT_10F_11F_11F_REV */
  68383. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68384. /** UNSIGNED_INT_5_9_9_9_REV */
  68385. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68386. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68387. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68388. /** nearest is mag = nearest and min = nearest and mip = linear */
  68389. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68390. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68391. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68392. /** Trilinear is mag = linear and min = linear and mip = linear */
  68393. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68394. /** nearest is mag = nearest and min = nearest and mip = linear */
  68395. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68396. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68397. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68398. /** Trilinear is mag = linear and min = linear and mip = linear */
  68399. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68400. /** mag = nearest and min = nearest and mip = nearest */
  68401. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68402. /** mag = nearest and min = linear and mip = nearest */
  68403. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68404. /** mag = nearest and min = linear and mip = linear */
  68405. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68406. /** mag = nearest and min = linear and mip = none */
  68407. static readonly TEXTURE_NEAREST_LINEAR: number;
  68408. /** mag = nearest and min = nearest and mip = none */
  68409. static readonly TEXTURE_NEAREST_NEAREST: number;
  68410. /** mag = linear and min = nearest and mip = nearest */
  68411. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68412. /** mag = linear and min = nearest and mip = linear */
  68413. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68414. /** mag = linear and min = linear and mip = none */
  68415. static readonly TEXTURE_LINEAR_LINEAR: number;
  68416. /** mag = linear and min = nearest and mip = none */
  68417. static readonly TEXTURE_LINEAR_NEAREST: number;
  68418. /** Explicit coordinates mode */
  68419. static readonly TEXTURE_EXPLICIT_MODE: number;
  68420. /** Spherical coordinates mode */
  68421. static readonly TEXTURE_SPHERICAL_MODE: number;
  68422. /** Planar coordinates mode */
  68423. static readonly TEXTURE_PLANAR_MODE: number;
  68424. /** Cubic coordinates mode */
  68425. static readonly TEXTURE_CUBIC_MODE: number;
  68426. /** Projection coordinates mode */
  68427. static readonly TEXTURE_PROJECTION_MODE: number;
  68428. /** Skybox coordinates mode */
  68429. static readonly TEXTURE_SKYBOX_MODE: number;
  68430. /** Inverse Cubic coordinates mode */
  68431. static readonly TEXTURE_INVCUBIC_MODE: number;
  68432. /** Equirectangular coordinates mode */
  68433. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68434. /** Equirectangular Fixed coordinates mode */
  68435. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68436. /** Equirectangular Fixed Mirrored coordinates mode */
  68437. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68438. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68439. static readonly SCALEMODE_FLOOR: number;
  68440. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68441. static readonly SCALEMODE_NEAREST: number;
  68442. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68443. static readonly SCALEMODE_CEILING: number;
  68444. /**
  68445. * The dirty texture flag value
  68446. */
  68447. static readonly MATERIAL_TextureDirtyFlag: number;
  68448. /**
  68449. * The dirty light flag value
  68450. */
  68451. static readonly MATERIAL_LightDirtyFlag: number;
  68452. /**
  68453. * The dirty fresnel flag value
  68454. */
  68455. static readonly MATERIAL_FresnelDirtyFlag: number;
  68456. /**
  68457. * The dirty attribute flag value
  68458. */
  68459. static readonly MATERIAL_AttributesDirtyFlag: number;
  68460. /**
  68461. * The dirty misc flag value
  68462. */
  68463. static readonly MATERIAL_MiscDirtyFlag: number;
  68464. /**
  68465. * The all dirty flag value
  68466. */
  68467. static readonly MATERIAL_AllDirtyFlag: number;
  68468. /**
  68469. * Returns the triangle fill mode
  68470. */
  68471. static readonly MATERIAL_TriangleFillMode: number;
  68472. /**
  68473. * Returns the wireframe mode
  68474. */
  68475. static readonly MATERIAL_WireFrameFillMode: number;
  68476. /**
  68477. * Returns the point fill mode
  68478. */
  68479. static readonly MATERIAL_PointFillMode: number;
  68480. /**
  68481. * Returns the point list draw mode
  68482. */
  68483. static readonly MATERIAL_PointListDrawMode: number;
  68484. /**
  68485. * Returns the line list draw mode
  68486. */
  68487. static readonly MATERIAL_LineListDrawMode: number;
  68488. /**
  68489. * Returns the line loop draw mode
  68490. */
  68491. static readonly MATERIAL_LineLoopDrawMode: number;
  68492. /**
  68493. * Returns the line strip draw mode
  68494. */
  68495. static readonly MATERIAL_LineStripDrawMode: number;
  68496. /**
  68497. * Returns the triangle strip draw mode
  68498. */
  68499. static readonly MATERIAL_TriangleStripDrawMode: number;
  68500. /**
  68501. * Returns the triangle fan draw mode
  68502. */
  68503. static readonly MATERIAL_TriangleFanDrawMode: number;
  68504. /**
  68505. * Stores the clock-wise side orientation
  68506. */
  68507. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68508. /**
  68509. * Stores the counter clock-wise side orientation
  68510. */
  68511. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68512. /**
  68513. * Nothing
  68514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68515. */
  68516. static readonly ACTION_NothingTrigger: number;
  68517. /**
  68518. * On pick
  68519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68520. */
  68521. static readonly ACTION_OnPickTrigger: number;
  68522. /**
  68523. * On left pick
  68524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68525. */
  68526. static readonly ACTION_OnLeftPickTrigger: number;
  68527. /**
  68528. * On right pick
  68529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68530. */
  68531. static readonly ACTION_OnRightPickTrigger: number;
  68532. /**
  68533. * On center pick
  68534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68535. */
  68536. static readonly ACTION_OnCenterPickTrigger: number;
  68537. /**
  68538. * On pick down
  68539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68540. */
  68541. static readonly ACTION_OnPickDownTrigger: number;
  68542. /**
  68543. * On double pick
  68544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68545. */
  68546. static readonly ACTION_OnDoublePickTrigger: number;
  68547. /**
  68548. * On pick up
  68549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68550. */
  68551. static readonly ACTION_OnPickUpTrigger: number;
  68552. /**
  68553. * On pick out.
  68554. * This trigger will only be raised if you also declared a OnPickDown
  68555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68556. */
  68557. static readonly ACTION_OnPickOutTrigger: number;
  68558. /**
  68559. * On long press
  68560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68561. */
  68562. static readonly ACTION_OnLongPressTrigger: number;
  68563. /**
  68564. * On pointer over
  68565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68566. */
  68567. static readonly ACTION_OnPointerOverTrigger: number;
  68568. /**
  68569. * On pointer out
  68570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68571. */
  68572. static readonly ACTION_OnPointerOutTrigger: number;
  68573. /**
  68574. * On every frame
  68575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68576. */
  68577. static readonly ACTION_OnEveryFrameTrigger: number;
  68578. /**
  68579. * On intersection enter
  68580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68581. */
  68582. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68583. /**
  68584. * On intersection exit
  68585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68586. */
  68587. static readonly ACTION_OnIntersectionExitTrigger: number;
  68588. /**
  68589. * On key down
  68590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68591. */
  68592. static readonly ACTION_OnKeyDownTrigger: number;
  68593. /**
  68594. * On key up
  68595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68596. */
  68597. static readonly ACTION_OnKeyUpTrigger: number;
  68598. /**
  68599. * Billboard mode will only apply to Y axis
  68600. */
  68601. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68602. /**
  68603. * Billboard mode will apply to all axes
  68604. */
  68605. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68606. /**
  68607. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68608. */
  68609. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68610. /**
  68611. * Gets or sets base Assets URL
  68612. */
  68613. static PARTICLES_BaseAssetsUrl: string;
  68614. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68615. * Test order :
  68616. * Is the bounding sphere outside the frustum ?
  68617. * If not, are the bounding box vertices outside the frustum ?
  68618. * It not, then the cullable object is in the frustum.
  68619. */
  68620. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68621. /** Culling strategy : Bounding Sphere Only.
  68622. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68623. * It's also less accurate than the standard because some not visible objects can still be selected.
  68624. * Test : is the bounding sphere outside the frustum ?
  68625. * If not, then the cullable object is in the frustum.
  68626. */
  68627. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68628. /** Culling strategy : Optimistic Inclusion.
  68629. * This in an inclusion test first, then the standard exclusion test.
  68630. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68631. * 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.
  68632. * Anyway, it's as accurate as the standard strategy.
  68633. * Test :
  68634. * Is the cullable object bounding sphere center in the frustum ?
  68635. * If not, apply the default culling strategy.
  68636. */
  68637. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68638. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68639. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68640. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68641. * 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.
  68642. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68643. * Test :
  68644. * Is the cullable object bounding sphere center in the frustum ?
  68645. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68646. */
  68647. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68648. /**
  68649. * No logging while loading
  68650. */
  68651. static readonly SCENELOADER_NO_LOGGING: number;
  68652. /**
  68653. * Minimal logging while loading
  68654. */
  68655. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68656. /**
  68657. * Summary logging while loading
  68658. */
  68659. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68660. /**
  68661. * Detailled logging while loading
  68662. */
  68663. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68664. }
  68665. }
  68666. declare module BABYLON {
  68667. /**
  68668. * Class used to store and describe the pipeline context associated with an effect
  68669. */
  68670. export interface IPipelineContext {
  68671. /**
  68672. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68673. */
  68674. isAsync: boolean;
  68675. /**
  68676. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68677. */
  68678. isReady: boolean;
  68679. /** @hidden */
  68680. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68681. }
  68682. }
  68683. declare module BABYLON {
  68684. /** @hidden */
  68685. export interface IShaderProcessor {
  68686. attributeProcessor?: (attribute: string) => string;
  68687. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68688. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68689. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68690. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68691. lineProcessor?: (line: string, isFragment: boolean) => string;
  68692. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68693. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68694. }
  68695. }
  68696. declare module BABYLON {
  68697. /** @hidden */
  68698. export interface ProcessingOptions {
  68699. defines: string[];
  68700. indexParameters: any;
  68701. isFragment: boolean;
  68702. shouldUseHighPrecisionShader: boolean;
  68703. supportsUniformBuffers: boolean;
  68704. shadersRepository: string;
  68705. includesShadersStore: {
  68706. [key: string]: string;
  68707. };
  68708. processor?: IShaderProcessor;
  68709. version: string;
  68710. platformName: string;
  68711. lookForClosingBracketForUniformBuffer?: boolean;
  68712. }
  68713. }
  68714. declare module BABYLON {
  68715. /**
  68716. * Helper to manipulate strings
  68717. */
  68718. export class StringTools {
  68719. /**
  68720. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68721. * @param str Source string
  68722. * @param suffix Suffix to search for in the source string
  68723. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68724. */
  68725. static EndsWith(str: string, suffix: string): boolean;
  68726. /**
  68727. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68728. * @param str Source string
  68729. * @param suffix Suffix to search for in the source string
  68730. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68731. */
  68732. static StartsWith(str: string, suffix: string): boolean;
  68733. }
  68734. }
  68735. declare module BABYLON {
  68736. /** @hidden */
  68737. export class ShaderCodeNode {
  68738. line: string;
  68739. children: ShaderCodeNode[];
  68740. additionalDefineKey?: string;
  68741. additionalDefineValue?: string;
  68742. isValid(preprocessors: {
  68743. [key: string]: string;
  68744. }): boolean;
  68745. process(preprocessors: {
  68746. [key: string]: string;
  68747. }, options: ProcessingOptions): string;
  68748. }
  68749. }
  68750. declare module BABYLON {
  68751. /** @hidden */
  68752. export class ShaderCodeCursor {
  68753. private _lines;
  68754. lineIndex: number;
  68755. readonly currentLine: string;
  68756. readonly canRead: boolean;
  68757. lines: string[];
  68758. }
  68759. }
  68760. declare module BABYLON {
  68761. /** @hidden */
  68762. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68763. process(preprocessors: {
  68764. [key: string]: string;
  68765. }, options: ProcessingOptions): string;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /** @hidden */
  68770. export class ShaderDefineExpression {
  68771. isTrue(preprocessors: {
  68772. [key: string]: string;
  68773. }): boolean;
  68774. }
  68775. }
  68776. declare module BABYLON {
  68777. /** @hidden */
  68778. export class ShaderCodeTestNode extends ShaderCodeNode {
  68779. testExpression: ShaderDefineExpression;
  68780. isValid(preprocessors: {
  68781. [key: string]: string;
  68782. }): boolean;
  68783. }
  68784. }
  68785. declare module BABYLON {
  68786. /** @hidden */
  68787. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68788. define: string;
  68789. not: boolean;
  68790. constructor(define: string, not?: boolean);
  68791. isTrue(preprocessors: {
  68792. [key: string]: string;
  68793. }): boolean;
  68794. }
  68795. }
  68796. declare module BABYLON {
  68797. /** @hidden */
  68798. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68799. leftOperand: ShaderDefineExpression;
  68800. rightOperand: ShaderDefineExpression;
  68801. isTrue(preprocessors: {
  68802. [key: string]: string;
  68803. }): boolean;
  68804. }
  68805. }
  68806. declare module BABYLON {
  68807. /** @hidden */
  68808. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68809. leftOperand: ShaderDefineExpression;
  68810. rightOperand: ShaderDefineExpression;
  68811. isTrue(preprocessors: {
  68812. [key: string]: string;
  68813. }): boolean;
  68814. }
  68815. }
  68816. declare module BABYLON {
  68817. /** @hidden */
  68818. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68819. define: string;
  68820. operand: string;
  68821. testValue: string;
  68822. constructor(define: string, operand: string, testValue: string);
  68823. isTrue(preprocessors: {
  68824. [key: string]: string;
  68825. }): boolean;
  68826. }
  68827. }
  68828. declare module BABYLON {
  68829. /**
  68830. * @ignore
  68831. * Application error to support additional information when loading a file
  68832. */
  68833. export class LoadFileError extends Error {
  68834. /** defines the optional web request */
  68835. request?: WebRequest | undefined;
  68836. private static _setPrototypeOf;
  68837. /**
  68838. * Creates a new LoadFileError
  68839. * @param message defines the message of the error
  68840. * @param request defines the optional web request
  68841. */
  68842. constructor(message: string,
  68843. /** defines the optional web request */
  68844. request?: WebRequest | undefined);
  68845. }
  68846. }
  68847. declare module BABYLON {
  68848. /**
  68849. * Class used to enable access to offline support
  68850. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68851. */
  68852. export interface IOfflineProvider {
  68853. /**
  68854. * Gets a boolean indicating if scene must be saved in the database
  68855. */
  68856. enableSceneOffline: boolean;
  68857. /**
  68858. * Gets a boolean indicating if textures must be saved in the database
  68859. */
  68860. enableTexturesOffline: boolean;
  68861. /**
  68862. * Open the offline support and make it available
  68863. * @param successCallback defines the callback to call on success
  68864. * @param errorCallback defines the callback to call on error
  68865. */
  68866. open(successCallback: () => void, errorCallback: () => void): void;
  68867. /**
  68868. * Loads an image from the offline support
  68869. * @param url defines the url to load from
  68870. * @param image defines the target DOM image
  68871. */
  68872. loadImage(url: string, image: HTMLImageElement): void;
  68873. /**
  68874. * Loads a file from offline support
  68875. * @param url defines the URL to load from
  68876. * @param sceneLoaded defines a callback to call on success
  68877. * @param progressCallBack defines a callback to call when progress changed
  68878. * @param errorCallback defines a callback to call on error
  68879. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68880. */
  68881. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68882. }
  68883. }
  68884. declare module BABYLON {
  68885. /**
  68886. * Class used to help managing file picking and drag'n'drop
  68887. * File Storage
  68888. */
  68889. export class FilesInputStore {
  68890. /**
  68891. * List of files ready to be loaded
  68892. */
  68893. static FilesToLoad: {
  68894. [key: string]: File;
  68895. };
  68896. }
  68897. }
  68898. declare module BABYLON {
  68899. /**
  68900. * Class used to define a retry strategy when error happens while loading assets
  68901. */
  68902. export class RetryStrategy {
  68903. /**
  68904. * Function used to defines an exponential back off strategy
  68905. * @param maxRetries defines the maximum number of retries (3 by default)
  68906. * @param baseInterval defines the interval between retries
  68907. * @returns the strategy function to use
  68908. */
  68909. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68910. }
  68911. }
  68912. declare module BABYLON {
  68913. /**
  68914. * @hidden
  68915. */
  68916. export class FileTools {
  68917. /**
  68918. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68919. */
  68920. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68921. /**
  68922. * Gets or sets the base URL to use to load assets
  68923. */
  68924. static BaseUrl: string;
  68925. /**
  68926. * Default behaviour for cors in the application.
  68927. * It can be a string if the expected behavior is identical in the entire app.
  68928. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68929. */
  68930. static CorsBehavior: string | ((url: string | string[]) => string);
  68931. /**
  68932. * Gets or sets a function used to pre-process url before using them to load assets
  68933. */
  68934. static PreprocessUrl: (url: string) => string;
  68935. /**
  68936. * Removes unwanted characters from an url
  68937. * @param url defines the url to clean
  68938. * @returns the cleaned url
  68939. */
  68940. private static _CleanUrl;
  68941. /**
  68942. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68943. * @param url define the url we are trying
  68944. * @param element define the dom element where to configure the cors policy
  68945. */
  68946. static SetCorsBehavior(url: string | string[], element: {
  68947. crossOrigin: string | null;
  68948. }): void;
  68949. /**
  68950. * Loads an image as an HTMLImageElement.
  68951. * @param input url string, ArrayBuffer, or Blob to load
  68952. * @param onLoad callback called when the image successfully loads
  68953. * @param onError callback called when the image fails to load
  68954. * @param offlineProvider offline provider for caching
  68955. * @returns the HTMLImageElement of the loaded image
  68956. */
  68957. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68958. /**
  68959. * Loads a file
  68960. * @param fileToLoad defines the file to load
  68961. * @param callback defines the callback to call when data is loaded
  68962. * @param progressCallBack defines the callback to call during loading process
  68963. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68964. * @returns a file request object
  68965. */
  68966. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68967. /**
  68968. * Loads a file
  68969. * @param url url string, ArrayBuffer, or Blob to load
  68970. * @param onSuccess callback called when the file successfully loads
  68971. * @param onProgress callback called while file is loading (if the server supports this mode)
  68972. * @param offlineProvider defines the offline provider for caching
  68973. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68974. * @param onError callback called when the file fails to load
  68975. * @returns a file request object
  68976. */
  68977. 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;
  68978. /**
  68979. * Checks if the loaded document was accessed via `file:`-Protocol.
  68980. * @returns boolean
  68981. */
  68982. static IsFileURL(): boolean;
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /** @hidden */
  68987. export class ShaderProcessor {
  68988. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68989. private static _ProcessPrecision;
  68990. private static _ExtractOperation;
  68991. private static _BuildSubExpression;
  68992. private static _BuildExpression;
  68993. private static _MoveCursorWithinIf;
  68994. private static _MoveCursor;
  68995. private static _EvaluatePreProcessors;
  68996. private static _PreparePreProcessors;
  68997. private static _ProcessShaderConversion;
  68998. private static _ProcessIncludes;
  68999. }
  69000. }
  69001. declare module BABYLON {
  69002. /**
  69003. * Class used to hold a RBG color
  69004. */
  69005. export class Color3 {
  69006. /**
  69007. * Defines the red component (between 0 and 1, default is 0)
  69008. */
  69009. r: number;
  69010. /**
  69011. * Defines the green component (between 0 and 1, default is 0)
  69012. */
  69013. g: number;
  69014. /**
  69015. * Defines the blue component (between 0 and 1, default is 0)
  69016. */
  69017. b: number;
  69018. /**
  69019. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  69020. * @param r defines the red component (between 0 and 1, default is 0)
  69021. * @param g defines the green component (between 0 and 1, default is 0)
  69022. * @param b defines the blue component (between 0 and 1, default is 0)
  69023. */
  69024. constructor(
  69025. /**
  69026. * Defines the red component (between 0 and 1, default is 0)
  69027. */
  69028. r?: number,
  69029. /**
  69030. * Defines the green component (between 0 and 1, default is 0)
  69031. */
  69032. g?: number,
  69033. /**
  69034. * Defines the blue component (between 0 and 1, default is 0)
  69035. */
  69036. b?: number);
  69037. /**
  69038. * Creates a string with the Color3 current values
  69039. * @returns the string representation of the Color3 object
  69040. */
  69041. toString(): string;
  69042. /**
  69043. * Returns the string "Color3"
  69044. * @returns "Color3"
  69045. */
  69046. getClassName(): string;
  69047. /**
  69048. * Compute the Color3 hash code
  69049. * @returns an unique number that can be used to hash Color3 objects
  69050. */
  69051. getHashCode(): number;
  69052. /**
  69053. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  69054. * @param array defines the array where to store the r,g,b components
  69055. * @param index defines an optional index in the target array to define where to start storing values
  69056. * @returns the current Color3 object
  69057. */
  69058. toArray(array: FloatArray, index?: number): Color3;
  69059. /**
  69060. * Returns a new Color4 object from the current Color3 and the given alpha
  69061. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  69062. * @returns a new Color4 object
  69063. */
  69064. toColor4(alpha?: number): Color4;
  69065. /**
  69066. * Returns a new array populated with 3 numeric elements : red, green and blue values
  69067. * @returns the new array
  69068. */
  69069. asArray(): number[];
  69070. /**
  69071. * Returns the luminance value
  69072. * @returns a float value
  69073. */
  69074. toLuminance(): number;
  69075. /**
  69076. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  69077. * @param otherColor defines the second operand
  69078. * @returns the new Color3 object
  69079. */
  69080. multiply(otherColor: DeepImmutable<Color3>): Color3;
  69081. /**
  69082. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  69083. * @param otherColor defines the second operand
  69084. * @param result defines the Color3 object where to store the result
  69085. * @returns the current Color3
  69086. */
  69087. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69088. /**
  69089. * Determines equality between Color3 objects
  69090. * @param otherColor defines the second operand
  69091. * @returns true if the rgb values are equal to the given ones
  69092. */
  69093. equals(otherColor: DeepImmutable<Color3>): boolean;
  69094. /**
  69095. * Determines equality between the current Color3 object and a set of r,b,g values
  69096. * @param r defines the red component to check
  69097. * @param g defines the green component to check
  69098. * @param b defines the blue component to check
  69099. * @returns true if the rgb values are equal to the given ones
  69100. */
  69101. equalsFloats(r: number, g: number, b: number): boolean;
  69102. /**
  69103. * Multiplies in place each rgb value by scale
  69104. * @param scale defines the scaling factor
  69105. * @returns the updated Color3
  69106. */
  69107. scale(scale: number): Color3;
  69108. /**
  69109. * Multiplies the rgb values by scale and stores the result into "result"
  69110. * @param scale defines the scaling factor
  69111. * @param result defines the Color3 object where to store the result
  69112. * @returns the unmodified current Color3
  69113. */
  69114. scaleToRef(scale: number, result: Color3): Color3;
  69115. /**
  69116. * Scale the current Color3 values by a factor and add the result to a given Color3
  69117. * @param scale defines the scale factor
  69118. * @param result defines color to store the result into
  69119. * @returns the unmodified current Color3
  69120. */
  69121. scaleAndAddToRef(scale: number, result: Color3): Color3;
  69122. /**
  69123. * Clamps the rgb values by the min and max values and stores the result into "result"
  69124. * @param min defines minimum clamping value (default is 0)
  69125. * @param max defines maximum clamping value (default is 1)
  69126. * @param result defines color to store the result into
  69127. * @returns the original Color3
  69128. */
  69129. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  69130. /**
  69131. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  69132. * @param otherColor defines the second operand
  69133. * @returns the new Color3
  69134. */
  69135. add(otherColor: DeepImmutable<Color3>): Color3;
  69136. /**
  69137. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  69138. * @param otherColor defines the second operand
  69139. * @param result defines Color3 object to store the result into
  69140. * @returns the unmodified current Color3
  69141. */
  69142. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69143. /**
  69144. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  69145. * @param otherColor defines the second operand
  69146. * @returns the new Color3
  69147. */
  69148. subtract(otherColor: DeepImmutable<Color3>): Color3;
  69149. /**
  69150. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  69151. * @param otherColor defines the second operand
  69152. * @param result defines Color3 object to store the result into
  69153. * @returns the unmodified current Color3
  69154. */
  69155. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  69156. /**
  69157. * Copy the current object
  69158. * @returns a new Color3 copied the current one
  69159. */
  69160. clone(): Color3;
  69161. /**
  69162. * Copies the rgb values from the source in the current Color3
  69163. * @param source defines the source Color3 object
  69164. * @returns the updated Color3 object
  69165. */
  69166. copyFrom(source: DeepImmutable<Color3>): Color3;
  69167. /**
  69168. * Updates the Color3 rgb values from the given floats
  69169. * @param r defines the red component to read from
  69170. * @param g defines the green component to read from
  69171. * @param b defines the blue component to read from
  69172. * @returns the current Color3 object
  69173. */
  69174. copyFromFloats(r: number, g: number, b: number): Color3;
  69175. /**
  69176. * Updates the Color3 rgb values from the given floats
  69177. * @param r defines the red component to read from
  69178. * @param g defines the green component to read from
  69179. * @param b defines the blue component to read from
  69180. * @returns the current Color3 object
  69181. */
  69182. set(r: number, g: number, b: number): Color3;
  69183. /**
  69184. * Compute the Color3 hexadecimal code as a string
  69185. * @returns a string containing the hexadecimal representation of the Color3 object
  69186. */
  69187. toHexString(): string;
  69188. /**
  69189. * Computes a new Color3 converted from the current one to linear space
  69190. * @returns a new Color3 object
  69191. */
  69192. toLinearSpace(): Color3;
  69193. /**
  69194. * Converts current color in rgb space to HSV values
  69195. * @returns a new color3 representing the HSV values
  69196. */
  69197. toHSV(): Color3;
  69198. /**
  69199. * Converts current color in rgb space to HSV values
  69200. * @param result defines the Color3 where to store the HSV values
  69201. */
  69202. toHSVToRef(result: Color3): void;
  69203. /**
  69204. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  69205. * @param convertedColor defines the Color3 object where to store the linear space version
  69206. * @returns the unmodified Color3
  69207. */
  69208. toLinearSpaceToRef(convertedColor: Color3): Color3;
  69209. /**
  69210. * Computes a new Color3 converted from the current one to gamma space
  69211. * @returns a new Color3 object
  69212. */
  69213. toGammaSpace(): Color3;
  69214. /**
  69215. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  69216. * @param convertedColor defines the Color3 object where to store the gamma space version
  69217. * @returns the unmodified Color3
  69218. */
  69219. toGammaSpaceToRef(convertedColor: Color3): Color3;
  69220. private static _BlackReadOnly;
  69221. /**
  69222. * Convert Hue, saturation and value to a Color3 (RGB)
  69223. * @param hue defines the hue
  69224. * @param saturation defines the saturation
  69225. * @param value defines the value
  69226. * @param result defines the Color3 where to store the RGB values
  69227. */
  69228. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  69229. /**
  69230. * Creates a new Color3 from the string containing valid hexadecimal values
  69231. * @param hex defines a string containing valid hexadecimal values
  69232. * @returns a new Color3 object
  69233. */
  69234. static FromHexString(hex: string): Color3;
  69235. /**
  69236. * Creates a new Color3 from the starting index of the given array
  69237. * @param array defines the source array
  69238. * @param offset defines an offset in the source array
  69239. * @returns a new Color3 object
  69240. */
  69241. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  69242. /**
  69243. * Creates a new Color3 from integer values (< 256)
  69244. * @param r defines the red component to read from (value between 0 and 255)
  69245. * @param g defines the green component to read from (value between 0 and 255)
  69246. * @param b defines the blue component to read from (value between 0 and 255)
  69247. * @returns a new Color3 object
  69248. */
  69249. static FromInts(r: number, g: number, b: number): Color3;
  69250. /**
  69251. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69252. * @param start defines the start Color3 value
  69253. * @param end defines the end Color3 value
  69254. * @param amount defines the gradient value between start and end
  69255. * @returns a new Color3 object
  69256. */
  69257. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  69258. /**
  69259. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  69260. * @param left defines the start value
  69261. * @param right defines the end value
  69262. * @param amount defines the gradient factor
  69263. * @param result defines the Color3 object where to store the result
  69264. */
  69265. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  69266. /**
  69267. * Returns a Color3 value containing a red color
  69268. * @returns a new Color3 object
  69269. */
  69270. static Red(): Color3;
  69271. /**
  69272. * Returns a Color3 value containing a green color
  69273. * @returns a new Color3 object
  69274. */
  69275. static Green(): Color3;
  69276. /**
  69277. * Returns a Color3 value containing a blue color
  69278. * @returns a new Color3 object
  69279. */
  69280. static Blue(): Color3;
  69281. /**
  69282. * Returns a Color3 value containing a black color
  69283. * @returns a new Color3 object
  69284. */
  69285. static Black(): Color3;
  69286. /**
  69287. * Gets a Color3 value containing a black color that must not be updated
  69288. */
  69289. static readonly BlackReadOnly: DeepImmutable<Color3>;
  69290. /**
  69291. * Returns a Color3 value containing a white color
  69292. * @returns a new Color3 object
  69293. */
  69294. static White(): Color3;
  69295. /**
  69296. * Returns a Color3 value containing a purple color
  69297. * @returns a new Color3 object
  69298. */
  69299. static Purple(): Color3;
  69300. /**
  69301. * Returns a Color3 value containing a magenta color
  69302. * @returns a new Color3 object
  69303. */
  69304. static Magenta(): Color3;
  69305. /**
  69306. * Returns a Color3 value containing a yellow color
  69307. * @returns a new Color3 object
  69308. */
  69309. static Yellow(): Color3;
  69310. /**
  69311. * Returns a Color3 value containing a gray color
  69312. * @returns a new Color3 object
  69313. */
  69314. static Gray(): Color3;
  69315. /**
  69316. * Returns a Color3 value containing a teal color
  69317. * @returns a new Color3 object
  69318. */
  69319. static Teal(): Color3;
  69320. /**
  69321. * Returns a Color3 value containing a random color
  69322. * @returns a new Color3 object
  69323. */
  69324. static Random(): Color3;
  69325. }
  69326. /**
  69327. * Class used to hold a RBGA color
  69328. */
  69329. export class Color4 {
  69330. /**
  69331. * Defines the red component (between 0 and 1, default is 0)
  69332. */
  69333. r: number;
  69334. /**
  69335. * Defines the green component (between 0 and 1, default is 0)
  69336. */
  69337. g: number;
  69338. /**
  69339. * Defines the blue component (between 0 and 1, default is 0)
  69340. */
  69341. b: number;
  69342. /**
  69343. * Defines the alpha component (between 0 and 1, default is 1)
  69344. */
  69345. a: number;
  69346. /**
  69347. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69348. * @param r defines the red component (between 0 and 1, default is 0)
  69349. * @param g defines the green component (between 0 and 1, default is 0)
  69350. * @param b defines the blue component (between 0 and 1, default is 0)
  69351. * @param a defines the alpha component (between 0 and 1, default is 1)
  69352. */
  69353. constructor(
  69354. /**
  69355. * Defines the red component (between 0 and 1, default is 0)
  69356. */
  69357. r?: number,
  69358. /**
  69359. * Defines the green component (between 0 and 1, default is 0)
  69360. */
  69361. g?: number,
  69362. /**
  69363. * Defines the blue component (between 0 and 1, default is 0)
  69364. */
  69365. b?: number,
  69366. /**
  69367. * Defines the alpha component (between 0 and 1, default is 1)
  69368. */
  69369. a?: number);
  69370. /**
  69371. * Adds in place the given Color4 values to the current Color4 object
  69372. * @param right defines the second operand
  69373. * @returns the current updated Color4 object
  69374. */
  69375. addInPlace(right: DeepImmutable<Color4>): Color4;
  69376. /**
  69377. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69378. * @returns the new array
  69379. */
  69380. asArray(): number[];
  69381. /**
  69382. * Stores from the starting index in the given array the Color4 successive values
  69383. * @param array defines the array where to store the r,g,b components
  69384. * @param index defines an optional index in the target array to define where to start storing values
  69385. * @returns the current Color4 object
  69386. */
  69387. toArray(array: number[], index?: number): Color4;
  69388. /**
  69389. * Determines equality between Color4 objects
  69390. * @param otherColor defines the second operand
  69391. * @returns true if the rgba values are equal to the given ones
  69392. */
  69393. equals(otherColor: DeepImmutable<Color4>): boolean;
  69394. /**
  69395. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69396. * @param right defines the second operand
  69397. * @returns a new Color4 object
  69398. */
  69399. add(right: DeepImmutable<Color4>): Color4;
  69400. /**
  69401. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69402. * @param right defines the second operand
  69403. * @returns a new Color4 object
  69404. */
  69405. subtract(right: DeepImmutable<Color4>): Color4;
  69406. /**
  69407. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69408. * @param right defines the second operand
  69409. * @param result defines the Color4 object where to store the result
  69410. * @returns the current Color4 object
  69411. */
  69412. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69413. /**
  69414. * Creates a new Color4 with the current Color4 values multiplied by scale
  69415. * @param scale defines the scaling factor to apply
  69416. * @returns a new Color4 object
  69417. */
  69418. scale(scale: number): Color4;
  69419. /**
  69420. * Multiplies the current Color4 values by scale and stores the result in "result"
  69421. * @param scale defines the scaling factor to apply
  69422. * @param result defines the Color4 object where to store the result
  69423. * @returns the current unmodified Color4
  69424. */
  69425. scaleToRef(scale: number, result: Color4): Color4;
  69426. /**
  69427. * Scale the current Color4 values by a factor and add the result to a given Color4
  69428. * @param scale defines the scale factor
  69429. * @param result defines the Color4 object where to store the result
  69430. * @returns the unmodified current Color4
  69431. */
  69432. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69433. /**
  69434. * Clamps the rgb values by the min and max values and stores the result into "result"
  69435. * @param min defines minimum clamping value (default is 0)
  69436. * @param max defines maximum clamping value (default is 1)
  69437. * @param result defines color to store the result into.
  69438. * @returns the cuurent Color4
  69439. */
  69440. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69441. /**
  69442. * Multipy an Color4 value by another and return a new Color4 object
  69443. * @param color defines the Color4 value to multiply by
  69444. * @returns a new Color4 object
  69445. */
  69446. multiply(color: Color4): Color4;
  69447. /**
  69448. * Multipy a Color4 value by another and push the result in a reference value
  69449. * @param color defines the Color4 value to multiply by
  69450. * @param result defines the Color4 to fill the result in
  69451. * @returns the result Color4
  69452. */
  69453. multiplyToRef(color: Color4, result: Color4): Color4;
  69454. /**
  69455. * Creates a string with the Color4 current values
  69456. * @returns the string representation of the Color4 object
  69457. */
  69458. toString(): string;
  69459. /**
  69460. * Returns the string "Color4"
  69461. * @returns "Color4"
  69462. */
  69463. getClassName(): string;
  69464. /**
  69465. * Compute the Color4 hash code
  69466. * @returns an unique number that can be used to hash Color4 objects
  69467. */
  69468. getHashCode(): number;
  69469. /**
  69470. * Creates a new Color4 copied from the current one
  69471. * @returns a new Color4 object
  69472. */
  69473. clone(): Color4;
  69474. /**
  69475. * Copies the given Color4 values into the current one
  69476. * @param source defines the source Color4 object
  69477. * @returns the current updated Color4 object
  69478. */
  69479. copyFrom(source: Color4): Color4;
  69480. /**
  69481. * Copies the given float values into the current one
  69482. * @param r defines the red component to read from
  69483. * @param g defines the green component to read from
  69484. * @param b defines the blue component to read from
  69485. * @param a defines the alpha component to read from
  69486. * @returns the current updated Color4 object
  69487. */
  69488. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69489. /**
  69490. * Copies the given float values into the current one
  69491. * @param r defines the red component to read from
  69492. * @param g defines the green component to read from
  69493. * @param b defines the blue component to read from
  69494. * @param a defines the alpha component to read from
  69495. * @returns the current updated Color4 object
  69496. */
  69497. set(r: number, g: number, b: number, a: number): Color4;
  69498. /**
  69499. * Compute the Color4 hexadecimal code as a string
  69500. * @returns a string containing the hexadecimal representation of the Color4 object
  69501. */
  69502. toHexString(): string;
  69503. /**
  69504. * Computes a new Color4 converted from the current one to linear space
  69505. * @returns a new Color4 object
  69506. */
  69507. toLinearSpace(): Color4;
  69508. /**
  69509. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69510. * @param convertedColor defines the Color4 object where to store the linear space version
  69511. * @returns the unmodified Color4
  69512. */
  69513. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69514. /**
  69515. * Computes a new Color4 converted from the current one to gamma space
  69516. * @returns a new Color4 object
  69517. */
  69518. toGammaSpace(): Color4;
  69519. /**
  69520. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69521. * @param convertedColor defines the Color4 object where to store the gamma space version
  69522. * @returns the unmodified Color4
  69523. */
  69524. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69525. /**
  69526. * Creates a new Color4 from the string containing valid hexadecimal values
  69527. * @param hex defines a string containing valid hexadecimal values
  69528. * @returns a new Color4 object
  69529. */
  69530. static FromHexString(hex: string): Color4;
  69531. /**
  69532. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69533. * @param left defines the start value
  69534. * @param right defines the end value
  69535. * @param amount defines the gradient factor
  69536. * @returns a new Color4 object
  69537. */
  69538. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69539. /**
  69540. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69541. * @param left defines the start value
  69542. * @param right defines the end value
  69543. * @param amount defines the gradient factor
  69544. * @param result defines the Color4 object where to store data
  69545. */
  69546. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69547. /**
  69548. * Creates a new Color4 from a Color3 and an alpha value
  69549. * @param color3 defines the source Color3 to read from
  69550. * @param alpha defines the alpha component (1.0 by default)
  69551. * @returns a new Color4 object
  69552. */
  69553. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69554. /**
  69555. * Creates a new Color4 from the starting index element of the given array
  69556. * @param array defines the source array to read from
  69557. * @param offset defines the offset in the source array
  69558. * @returns a new Color4 object
  69559. */
  69560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69561. /**
  69562. * Creates a new Color3 from integer values (< 256)
  69563. * @param r defines the red component to read from (value between 0 and 255)
  69564. * @param g defines the green component to read from (value between 0 and 255)
  69565. * @param b defines the blue component to read from (value between 0 and 255)
  69566. * @param a defines the alpha component to read from (value between 0 and 255)
  69567. * @returns a new Color3 object
  69568. */
  69569. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69570. /**
  69571. * Check the content of a given array and convert it to an array containing RGBA data
  69572. * If the original array was already containing count * 4 values then it is returned directly
  69573. * @param colors defines the array to check
  69574. * @param count defines the number of RGBA data to expect
  69575. * @returns an array containing count * 4 values (RGBA)
  69576. */
  69577. static CheckColors4(colors: number[], count: number): number[];
  69578. }
  69579. /**
  69580. * @hidden
  69581. */
  69582. export class TmpColors {
  69583. static Color3: Color3[];
  69584. static Color4: Color4[];
  69585. }
  69586. }
  69587. declare module BABYLON {
  69588. /**
  69589. * Class representing spherical harmonics coefficients to the 3rd degree
  69590. */
  69591. export class SphericalHarmonics {
  69592. /**
  69593. * Defines whether or not the harmonics have been prescaled for rendering.
  69594. */
  69595. preScaled: boolean;
  69596. /**
  69597. * The l0,0 coefficients of the spherical harmonics
  69598. */
  69599. l00: Vector3;
  69600. /**
  69601. * The l1,-1 coefficients of the spherical harmonics
  69602. */
  69603. l1_1: Vector3;
  69604. /**
  69605. * The l1,0 coefficients of the spherical harmonics
  69606. */
  69607. l10: Vector3;
  69608. /**
  69609. * The l1,1 coefficients of the spherical harmonics
  69610. */
  69611. l11: Vector3;
  69612. /**
  69613. * The l2,-2 coefficients of the spherical harmonics
  69614. */
  69615. l2_2: Vector3;
  69616. /**
  69617. * The l2,-1 coefficients of the spherical harmonics
  69618. */
  69619. l2_1: Vector3;
  69620. /**
  69621. * The l2,0 coefficients of the spherical harmonics
  69622. */
  69623. l20: Vector3;
  69624. /**
  69625. * The l2,1 coefficients of the spherical harmonics
  69626. */
  69627. l21: Vector3;
  69628. /**
  69629. * The l2,2 coefficients of the spherical harmonics
  69630. */
  69631. l22: Vector3;
  69632. /**
  69633. * Adds a light to the spherical harmonics
  69634. * @param direction the direction of the light
  69635. * @param color the color of the light
  69636. * @param deltaSolidAngle the delta solid angle of the light
  69637. */
  69638. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69639. /**
  69640. * Scales the spherical harmonics by the given amount
  69641. * @param scale the amount to scale
  69642. */
  69643. scaleInPlace(scale: number): void;
  69644. /**
  69645. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69646. *
  69647. * ```
  69648. * E_lm = A_l * L_lm
  69649. * ```
  69650. *
  69651. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69652. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69653. * the scaling factors are given in equation 9.
  69654. */
  69655. convertIncidentRadianceToIrradiance(): void;
  69656. /**
  69657. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69658. *
  69659. * ```
  69660. * L = (1/pi) * E * rho
  69661. * ```
  69662. *
  69663. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69664. */
  69665. convertIrradianceToLambertianRadiance(): void;
  69666. /**
  69667. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69668. * required operations at run time.
  69669. *
  69670. * This is simply done by scaling back the SH with Ylm constants parameter.
  69671. * The trigonometric part being applied by the shader at run time.
  69672. */
  69673. preScaleForRendering(): void;
  69674. /**
  69675. * Constructs a spherical harmonics from an array.
  69676. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69677. * @returns the spherical harmonics
  69678. */
  69679. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69680. /**
  69681. * Gets the spherical harmonics from polynomial
  69682. * @param polynomial the spherical polynomial
  69683. * @returns the spherical harmonics
  69684. */
  69685. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69686. }
  69687. /**
  69688. * Class representing spherical polynomial coefficients to the 3rd degree
  69689. */
  69690. export class SphericalPolynomial {
  69691. private _harmonics;
  69692. /**
  69693. * The spherical harmonics used to create the polynomials.
  69694. */
  69695. readonly preScaledHarmonics: SphericalHarmonics;
  69696. /**
  69697. * The x coefficients of the spherical polynomial
  69698. */
  69699. x: Vector3;
  69700. /**
  69701. * The y coefficients of the spherical polynomial
  69702. */
  69703. y: Vector3;
  69704. /**
  69705. * The z coefficients of the spherical polynomial
  69706. */
  69707. z: Vector3;
  69708. /**
  69709. * The xx coefficients of the spherical polynomial
  69710. */
  69711. xx: Vector3;
  69712. /**
  69713. * The yy coefficients of the spherical polynomial
  69714. */
  69715. yy: Vector3;
  69716. /**
  69717. * The zz coefficients of the spherical polynomial
  69718. */
  69719. zz: Vector3;
  69720. /**
  69721. * The xy coefficients of the spherical polynomial
  69722. */
  69723. xy: Vector3;
  69724. /**
  69725. * The yz coefficients of the spherical polynomial
  69726. */
  69727. yz: Vector3;
  69728. /**
  69729. * The zx coefficients of the spherical polynomial
  69730. */
  69731. zx: Vector3;
  69732. /**
  69733. * Adds an ambient color to the spherical polynomial
  69734. * @param color the color to add
  69735. */
  69736. addAmbient(color: Color3): void;
  69737. /**
  69738. * Scales the spherical polynomial by the given amount
  69739. * @param scale the amount to scale
  69740. */
  69741. scaleInPlace(scale: number): void;
  69742. /**
  69743. * Gets the spherical polynomial from harmonics
  69744. * @param harmonics the spherical harmonics
  69745. * @returns the spherical polynomial
  69746. */
  69747. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69748. /**
  69749. * Constructs a spherical polynomial from an array.
  69750. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69751. * @returns the spherical polynomial
  69752. */
  69753. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69754. }
  69755. }
  69756. declare module BABYLON {
  69757. /**
  69758. * Define options used to create a render target texture
  69759. */
  69760. export class RenderTargetCreationOptions {
  69761. /**
  69762. * Specifies is mipmaps must be generated
  69763. */
  69764. generateMipMaps?: boolean;
  69765. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69766. generateDepthBuffer?: boolean;
  69767. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69768. generateStencilBuffer?: boolean;
  69769. /** Defines texture type (int by default) */
  69770. type?: number;
  69771. /** Defines sampling mode (trilinear by default) */
  69772. samplingMode?: number;
  69773. /** Defines format (RGBA by default) */
  69774. format?: number;
  69775. }
  69776. }
  69777. declare module BABYLON {
  69778. /**
  69779. * @hidden
  69780. **/
  69781. export class _AlphaState {
  69782. private _isAlphaBlendDirty;
  69783. private _isBlendFunctionParametersDirty;
  69784. private _isBlendEquationParametersDirty;
  69785. private _isBlendConstantsDirty;
  69786. private _alphaBlend;
  69787. private _blendFunctionParameters;
  69788. private _blendEquationParameters;
  69789. private _blendConstants;
  69790. /**
  69791. * Initializes the state.
  69792. */
  69793. constructor();
  69794. readonly isDirty: boolean;
  69795. alphaBlend: boolean;
  69796. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69797. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69798. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69799. reset(): void;
  69800. apply(gl: WebGLRenderingContext): void;
  69801. }
  69802. }
  69803. declare module BABYLON {
  69804. /**
  69805. * @hidden
  69806. **/
  69807. export class _DepthCullingState {
  69808. private _isDepthTestDirty;
  69809. private _isDepthMaskDirty;
  69810. private _isDepthFuncDirty;
  69811. private _isCullFaceDirty;
  69812. private _isCullDirty;
  69813. private _isZOffsetDirty;
  69814. private _isFrontFaceDirty;
  69815. private _depthTest;
  69816. private _depthMask;
  69817. private _depthFunc;
  69818. private _cull;
  69819. private _cullFace;
  69820. private _zOffset;
  69821. private _frontFace;
  69822. /**
  69823. * Initializes the state.
  69824. */
  69825. constructor();
  69826. readonly isDirty: boolean;
  69827. zOffset: number;
  69828. cullFace: Nullable<number>;
  69829. cull: Nullable<boolean>;
  69830. depthFunc: Nullable<number>;
  69831. depthMask: boolean;
  69832. depthTest: boolean;
  69833. frontFace: Nullable<number>;
  69834. reset(): void;
  69835. apply(gl: WebGLRenderingContext): void;
  69836. }
  69837. }
  69838. declare module BABYLON {
  69839. /**
  69840. * @hidden
  69841. **/
  69842. export class _StencilState {
  69843. /** 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 */
  69844. static readonly ALWAYS: number;
  69845. /** Passed to stencilOperation to specify that stencil value must be kept */
  69846. static readonly KEEP: number;
  69847. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69848. static readonly REPLACE: number;
  69849. private _isStencilTestDirty;
  69850. private _isStencilMaskDirty;
  69851. private _isStencilFuncDirty;
  69852. private _isStencilOpDirty;
  69853. private _stencilTest;
  69854. private _stencilMask;
  69855. private _stencilFunc;
  69856. private _stencilFuncRef;
  69857. private _stencilFuncMask;
  69858. private _stencilOpStencilFail;
  69859. private _stencilOpDepthFail;
  69860. private _stencilOpStencilDepthPass;
  69861. readonly isDirty: boolean;
  69862. stencilFunc: number;
  69863. stencilFuncRef: number;
  69864. stencilFuncMask: number;
  69865. stencilOpStencilFail: number;
  69866. stencilOpDepthFail: number;
  69867. stencilOpStencilDepthPass: number;
  69868. stencilMask: number;
  69869. stencilTest: boolean;
  69870. constructor();
  69871. reset(): void;
  69872. apply(gl: WebGLRenderingContext): void;
  69873. }
  69874. }
  69875. declare module BABYLON {
  69876. /**
  69877. * @hidden
  69878. **/
  69879. export class _TimeToken {
  69880. _startTimeQuery: Nullable<WebGLQuery>;
  69881. _endTimeQuery: Nullable<WebGLQuery>;
  69882. _timeElapsedQuery: Nullable<WebGLQuery>;
  69883. _timeElapsedQueryEnded: boolean;
  69884. }
  69885. }
  69886. declare module BABYLON {
  69887. /**
  69888. * Class used to evalaute queries containing `and` and `or` operators
  69889. */
  69890. export class AndOrNotEvaluator {
  69891. /**
  69892. * Evaluate a query
  69893. * @param query defines the query to evaluate
  69894. * @param evaluateCallback defines the callback used to filter result
  69895. * @returns true if the query matches
  69896. */
  69897. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69898. private static _HandleParenthesisContent;
  69899. private static _SimplifyNegation;
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. /**
  69904. * Class used to store custom tags
  69905. */
  69906. export class Tags {
  69907. /**
  69908. * Adds support for tags on the given object
  69909. * @param obj defines the object to use
  69910. */
  69911. static EnableFor(obj: any): void;
  69912. /**
  69913. * Removes tags support
  69914. * @param obj defines the object to use
  69915. */
  69916. static DisableFor(obj: any): void;
  69917. /**
  69918. * Gets a boolean indicating if the given object has tags
  69919. * @param obj defines the object to use
  69920. * @returns a boolean
  69921. */
  69922. static HasTags(obj: any): boolean;
  69923. /**
  69924. * Gets the tags available on a given object
  69925. * @param obj defines the object to use
  69926. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69927. * @returns the tags
  69928. */
  69929. static GetTags(obj: any, asString?: boolean): any;
  69930. /**
  69931. * Adds tags to an object
  69932. * @param obj defines the object to use
  69933. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69934. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69935. */
  69936. static AddTagsTo(obj: any, tagsString: string): void;
  69937. /**
  69938. * @hidden
  69939. */
  69940. static _AddTagTo(obj: any, tag: string): void;
  69941. /**
  69942. * Removes specific tags from a specific object
  69943. * @param obj defines the object to use
  69944. * @param tagsString defines the tags to remove
  69945. */
  69946. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69947. /**
  69948. * @hidden
  69949. */
  69950. static _RemoveTagFrom(obj: any, tag: string): void;
  69951. /**
  69952. * Defines if tags hosted on an object match a given query
  69953. * @param obj defines the object to use
  69954. * @param tagsQuery defines the tag query
  69955. * @returns a boolean
  69956. */
  69957. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /**
  69962. * Defines potential orientation for back face culling
  69963. */
  69964. export enum Orientation {
  69965. /**
  69966. * Clockwise
  69967. */
  69968. CW = 0,
  69969. /** Counter clockwise */
  69970. CCW = 1
  69971. }
  69972. /** Class used to represent a Bezier curve */
  69973. export class BezierCurve {
  69974. /**
  69975. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69976. * @param t defines the time
  69977. * @param x1 defines the left coordinate on X axis
  69978. * @param y1 defines the left coordinate on Y axis
  69979. * @param x2 defines the right coordinate on X axis
  69980. * @param y2 defines the right coordinate on Y axis
  69981. * @returns the interpolated value
  69982. */
  69983. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69984. }
  69985. /**
  69986. * Defines angle representation
  69987. */
  69988. export class Angle {
  69989. private _radians;
  69990. /**
  69991. * Creates an Angle object of "radians" radians (float).
  69992. * @param radians the angle in radians
  69993. */
  69994. constructor(radians: number);
  69995. /**
  69996. * Get value in degrees
  69997. * @returns the Angle value in degrees (float)
  69998. */
  69999. degrees(): number;
  70000. /**
  70001. * Get value in radians
  70002. * @returns the Angle value in radians (float)
  70003. */
  70004. radians(): number;
  70005. /**
  70006. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  70007. * @param a defines first vector
  70008. * @param b defines second vector
  70009. * @returns a new Angle
  70010. */
  70011. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  70012. /**
  70013. * Gets a new Angle object from the given float in radians
  70014. * @param radians defines the angle value in radians
  70015. * @returns a new Angle
  70016. */
  70017. static FromRadians(radians: number): Angle;
  70018. /**
  70019. * Gets a new Angle object from the given float in degrees
  70020. * @param degrees defines the angle value in degrees
  70021. * @returns a new Angle
  70022. */
  70023. static FromDegrees(degrees: number): Angle;
  70024. }
  70025. /**
  70026. * This represents an arc in a 2d space.
  70027. */
  70028. export class Arc2 {
  70029. /** Defines the start point of the arc */
  70030. startPoint: Vector2;
  70031. /** Defines the mid point of the arc */
  70032. midPoint: Vector2;
  70033. /** Defines the end point of the arc */
  70034. endPoint: Vector2;
  70035. /**
  70036. * Defines the center point of the arc.
  70037. */
  70038. centerPoint: Vector2;
  70039. /**
  70040. * Defines the radius of the arc.
  70041. */
  70042. radius: number;
  70043. /**
  70044. * Defines the angle of the arc (from mid point to end point).
  70045. */
  70046. angle: Angle;
  70047. /**
  70048. * Defines the start angle of the arc (from start point to middle point).
  70049. */
  70050. startAngle: Angle;
  70051. /**
  70052. * Defines the orientation of the arc (clock wise/counter clock wise).
  70053. */
  70054. orientation: Orientation;
  70055. /**
  70056. * Creates an Arc object from the three given points : start, middle and end.
  70057. * @param startPoint Defines the start point of the arc
  70058. * @param midPoint Defines the midlle point of the arc
  70059. * @param endPoint Defines the end point of the arc
  70060. */
  70061. constructor(
  70062. /** Defines the start point of the arc */
  70063. startPoint: Vector2,
  70064. /** Defines the mid point of the arc */
  70065. midPoint: Vector2,
  70066. /** Defines the end point of the arc */
  70067. endPoint: Vector2);
  70068. }
  70069. /**
  70070. * Represents a 2D path made up of multiple 2D points
  70071. */
  70072. export class Path2 {
  70073. private _points;
  70074. private _length;
  70075. /**
  70076. * If the path start and end point are the same
  70077. */
  70078. closed: boolean;
  70079. /**
  70080. * Creates a Path2 object from the starting 2D coordinates x and y.
  70081. * @param x the starting points x value
  70082. * @param y the starting points y value
  70083. */
  70084. constructor(x: number, y: number);
  70085. /**
  70086. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  70087. * @param x the added points x value
  70088. * @param y the added points y value
  70089. * @returns the updated Path2.
  70090. */
  70091. addLineTo(x: number, y: number): Path2;
  70092. /**
  70093. * 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.
  70094. * @param midX middle point x value
  70095. * @param midY middle point y value
  70096. * @param endX end point x value
  70097. * @param endY end point y value
  70098. * @param numberOfSegments (default: 36)
  70099. * @returns the updated Path2.
  70100. */
  70101. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  70102. /**
  70103. * Closes the Path2.
  70104. * @returns the Path2.
  70105. */
  70106. close(): Path2;
  70107. /**
  70108. * Gets the sum of the distance between each sequential point in the path
  70109. * @returns the Path2 total length (float).
  70110. */
  70111. length(): number;
  70112. /**
  70113. * Gets the points which construct the path
  70114. * @returns the Path2 internal array of points.
  70115. */
  70116. getPoints(): Vector2[];
  70117. /**
  70118. * Retreives the point at the distance aways from the starting point
  70119. * @param normalizedLengthPosition the length along the path to retreive the point from
  70120. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  70121. */
  70122. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  70123. /**
  70124. * Creates a new path starting from an x and y position
  70125. * @param x starting x value
  70126. * @param y starting y value
  70127. * @returns a new Path2 starting at the coordinates (x, y).
  70128. */
  70129. static StartingAt(x: number, y: number): Path2;
  70130. }
  70131. /**
  70132. * Represents a 3D path made up of multiple 3D points
  70133. */
  70134. export class Path3D {
  70135. /**
  70136. * an array of Vector3, the curve axis of the Path3D
  70137. */
  70138. path: Vector3[];
  70139. private _curve;
  70140. private _distances;
  70141. private _tangents;
  70142. private _normals;
  70143. private _binormals;
  70144. private _raw;
  70145. /**
  70146. * new Path3D(path, normal, raw)
  70147. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  70148. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  70149. * @param path an array of Vector3, the curve axis of the Path3D
  70150. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  70151. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  70152. */
  70153. constructor(
  70154. /**
  70155. * an array of Vector3, the curve axis of the Path3D
  70156. */
  70157. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  70158. /**
  70159. * Returns the Path3D array of successive Vector3 designing its curve.
  70160. * @returns the Path3D array of successive Vector3 designing its curve.
  70161. */
  70162. getCurve(): Vector3[];
  70163. /**
  70164. * Returns an array populated with tangent vectors on each Path3D curve point.
  70165. * @returns an array populated with tangent vectors on each Path3D curve point.
  70166. */
  70167. getTangents(): Vector3[];
  70168. /**
  70169. * Returns an array populated with normal vectors on each Path3D curve point.
  70170. * @returns an array populated with normal vectors on each Path3D curve point.
  70171. */
  70172. getNormals(): Vector3[];
  70173. /**
  70174. * Returns an array populated with binormal vectors on each Path3D curve point.
  70175. * @returns an array populated with binormal vectors on each Path3D curve point.
  70176. */
  70177. getBinormals(): Vector3[];
  70178. /**
  70179. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  70180. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  70181. */
  70182. getDistances(): number[];
  70183. /**
  70184. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  70185. * @param path path which all values are copied into the curves points
  70186. * @param firstNormal which should be projected onto the curve
  70187. * @returns the same object updated.
  70188. */
  70189. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  70190. private _compute;
  70191. private _getFirstNonNullVector;
  70192. private _getLastNonNullVector;
  70193. private _normalVector;
  70194. }
  70195. /**
  70196. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70197. * A Curve3 is designed from a series of successive Vector3.
  70198. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  70199. */
  70200. export class Curve3 {
  70201. private _points;
  70202. private _length;
  70203. /**
  70204. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  70205. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  70206. * @param v1 (Vector3) the control point
  70207. * @param v2 (Vector3) the end point of the Quadratic Bezier
  70208. * @param nbPoints (integer) the wanted number of points in the curve
  70209. * @returns the created Curve3
  70210. */
  70211. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70212. /**
  70213. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  70214. * @param v0 (Vector3) the origin point of the Cubic Bezier
  70215. * @param v1 (Vector3) the first control point
  70216. * @param v2 (Vector3) the second control point
  70217. * @param v3 (Vector3) the end point of the Cubic Bezier
  70218. * @param nbPoints (integer) the wanted number of points in the curve
  70219. * @returns the created Curve3
  70220. */
  70221. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70222. /**
  70223. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  70224. * @param p1 (Vector3) the origin point of the Hermite Spline
  70225. * @param t1 (Vector3) the tangent vector at the origin point
  70226. * @param p2 (Vector3) the end point of the Hermite Spline
  70227. * @param t2 (Vector3) the tangent vector at the end point
  70228. * @param nbPoints (integer) the wanted number of points in the curve
  70229. * @returns the created Curve3
  70230. */
  70231. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  70232. /**
  70233. * Returns a Curve3 object along a CatmullRom Spline curve :
  70234. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  70235. * @param nbPoints (integer) the wanted number of points between each curve control points
  70236. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  70237. * @returns the created Curve3
  70238. */
  70239. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  70240. /**
  70241. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  70242. * A Curve3 is designed from a series of successive Vector3.
  70243. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  70244. * @param points points which make up the curve
  70245. */
  70246. constructor(points: Vector3[]);
  70247. /**
  70248. * @returns the Curve3 stored array of successive Vector3
  70249. */
  70250. getPoints(): Vector3[];
  70251. /**
  70252. * @returns the computed length (float) of the curve.
  70253. */
  70254. length(): number;
  70255. /**
  70256. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  70257. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  70258. * curveA and curveB keep unchanged.
  70259. * @param curve the curve to continue from this curve
  70260. * @returns the newly constructed curve
  70261. */
  70262. continue(curve: DeepImmutable<Curve3>): Curve3;
  70263. private _computeLength;
  70264. }
  70265. }
  70266. declare module BABYLON {
  70267. /**
  70268. * This represents the main contract an easing function should follow.
  70269. * Easing functions are used throughout the animation system.
  70270. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70271. */
  70272. export interface IEasingFunction {
  70273. /**
  70274. * Given an input gradient between 0 and 1, this returns the corrseponding value
  70275. * of the easing function.
  70276. * The link below provides some of the most common examples of easing functions.
  70277. * @see https://easings.net/
  70278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70279. * @returns the corresponding value on the curve defined by the easing function
  70280. */
  70281. ease(gradient: number): number;
  70282. }
  70283. /**
  70284. * Base class used for every default easing function.
  70285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70286. */
  70287. export class EasingFunction implements IEasingFunction {
  70288. /**
  70289. * Interpolation follows the mathematical formula associated with the easing function.
  70290. */
  70291. static readonly EASINGMODE_EASEIN: number;
  70292. /**
  70293. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  70294. */
  70295. static readonly EASINGMODE_EASEOUT: number;
  70296. /**
  70297. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  70298. */
  70299. static readonly EASINGMODE_EASEINOUT: number;
  70300. private _easingMode;
  70301. /**
  70302. * Sets the easing mode of the current function.
  70303. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  70304. */
  70305. setEasingMode(easingMode: number): void;
  70306. /**
  70307. * Gets the current easing mode.
  70308. * @returns the easing mode
  70309. */
  70310. getEasingMode(): number;
  70311. /**
  70312. * @hidden
  70313. */
  70314. easeInCore(gradient: number): number;
  70315. /**
  70316. * Given an input gradient between 0 and 1, this returns the corresponding value
  70317. * of the easing function.
  70318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70319. * @returns the corresponding value on the curve defined by the easing function
  70320. */
  70321. ease(gradient: number): number;
  70322. }
  70323. /**
  70324. * Easing function with a circle shape (see link below).
  70325. * @see https://easings.net/#easeInCirc
  70326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70327. */
  70328. export class CircleEase extends EasingFunction implements IEasingFunction {
  70329. /** @hidden */
  70330. easeInCore(gradient: number): number;
  70331. }
  70332. /**
  70333. * Easing function with a ease back shape (see link below).
  70334. * @see https://easings.net/#easeInBack
  70335. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70336. */
  70337. export class BackEase extends EasingFunction implements IEasingFunction {
  70338. /** Defines the amplitude of the function */
  70339. amplitude: number;
  70340. /**
  70341. * Instantiates a back ease easing
  70342. * @see https://easings.net/#easeInBack
  70343. * @param amplitude Defines the amplitude of the function
  70344. */
  70345. constructor(
  70346. /** Defines the amplitude of the function */
  70347. amplitude?: number);
  70348. /** @hidden */
  70349. easeInCore(gradient: number): number;
  70350. }
  70351. /**
  70352. * Easing function with a bouncing shape (see link below).
  70353. * @see https://easings.net/#easeInBounce
  70354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70355. */
  70356. export class BounceEase extends EasingFunction implements IEasingFunction {
  70357. /** Defines the number of bounces */
  70358. bounces: number;
  70359. /** Defines the amplitude of the bounce */
  70360. bounciness: number;
  70361. /**
  70362. * Instantiates a bounce easing
  70363. * @see https://easings.net/#easeInBounce
  70364. * @param bounces Defines the number of bounces
  70365. * @param bounciness Defines the amplitude of the bounce
  70366. */
  70367. constructor(
  70368. /** Defines the number of bounces */
  70369. bounces?: number,
  70370. /** Defines the amplitude of the bounce */
  70371. bounciness?: number);
  70372. /** @hidden */
  70373. easeInCore(gradient: number): number;
  70374. }
  70375. /**
  70376. * Easing function with a power of 3 shape (see link below).
  70377. * @see https://easings.net/#easeInCubic
  70378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70379. */
  70380. export class CubicEase extends EasingFunction implements IEasingFunction {
  70381. /** @hidden */
  70382. easeInCore(gradient: number): number;
  70383. }
  70384. /**
  70385. * Easing function with an elastic shape (see link below).
  70386. * @see https://easings.net/#easeInElastic
  70387. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70388. */
  70389. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70390. /** Defines the number of oscillations*/
  70391. oscillations: number;
  70392. /** Defines the amplitude of the oscillations*/
  70393. springiness: number;
  70394. /**
  70395. * Instantiates an elastic easing function
  70396. * @see https://easings.net/#easeInElastic
  70397. * @param oscillations Defines the number of oscillations
  70398. * @param springiness Defines the amplitude of the oscillations
  70399. */
  70400. constructor(
  70401. /** Defines the number of oscillations*/
  70402. oscillations?: number,
  70403. /** Defines the amplitude of the oscillations*/
  70404. springiness?: number);
  70405. /** @hidden */
  70406. easeInCore(gradient: number): number;
  70407. }
  70408. /**
  70409. * Easing function with an exponential shape (see link below).
  70410. * @see https://easings.net/#easeInExpo
  70411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70412. */
  70413. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70414. /** Defines the exponent of the function */
  70415. exponent: number;
  70416. /**
  70417. * Instantiates an exponential easing function
  70418. * @see https://easings.net/#easeInExpo
  70419. * @param exponent Defines the exponent of the function
  70420. */
  70421. constructor(
  70422. /** Defines the exponent of the function */
  70423. exponent?: number);
  70424. /** @hidden */
  70425. easeInCore(gradient: number): number;
  70426. }
  70427. /**
  70428. * Easing function with a power shape (see link below).
  70429. * @see https://easings.net/#easeInQuad
  70430. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70431. */
  70432. export class PowerEase extends EasingFunction implements IEasingFunction {
  70433. /** Defines the power of the function */
  70434. power: number;
  70435. /**
  70436. * Instantiates an power base easing function
  70437. * @see https://easings.net/#easeInQuad
  70438. * @param power Defines the power of the function
  70439. */
  70440. constructor(
  70441. /** Defines the power of the function */
  70442. power?: number);
  70443. /** @hidden */
  70444. easeInCore(gradient: number): number;
  70445. }
  70446. /**
  70447. * Easing function with a power of 2 shape (see link below).
  70448. * @see https://easings.net/#easeInQuad
  70449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70450. */
  70451. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70452. /** @hidden */
  70453. easeInCore(gradient: number): number;
  70454. }
  70455. /**
  70456. * Easing function with a power of 4 shape (see link below).
  70457. * @see https://easings.net/#easeInQuart
  70458. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70459. */
  70460. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70461. /** @hidden */
  70462. easeInCore(gradient: number): number;
  70463. }
  70464. /**
  70465. * Easing function with a power of 5 shape (see link below).
  70466. * @see https://easings.net/#easeInQuint
  70467. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70468. */
  70469. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70470. /** @hidden */
  70471. easeInCore(gradient: number): number;
  70472. }
  70473. /**
  70474. * Easing function with a sin shape (see link below).
  70475. * @see https://easings.net/#easeInSine
  70476. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70477. */
  70478. export class SineEase extends EasingFunction implements IEasingFunction {
  70479. /** @hidden */
  70480. easeInCore(gradient: number): number;
  70481. }
  70482. /**
  70483. * Easing function with a bezier shape (see link below).
  70484. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70485. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70486. */
  70487. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70488. /** Defines the x component of the start tangent in the bezier curve */
  70489. x1: number;
  70490. /** Defines the y component of the start tangent in the bezier curve */
  70491. y1: number;
  70492. /** Defines the x component of the end tangent in the bezier curve */
  70493. x2: number;
  70494. /** Defines the y component of the end tangent in the bezier curve */
  70495. y2: number;
  70496. /**
  70497. * Instantiates a bezier function
  70498. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70499. * @param x1 Defines the x component of the start tangent in the bezier curve
  70500. * @param y1 Defines the y component of the start tangent in the bezier curve
  70501. * @param x2 Defines the x component of the end tangent in the bezier curve
  70502. * @param y2 Defines the y component of the end tangent in the bezier curve
  70503. */
  70504. constructor(
  70505. /** Defines the x component of the start tangent in the bezier curve */
  70506. x1?: number,
  70507. /** Defines the y component of the start tangent in the bezier curve */
  70508. y1?: number,
  70509. /** Defines the x component of the end tangent in the bezier curve */
  70510. x2?: number,
  70511. /** Defines the y component of the end tangent in the bezier curve */
  70512. y2?: number);
  70513. /** @hidden */
  70514. easeInCore(gradient: number): number;
  70515. }
  70516. }
  70517. declare module BABYLON {
  70518. /**
  70519. * Defines an interface which represents an animation key frame
  70520. */
  70521. export interface IAnimationKey {
  70522. /**
  70523. * Frame of the key frame
  70524. */
  70525. frame: number;
  70526. /**
  70527. * Value at the specifies key frame
  70528. */
  70529. value: any;
  70530. /**
  70531. * The input tangent for the cubic hermite spline
  70532. */
  70533. inTangent?: any;
  70534. /**
  70535. * The output tangent for the cubic hermite spline
  70536. */
  70537. outTangent?: any;
  70538. /**
  70539. * The animation interpolation type
  70540. */
  70541. interpolation?: AnimationKeyInterpolation;
  70542. }
  70543. /**
  70544. * Enum for the animation key frame interpolation type
  70545. */
  70546. export enum AnimationKeyInterpolation {
  70547. /**
  70548. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70549. */
  70550. STEP = 1
  70551. }
  70552. }
  70553. declare module BABYLON {
  70554. /**
  70555. * Represents the range of an animation
  70556. */
  70557. export class AnimationRange {
  70558. /**The name of the animation range**/
  70559. name: string;
  70560. /**The starting frame of the animation */
  70561. from: number;
  70562. /**The ending frame of the animation*/
  70563. to: number;
  70564. /**
  70565. * Initializes the range of an animation
  70566. * @param name The name of the animation range
  70567. * @param from The starting frame of the animation
  70568. * @param to The ending frame of the animation
  70569. */
  70570. constructor(
  70571. /**The name of the animation range**/
  70572. name: string,
  70573. /**The starting frame of the animation */
  70574. from: number,
  70575. /**The ending frame of the animation*/
  70576. to: number);
  70577. /**
  70578. * Makes a copy of the animation range
  70579. * @returns A copy of the animation range
  70580. */
  70581. clone(): AnimationRange;
  70582. }
  70583. }
  70584. declare module BABYLON {
  70585. /**
  70586. * Composed of a frame, and an action function
  70587. */
  70588. export class AnimationEvent {
  70589. /** The frame for which the event is triggered **/
  70590. frame: number;
  70591. /** The event to perform when triggered **/
  70592. action: (currentFrame: number) => void;
  70593. /** Specifies if the event should be triggered only once**/
  70594. onlyOnce?: boolean | undefined;
  70595. /**
  70596. * Specifies if the animation event is done
  70597. */
  70598. isDone: boolean;
  70599. /**
  70600. * Initializes the animation event
  70601. * @param frame The frame for which the event is triggered
  70602. * @param action The event to perform when triggered
  70603. * @param onlyOnce Specifies if the event should be triggered only once
  70604. */
  70605. constructor(
  70606. /** The frame for which the event is triggered **/
  70607. frame: number,
  70608. /** The event to perform when triggered **/
  70609. action: (currentFrame: number) => void,
  70610. /** Specifies if the event should be triggered only once**/
  70611. onlyOnce?: boolean | undefined);
  70612. /** @hidden */
  70613. _clone(): AnimationEvent;
  70614. }
  70615. }
  70616. declare module BABYLON {
  70617. /**
  70618. * Interface used to define a behavior
  70619. */
  70620. export interface Behavior<T> {
  70621. /** gets or sets behavior's name */
  70622. name: string;
  70623. /**
  70624. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70625. */
  70626. init(): void;
  70627. /**
  70628. * Called when the behavior is attached to a target
  70629. * @param target defines the target where the behavior is attached to
  70630. */
  70631. attach(target: T): void;
  70632. /**
  70633. * Called when the behavior is detached from its target
  70634. */
  70635. detach(): void;
  70636. }
  70637. /**
  70638. * Interface implemented by classes supporting behaviors
  70639. */
  70640. export interface IBehaviorAware<T> {
  70641. /**
  70642. * Attach a behavior
  70643. * @param behavior defines the behavior to attach
  70644. * @returns the current host
  70645. */
  70646. addBehavior(behavior: Behavior<T>): T;
  70647. /**
  70648. * Remove a behavior from the current object
  70649. * @param behavior defines the behavior to detach
  70650. * @returns the current host
  70651. */
  70652. removeBehavior(behavior: Behavior<T>): T;
  70653. /**
  70654. * Gets a behavior using its name to search
  70655. * @param name defines the name to search
  70656. * @returns the behavior or null if not found
  70657. */
  70658. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70659. }
  70660. }
  70661. declare module BABYLON {
  70662. /**
  70663. * Defines an array and its length.
  70664. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70665. */
  70666. export interface ISmartArrayLike<T> {
  70667. /**
  70668. * The data of the array.
  70669. */
  70670. data: Array<T>;
  70671. /**
  70672. * The active length of the array.
  70673. */
  70674. length: number;
  70675. }
  70676. /**
  70677. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70678. */
  70679. export class SmartArray<T> implements ISmartArrayLike<T> {
  70680. /**
  70681. * The full set of data from the array.
  70682. */
  70683. data: Array<T>;
  70684. /**
  70685. * The active length of the array.
  70686. */
  70687. length: number;
  70688. protected _id: number;
  70689. /**
  70690. * Instantiates a Smart Array.
  70691. * @param capacity defines the default capacity of the array.
  70692. */
  70693. constructor(capacity: number);
  70694. /**
  70695. * Pushes a value at the end of the active data.
  70696. * @param value defines the object to push in the array.
  70697. */
  70698. push(value: T): void;
  70699. /**
  70700. * Iterates over the active data and apply the lambda to them.
  70701. * @param func defines the action to apply on each value.
  70702. */
  70703. forEach(func: (content: T) => void): void;
  70704. /**
  70705. * Sorts the full sets of data.
  70706. * @param compareFn defines the comparison function to apply.
  70707. */
  70708. sort(compareFn: (a: T, b: T) => number): void;
  70709. /**
  70710. * Resets the active data to an empty array.
  70711. */
  70712. reset(): void;
  70713. /**
  70714. * Releases all the data from the array as well as the array.
  70715. */
  70716. dispose(): void;
  70717. /**
  70718. * Concats the active data with a given array.
  70719. * @param array defines the data to concatenate with.
  70720. */
  70721. concat(array: any): void;
  70722. /**
  70723. * Returns the position of a value in the active data.
  70724. * @param value defines the value to find the index for
  70725. * @returns the index if found in the active data otherwise -1
  70726. */
  70727. indexOf(value: T): number;
  70728. /**
  70729. * Returns whether an element is part of the active data.
  70730. * @param value defines the value to look for
  70731. * @returns true if found in the active data otherwise false
  70732. */
  70733. contains(value: T): boolean;
  70734. private static _GlobalId;
  70735. }
  70736. /**
  70737. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70738. * The data in this array can only be present once
  70739. */
  70740. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70741. private _duplicateId;
  70742. /**
  70743. * Pushes a value at the end of the active data.
  70744. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70745. * @param value defines the object to push in the array.
  70746. */
  70747. push(value: T): void;
  70748. /**
  70749. * Pushes a value at the end of the active data.
  70750. * If the data is already present, it won t be added again
  70751. * @param value defines the object to push in the array.
  70752. * @returns true if added false if it was already present
  70753. */
  70754. pushNoDuplicate(value: T): boolean;
  70755. /**
  70756. * Resets the active data to an empty array.
  70757. */
  70758. reset(): void;
  70759. /**
  70760. * Concats the active data with a given array.
  70761. * This ensures no dupplicate will be present in the result.
  70762. * @param array defines the data to concatenate with.
  70763. */
  70764. concatWithNoDuplicate(array: any): void;
  70765. }
  70766. }
  70767. declare module BABYLON {
  70768. /**
  70769. * @ignore
  70770. * This is a list of all the different input types that are available in the application.
  70771. * Fo instance: ArcRotateCameraGamepadInput...
  70772. */
  70773. export var CameraInputTypes: {};
  70774. /**
  70775. * This is the contract to implement in order to create a new input class.
  70776. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70777. */
  70778. export interface ICameraInput<TCamera extends Camera> {
  70779. /**
  70780. * Defines the camera the input is attached to.
  70781. */
  70782. camera: Nullable<TCamera>;
  70783. /**
  70784. * Gets the class name of the current intput.
  70785. * @returns the class name
  70786. */
  70787. getClassName(): string;
  70788. /**
  70789. * Get the friendly name associated with the input class.
  70790. * @returns the input friendly name
  70791. */
  70792. getSimpleName(): string;
  70793. /**
  70794. * Attach the input controls to a specific dom element to get the input from.
  70795. * @param element Defines the element the controls should be listened from
  70796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70797. */
  70798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70799. /**
  70800. * Detach the current controls from the specified dom element.
  70801. * @param element Defines the element to stop listening the inputs from
  70802. */
  70803. detachControl(element: Nullable<HTMLElement>): void;
  70804. /**
  70805. * Update the current camera state depending on the inputs that have been used this frame.
  70806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70807. */
  70808. checkInputs?: () => void;
  70809. }
  70810. /**
  70811. * Represents a map of input types to input instance or input index to input instance.
  70812. */
  70813. export interface CameraInputsMap<TCamera extends Camera> {
  70814. /**
  70815. * Accessor to the input by input type.
  70816. */
  70817. [name: string]: ICameraInput<TCamera>;
  70818. /**
  70819. * Accessor to the input by input index.
  70820. */
  70821. [idx: number]: ICameraInput<TCamera>;
  70822. }
  70823. /**
  70824. * This represents the input manager used within a camera.
  70825. * It helps dealing with all the different kind of input attached to a camera.
  70826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70827. */
  70828. export class CameraInputsManager<TCamera extends Camera> {
  70829. /**
  70830. * Defines the list of inputs attahed to the camera.
  70831. */
  70832. attached: CameraInputsMap<TCamera>;
  70833. /**
  70834. * Defines the dom element the camera is collecting inputs from.
  70835. * This is null if the controls have not been attached.
  70836. */
  70837. attachedElement: Nullable<HTMLElement>;
  70838. /**
  70839. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70840. */
  70841. noPreventDefault: boolean;
  70842. /**
  70843. * Defined the camera the input manager belongs to.
  70844. */
  70845. camera: TCamera;
  70846. /**
  70847. * Update the current camera state depending on the inputs that have been used this frame.
  70848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70849. */
  70850. checkInputs: () => void;
  70851. /**
  70852. * Instantiate a new Camera Input Manager.
  70853. * @param camera Defines the camera the input manager blongs to
  70854. */
  70855. constructor(camera: TCamera);
  70856. /**
  70857. * Add an input method to a camera
  70858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70859. * @param input camera input method
  70860. */
  70861. add(input: ICameraInput<TCamera>): void;
  70862. /**
  70863. * Remove a specific input method from a camera
  70864. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70865. * @param inputToRemove camera input method
  70866. */
  70867. remove(inputToRemove: ICameraInput<TCamera>): void;
  70868. /**
  70869. * Remove a specific input type from a camera
  70870. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70871. * @param inputType the type of the input to remove
  70872. */
  70873. removeByType(inputType: string): void;
  70874. private _addCheckInputs;
  70875. /**
  70876. * Attach the input controls to the currently attached dom element to listen the events from.
  70877. * @param input Defines the input to attach
  70878. */
  70879. attachInput(input: ICameraInput<TCamera>): void;
  70880. /**
  70881. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70882. * @param element Defines the dom element to collect the events from
  70883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70884. */
  70885. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70886. /**
  70887. * Detach the current manager inputs controls from a specific dom element.
  70888. * @param element Defines the dom element to collect the events from
  70889. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70890. */
  70891. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70892. /**
  70893. * Rebuild the dynamic inputCheck function from the current list of
  70894. * defined inputs in the manager.
  70895. */
  70896. rebuildInputCheck(): void;
  70897. /**
  70898. * Remove all attached input methods from a camera
  70899. */
  70900. clear(): void;
  70901. /**
  70902. * Serialize the current input manager attached to a camera.
  70903. * This ensures than once parsed,
  70904. * the input associated to the camera will be identical to the current ones
  70905. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70906. */
  70907. serialize(serializedCamera: any): void;
  70908. /**
  70909. * Parses an input manager serialized JSON to restore the previous list of inputs
  70910. * and states associated to a camera.
  70911. * @param parsedCamera Defines the JSON to parse
  70912. */
  70913. parse(parsedCamera: any): void;
  70914. }
  70915. }
  70916. declare module BABYLON {
  70917. /**
  70918. * @hidden
  70919. */
  70920. export class IntersectionInfo {
  70921. bu: Nullable<number>;
  70922. bv: Nullable<number>;
  70923. distance: number;
  70924. faceId: number;
  70925. subMeshId: number;
  70926. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70927. }
  70928. }
  70929. declare module BABYLON {
  70930. /**
  70931. * Represens a plane by the equation ax + by + cz + d = 0
  70932. */
  70933. export class Plane {
  70934. private static _TmpMatrix;
  70935. /**
  70936. * Normal of the plane (a,b,c)
  70937. */
  70938. normal: Vector3;
  70939. /**
  70940. * d component of the plane
  70941. */
  70942. d: number;
  70943. /**
  70944. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70945. * @param a a component of the plane
  70946. * @param b b component of the plane
  70947. * @param c c component of the plane
  70948. * @param d d component of the plane
  70949. */
  70950. constructor(a: number, b: number, c: number, d: number);
  70951. /**
  70952. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70953. */
  70954. asArray(): number[];
  70955. /**
  70956. * @returns a new plane copied from the current Plane.
  70957. */
  70958. clone(): Plane;
  70959. /**
  70960. * @returns the string "Plane".
  70961. */
  70962. getClassName(): string;
  70963. /**
  70964. * @returns the Plane hash code.
  70965. */
  70966. getHashCode(): number;
  70967. /**
  70968. * Normalize the current Plane in place.
  70969. * @returns the updated Plane.
  70970. */
  70971. normalize(): Plane;
  70972. /**
  70973. * Applies a transformation the plane and returns the result
  70974. * @param transformation the transformation matrix to be applied to the plane
  70975. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70976. */
  70977. transform(transformation: DeepImmutable<Matrix>): Plane;
  70978. /**
  70979. * Calcualtte the dot product between the point and the plane normal
  70980. * @param point point to calculate the dot product with
  70981. * @returns the dot product (float) of the point coordinates and the plane normal.
  70982. */
  70983. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70984. /**
  70985. * Updates the current Plane from the plane defined by the three given points.
  70986. * @param point1 one of the points used to contruct the plane
  70987. * @param point2 one of the points used to contruct the plane
  70988. * @param point3 one of the points used to contruct the plane
  70989. * @returns the updated Plane.
  70990. */
  70991. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70992. /**
  70993. * Checks if the plane is facing a given direction
  70994. * @param direction the direction to check if the plane is facing
  70995. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70996. * @returns True is the vector "direction" is the same side than the plane normal.
  70997. */
  70998. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70999. /**
  71000. * Calculates the distance to a point
  71001. * @param point point to calculate distance to
  71002. * @returns the signed distance (float) from the given point to the Plane.
  71003. */
  71004. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  71005. /**
  71006. * Creates a plane from an array
  71007. * @param array the array to create a plane from
  71008. * @returns a new Plane from the given array.
  71009. */
  71010. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  71011. /**
  71012. * Creates a plane from three points
  71013. * @param point1 point used to create the plane
  71014. * @param point2 point used to create the plane
  71015. * @param point3 point used to create the plane
  71016. * @returns a new Plane defined by the three given points.
  71017. */
  71018. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  71019. /**
  71020. * Creates a plane from an origin point and a normal
  71021. * @param origin origin of the plane to be constructed
  71022. * @param normal normal of the plane to be constructed
  71023. * @returns a new Plane the normal vector to this plane at the given origin point.
  71024. * Note : the vector "normal" is updated because normalized.
  71025. */
  71026. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  71027. /**
  71028. * Calculates the distance from a plane and a point
  71029. * @param origin origin of the plane to be constructed
  71030. * @param normal normal of the plane to be constructed
  71031. * @param point point to calculate distance to
  71032. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  71033. */
  71034. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  71035. }
  71036. }
  71037. declare module BABYLON {
  71038. /**
  71039. * Class used to store bounding sphere information
  71040. */
  71041. export class BoundingSphere {
  71042. /**
  71043. * Gets the center of the bounding sphere in local space
  71044. */
  71045. readonly center: Vector3;
  71046. /**
  71047. * Radius of the bounding sphere in local space
  71048. */
  71049. radius: number;
  71050. /**
  71051. * Gets the center of the bounding sphere in world space
  71052. */
  71053. readonly centerWorld: Vector3;
  71054. /**
  71055. * Radius of the bounding sphere in world space
  71056. */
  71057. radiusWorld: number;
  71058. /**
  71059. * Gets the minimum vector in local space
  71060. */
  71061. readonly minimum: Vector3;
  71062. /**
  71063. * Gets the maximum vector in local space
  71064. */
  71065. readonly maximum: Vector3;
  71066. private _worldMatrix;
  71067. private static readonly TmpVector3;
  71068. /**
  71069. * Creates a new bounding sphere
  71070. * @param min defines the minimum vector (in local space)
  71071. * @param max defines the maximum vector (in local space)
  71072. * @param worldMatrix defines the new world matrix
  71073. */
  71074. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71075. /**
  71076. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  71077. * @param min defines the new minimum vector (in local space)
  71078. * @param max defines the new maximum vector (in local space)
  71079. * @param worldMatrix defines the new world matrix
  71080. */
  71081. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71082. /**
  71083. * Scale the current bounding sphere by applying a scale factor
  71084. * @param factor defines the scale factor to apply
  71085. * @returns the current bounding box
  71086. */
  71087. scale(factor: number): BoundingSphere;
  71088. /**
  71089. * Gets the world matrix of the bounding box
  71090. * @returns a matrix
  71091. */
  71092. getWorldMatrix(): DeepImmutable<Matrix>;
  71093. /** @hidden */
  71094. _update(worldMatrix: DeepImmutable<Matrix>): void;
  71095. /**
  71096. * Tests if the bounding sphere is intersecting the frustum planes
  71097. * @param frustumPlanes defines the frustum planes to test
  71098. * @returns true if there is an intersection
  71099. */
  71100. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71101. /**
  71102. * Tests if the bounding sphere center is in between the frustum planes.
  71103. * Used for optimistic fast inclusion.
  71104. * @param frustumPlanes defines the frustum planes to test
  71105. * @returns true if the sphere center is in between the frustum planes
  71106. */
  71107. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71108. /**
  71109. * Tests if a point is inside the bounding sphere
  71110. * @param point defines the point to test
  71111. * @returns true if the point is inside the bounding sphere
  71112. */
  71113. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71114. /**
  71115. * Checks if two sphere intersct
  71116. * @param sphere0 sphere 0
  71117. * @param sphere1 sphere 1
  71118. * @returns true if the speres intersect
  71119. */
  71120. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  71121. }
  71122. }
  71123. declare module BABYLON {
  71124. /**
  71125. * Class used to store bounding box information
  71126. */
  71127. export class BoundingBox implements ICullable {
  71128. /**
  71129. * Gets the 8 vectors representing the bounding box in local space
  71130. */
  71131. readonly vectors: Vector3[];
  71132. /**
  71133. * Gets the center of the bounding box in local space
  71134. */
  71135. readonly center: Vector3;
  71136. /**
  71137. * Gets the center of the bounding box in world space
  71138. */
  71139. readonly centerWorld: Vector3;
  71140. /**
  71141. * Gets the extend size in local space
  71142. */
  71143. readonly extendSize: Vector3;
  71144. /**
  71145. * Gets the extend size in world space
  71146. */
  71147. readonly extendSizeWorld: Vector3;
  71148. /**
  71149. * Gets the OBB (object bounding box) directions
  71150. */
  71151. readonly directions: Vector3[];
  71152. /**
  71153. * Gets the 8 vectors representing the bounding box in world space
  71154. */
  71155. readonly vectorsWorld: Vector3[];
  71156. /**
  71157. * Gets the minimum vector in world space
  71158. */
  71159. readonly minimumWorld: Vector3;
  71160. /**
  71161. * Gets the maximum vector in world space
  71162. */
  71163. readonly maximumWorld: Vector3;
  71164. /**
  71165. * Gets the minimum vector in local space
  71166. */
  71167. readonly minimum: Vector3;
  71168. /**
  71169. * Gets the maximum vector in local space
  71170. */
  71171. readonly maximum: Vector3;
  71172. private _worldMatrix;
  71173. private static readonly TmpVector3;
  71174. /**
  71175. * @hidden
  71176. */
  71177. _tag: number;
  71178. /**
  71179. * Creates a new bounding box
  71180. * @param min defines the minimum vector (in local space)
  71181. * @param max defines the maximum vector (in local space)
  71182. * @param worldMatrix defines the new world matrix
  71183. */
  71184. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71185. /**
  71186. * Recreates the entire bounding box from scratch as if we call the constructor in place
  71187. * @param min defines the new minimum vector (in local space)
  71188. * @param max defines the new maximum vector (in local space)
  71189. * @param worldMatrix defines the new world matrix
  71190. */
  71191. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71192. /**
  71193. * Scale the current bounding box by applying a scale factor
  71194. * @param factor defines the scale factor to apply
  71195. * @returns the current bounding box
  71196. */
  71197. scale(factor: number): BoundingBox;
  71198. /**
  71199. * Gets the world matrix of the bounding box
  71200. * @returns a matrix
  71201. */
  71202. getWorldMatrix(): DeepImmutable<Matrix>;
  71203. /** @hidden */
  71204. _update(world: DeepImmutable<Matrix>): void;
  71205. /**
  71206. * Tests if the bounding box is intersecting the frustum planes
  71207. * @param frustumPlanes defines the frustum planes to test
  71208. * @returns true if there is an intersection
  71209. */
  71210. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71211. /**
  71212. * Tests if the bounding box is entirely inside the frustum planes
  71213. * @param frustumPlanes defines the frustum planes to test
  71214. * @returns true if there is an inclusion
  71215. */
  71216. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71217. /**
  71218. * Tests if a point is inside the bounding box
  71219. * @param point defines the point to test
  71220. * @returns true if the point is inside the bounding box
  71221. */
  71222. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71223. /**
  71224. * Tests if the bounding box intersects with a bounding sphere
  71225. * @param sphere defines the sphere to test
  71226. * @returns true if there is an intersection
  71227. */
  71228. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  71229. /**
  71230. * Tests if the bounding box intersects with a box defined by a min and max vectors
  71231. * @param min defines the min vector to use
  71232. * @param max defines the max vector to use
  71233. * @returns true if there is an intersection
  71234. */
  71235. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  71236. /**
  71237. * Tests if two bounding boxes are intersections
  71238. * @param box0 defines the first box to test
  71239. * @param box1 defines the second box to test
  71240. * @returns true if there is an intersection
  71241. */
  71242. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  71243. /**
  71244. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  71245. * @param minPoint defines the minimum vector of the bounding box
  71246. * @param maxPoint defines the maximum vector of the bounding box
  71247. * @param sphereCenter defines the sphere center
  71248. * @param sphereRadius defines the sphere radius
  71249. * @returns true if there is an intersection
  71250. */
  71251. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  71252. /**
  71253. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  71254. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71255. * @param frustumPlanes defines the frustum planes to test
  71256. * @return true if there is an inclusion
  71257. */
  71258. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71259. /**
  71260. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  71261. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  71262. * @param frustumPlanes defines the frustum planes to test
  71263. * @return true if there is an intersection
  71264. */
  71265. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71266. }
  71267. }
  71268. declare module BABYLON {
  71269. /** @hidden */
  71270. export class Collider {
  71271. /** Define if a collision was found */
  71272. collisionFound: boolean;
  71273. /**
  71274. * Define last intersection point in local space
  71275. */
  71276. intersectionPoint: Vector3;
  71277. /**
  71278. * Define last collided mesh
  71279. */
  71280. collidedMesh: Nullable<AbstractMesh>;
  71281. private _collisionPoint;
  71282. private _planeIntersectionPoint;
  71283. private _tempVector;
  71284. private _tempVector2;
  71285. private _tempVector3;
  71286. private _tempVector4;
  71287. private _edge;
  71288. private _baseToVertex;
  71289. private _destinationPoint;
  71290. private _slidePlaneNormal;
  71291. private _displacementVector;
  71292. /** @hidden */
  71293. _radius: Vector3;
  71294. /** @hidden */
  71295. _retry: number;
  71296. private _velocity;
  71297. private _basePoint;
  71298. private _epsilon;
  71299. /** @hidden */
  71300. _velocityWorldLength: number;
  71301. /** @hidden */
  71302. _basePointWorld: Vector3;
  71303. private _velocityWorld;
  71304. private _normalizedVelocity;
  71305. /** @hidden */
  71306. _initialVelocity: Vector3;
  71307. /** @hidden */
  71308. _initialPosition: Vector3;
  71309. private _nearestDistance;
  71310. private _collisionMask;
  71311. collisionMask: number;
  71312. /**
  71313. * Gets the plane normal used to compute the sliding response (in local space)
  71314. */
  71315. readonly slidePlaneNormal: Vector3;
  71316. /** @hidden */
  71317. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71318. /** @hidden */
  71319. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71320. /** @hidden */
  71321. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71322. /** @hidden */
  71323. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71324. /** @hidden */
  71325. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71326. /** @hidden */
  71327. _getResponse(pos: Vector3, vel: Vector3): void;
  71328. }
  71329. }
  71330. declare module BABYLON {
  71331. /**
  71332. * Interface for cullable objects
  71333. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71334. */
  71335. export interface ICullable {
  71336. /**
  71337. * Checks if the object or part of the object is in the frustum
  71338. * @param frustumPlanes Camera near/planes
  71339. * @returns true if the object is in frustum otherwise false
  71340. */
  71341. isInFrustum(frustumPlanes: Plane[]): boolean;
  71342. /**
  71343. * Checks if a cullable object (mesh...) is in the camera frustum
  71344. * Unlike isInFrustum this cheks the full bounding box
  71345. * @param frustumPlanes Camera near/planes
  71346. * @returns true if the object is in frustum otherwise false
  71347. */
  71348. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71349. }
  71350. /**
  71351. * Info for a bounding data of a mesh
  71352. */
  71353. export class BoundingInfo implements ICullable {
  71354. /**
  71355. * Bounding box for the mesh
  71356. */
  71357. readonly boundingBox: BoundingBox;
  71358. /**
  71359. * Bounding sphere for the mesh
  71360. */
  71361. readonly boundingSphere: BoundingSphere;
  71362. private _isLocked;
  71363. private static readonly TmpVector3;
  71364. /**
  71365. * Constructs bounding info
  71366. * @param minimum min vector of the bounding box/sphere
  71367. * @param maximum max vector of the bounding box/sphere
  71368. * @param worldMatrix defines the new world matrix
  71369. */
  71370. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71371. /**
  71372. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71373. * @param min defines the new minimum vector (in local space)
  71374. * @param max defines the new maximum vector (in local space)
  71375. * @param worldMatrix defines the new world matrix
  71376. */
  71377. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71378. /**
  71379. * min vector of the bounding box/sphere
  71380. */
  71381. readonly minimum: Vector3;
  71382. /**
  71383. * max vector of the bounding box/sphere
  71384. */
  71385. readonly maximum: Vector3;
  71386. /**
  71387. * If the info is locked and won't be updated to avoid perf overhead
  71388. */
  71389. isLocked: boolean;
  71390. /**
  71391. * Updates the bounding sphere and box
  71392. * @param world world matrix to be used to update
  71393. */
  71394. update(world: DeepImmutable<Matrix>): void;
  71395. /**
  71396. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71397. * @param center New center of the bounding info
  71398. * @param extend New extend of the bounding info
  71399. * @returns the current bounding info
  71400. */
  71401. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71402. /**
  71403. * Scale the current bounding info by applying a scale factor
  71404. * @param factor defines the scale factor to apply
  71405. * @returns the current bounding info
  71406. */
  71407. scale(factor: number): BoundingInfo;
  71408. /**
  71409. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71410. * @param frustumPlanes defines the frustum to test
  71411. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71412. * @returns true if the bounding info is in the frustum planes
  71413. */
  71414. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71415. /**
  71416. * Gets the world distance between the min and max points of the bounding box
  71417. */
  71418. readonly diagonalLength: number;
  71419. /**
  71420. * Checks if a cullable object (mesh...) is in the camera frustum
  71421. * Unlike isInFrustum this cheks the full bounding box
  71422. * @param frustumPlanes Camera near/planes
  71423. * @returns true if the object is in frustum otherwise false
  71424. */
  71425. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71426. /** @hidden */
  71427. _checkCollision(collider: Collider): boolean;
  71428. /**
  71429. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71430. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71431. * @param point the point to check intersection with
  71432. * @returns if the point intersects
  71433. */
  71434. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71435. /**
  71436. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71437. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71438. * @param boundingInfo the bounding info to check intersection with
  71439. * @param precise if the intersection should be done using OBB
  71440. * @returns if the bounding info intersects
  71441. */
  71442. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71443. }
  71444. }
  71445. declare module BABYLON {
  71446. /**
  71447. * Extracts minimum and maximum values from a list of indexed positions
  71448. * @param positions defines the positions to use
  71449. * @param indices defines the indices to the positions
  71450. * @param indexStart defines the start index
  71451. * @param indexCount defines the end index
  71452. * @param bias defines bias value to add to the result
  71453. * @return minimum and maximum values
  71454. */
  71455. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71456. minimum: Vector3;
  71457. maximum: Vector3;
  71458. };
  71459. /**
  71460. * Extracts minimum and maximum values from a list of positions
  71461. * @param positions defines the positions to use
  71462. * @param start defines the start index in the positions array
  71463. * @param count defines the number of positions to handle
  71464. * @param bias defines bias value to add to the result
  71465. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71466. * @return minimum and maximum values
  71467. */
  71468. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71469. minimum: Vector3;
  71470. maximum: Vector3;
  71471. };
  71472. }
  71473. declare module BABYLON {
  71474. /**
  71475. * Enum that determines the text-wrapping mode to use.
  71476. */
  71477. export enum InspectableType {
  71478. /**
  71479. * Checkbox for booleans
  71480. */
  71481. Checkbox = 0,
  71482. /**
  71483. * Sliders for numbers
  71484. */
  71485. Slider = 1,
  71486. /**
  71487. * Vector3
  71488. */
  71489. Vector3 = 2,
  71490. /**
  71491. * Quaternions
  71492. */
  71493. Quaternion = 3,
  71494. /**
  71495. * Color3
  71496. */
  71497. Color3 = 4,
  71498. /**
  71499. * String
  71500. */
  71501. String = 5
  71502. }
  71503. /**
  71504. * Interface used to define custom inspectable properties.
  71505. * This interface is used by the inspector to display custom property grids
  71506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71507. */
  71508. export interface IInspectable {
  71509. /**
  71510. * Gets the label to display
  71511. */
  71512. label: string;
  71513. /**
  71514. * Gets the name of the property to edit
  71515. */
  71516. propertyName: string;
  71517. /**
  71518. * Gets the type of the editor to use
  71519. */
  71520. type: InspectableType;
  71521. /**
  71522. * Gets the minimum value of the property when using in "slider" mode
  71523. */
  71524. min?: number;
  71525. /**
  71526. * Gets the maximum value of the property when using in "slider" mode
  71527. */
  71528. max?: number;
  71529. /**
  71530. * Gets the setp to use when using in "slider" mode
  71531. */
  71532. step?: number;
  71533. }
  71534. }
  71535. declare module BABYLON {
  71536. /**
  71537. * Class used to provide helper for timing
  71538. */
  71539. export class TimingTools {
  71540. /**
  71541. * Polyfill for setImmediate
  71542. * @param action defines the action to execute after the current execution block
  71543. */
  71544. static SetImmediate(action: () => void): void;
  71545. }
  71546. }
  71547. declare module BABYLON {
  71548. /**
  71549. * Class used to enable instatition of objects by class name
  71550. */
  71551. export class InstantiationTools {
  71552. /**
  71553. * Use this object to register external classes like custom textures or material
  71554. * to allow the laoders to instantiate them
  71555. */
  71556. static RegisteredExternalClasses: {
  71557. [key: string]: Object;
  71558. };
  71559. /**
  71560. * Tries to instantiate a new object from a given class name
  71561. * @param className defines the class name to instantiate
  71562. * @returns the new object or null if the system was not able to do the instantiation
  71563. */
  71564. static Instantiate(className: string): any;
  71565. }
  71566. }
  71567. declare module BABYLON {
  71568. /**
  71569. * This represents the required contract to create a new type of texture loader.
  71570. */
  71571. export interface IInternalTextureLoader {
  71572. /**
  71573. * Defines wether the loader supports cascade loading the different faces.
  71574. */
  71575. supportCascades: boolean;
  71576. /**
  71577. * This returns if the loader support the current file information.
  71578. * @param extension defines the file extension of the file being loaded
  71579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71580. * @param fallback defines the fallback internal texture if any
  71581. * @param isBase64 defines whether the texture is encoded as a base64
  71582. * @param isBuffer defines whether the texture data are stored as a buffer
  71583. * @returns true if the loader can load the specified file
  71584. */
  71585. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71586. /**
  71587. * Transform the url before loading if required.
  71588. * @param rootUrl the url of the texture
  71589. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71590. * @returns the transformed texture
  71591. */
  71592. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71593. /**
  71594. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71595. * @param rootUrl the url of the texture
  71596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71597. * @returns the fallback texture
  71598. */
  71599. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71600. /**
  71601. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71602. * @param data contains the texture data
  71603. * @param texture defines the BabylonJS internal texture
  71604. * @param createPolynomials will be true if polynomials have been requested
  71605. * @param onLoad defines the callback to trigger once the texture is ready
  71606. * @param onError defines the callback to trigger in case of error
  71607. */
  71608. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71609. /**
  71610. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71611. * @param data contains the texture data
  71612. * @param texture defines the BabylonJS internal texture
  71613. * @param callback defines the method to call once ready to upload
  71614. */
  71615. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71616. }
  71617. }
  71618. declare module BABYLON {
  71619. interface Engine {
  71620. /**
  71621. * Creates a depth stencil cube texture.
  71622. * This is only available in WebGL 2.
  71623. * @param size The size of face edge in the cube texture.
  71624. * @param options The options defining the cube texture.
  71625. * @returns The cube texture
  71626. */
  71627. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71628. /**
  71629. * Creates a cube texture
  71630. * @param rootUrl defines the url where the files to load is located
  71631. * @param scene defines the current scene
  71632. * @param files defines the list of files to load (1 per face)
  71633. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71634. * @param onLoad defines an optional callback raised when the texture is loaded
  71635. * @param onError defines an optional callback raised if there is an issue to load the texture
  71636. * @param format defines the format of the data
  71637. * @param forcedExtension defines the extension to use to pick the right loader
  71638. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71641. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71642. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71643. * @returns the cube texture as an InternalTexture
  71644. */
  71645. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  71646. /**
  71647. * Creates a cube texture
  71648. * @param rootUrl defines the url where the files to load is located
  71649. * @param scene defines the current scene
  71650. * @param files defines the list of files to load (1 per face)
  71651. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71652. * @param onLoad defines an optional callback raised when the texture is loaded
  71653. * @param onError defines an optional callback raised if there is an issue to load the texture
  71654. * @param format defines the format of the data
  71655. * @param forcedExtension defines the extension to use to pick the right loader
  71656. * @returns the cube texture as an InternalTexture
  71657. */
  71658. 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 | undefined, forcedExtension: any): InternalTexture;
  71659. /**
  71660. * Creates a cube texture
  71661. * @param rootUrl defines the url where the files to load is located
  71662. * @param scene defines the current scene
  71663. * @param files defines the list of files to load (1 per face)
  71664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71665. * @param onLoad defines an optional callback raised when the texture is loaded
  71666. * @param onError defines an optional callback raised if there is an issue to load the texture
  71667. * @param format defines the format of the data
  71668. * @param forcedExtension defines the extension to use to pick the right loader
  71669. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71670. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71671. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71672. * @returns the cube texture as an InternalTexture
  71673. */
  71674. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  71675. /** @hidden */
  71676. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71677. /** @hidden */
  71678. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71679. /** @hidden */
  71680. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71681. /** @hidden */
  71682. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * Class for creating a cube texture
  71688. */
  71689. export class CubeTexture extends BaseTexture {
  71690. private _delayedOnLoad;
  71691. /**
  71692. * The url of the texture
  71693. */
  71694. url: string;
  71695. /**
  71696. * Gets or sets the center of the bounding box associated with the cube texture.
  71697. * It must define where the camera used to render the texture was set
  71698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71699. */
  71700. boundingBoxPosition: Vector3;
  71701. private _boundingBoxSize;
  71702. /**
  71703. * Gets or sets the size of the bounding box associated with the cube texture
  71704. * When defined, the cubemap will switch to local mode
  71705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71706. * @example https://www.babylonjs-playground.com/#RNASML
  71707. */
  71708. /**
  71709. * Returns the bounding box size
  71710. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71711. */
  71712. boundingBoxSize: Vector3;
  71713. protected _rotationY: number;
  71714. /**
  71715. * Sets texture matrix rotation angle around Y axis in radians.
  71716. */
  71717. /**
  71718. * Gets texture matrix rotation angle around Y axis radians.
  71719. */
  71720. rotationY: number;
  71721. /**
  71722. * Are mip maps generated for this texture or not.
  71723. */
  71724. readonly noMipmap: boolean;
  71725. private _noMipmap;
  71726. private _files;
  71727. private _extensions;
  71728. private _textureMatrix;
  71729. private _format;
  71730. private _createPolynomials;
  71731. /** @hidden */
  71732. _prefiltered: boolean;
  71733. /**
  71734. * Creates a cube texture from an array of image urls
  71735. * @param files defines an array of image urls
  71736. * @param scene defines the hosting scene
  71737. * @param noMipmap specifies if mip maps are not used
  71738. * @returns a cube texture
  71739. */
  71740. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71741. /**
  71742. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71743. * @param url defines the url of the prefiltered texture
  71744. * @param scene defines the scene the texture is attached to
  71745. * @param forcedExtension defines the extension of the file if different from the url
  71746. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71747. * @return the prefiltered texture
  71748. */
  71749. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71750. /**
  71751. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71752. * as prefiltered data.
  71753. * @param rootUrl defines the url of the texture or the root name of the six images
  71754. * @param scene defines the scene the texture is attached to
  71755. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71756. * @param noMipmap defines if mipmaps should be created or not
  71757. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71758. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71759. * @param onError defines a callback triggered in case of error during load
  71760. * @param format defines the internal format to use for the texture once loaded
  71761. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71762. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71763. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71764. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71765. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71766. * @return the cube texture
  71767. */
  71768. 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);
  71769. /**
  71770. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71771. */
  71772. readonly isPrefiltered: boolean;
  71773. /**
  71774. * Get the current class name of the texture useful for serialization or dynamic coding.
  71775. * @returns "CubeTexture"
  71776. */
  71777. getClassName(): string;
  71778. /**
  71779. * Update the url (and optional buffer) of this texture if url was null during construction.
  71780. * @param url the url of the texture
  71781. * @param forcedExtension defines the extension to use
  71782. * @param onLoad callback called when the texture is loaded (defaults to null)
  71783. */
  71784. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71785. /**
  71786. * Delays loading of the cube texture
  71787. * @param forcedExtension defines the extension to use
  71788. */
  71789. delayLoad(forcedExtension?: string): void;
  71790. /**
  71791. * Returns the reflection texture matrix
  71792. * @returns the reflection texture matrix
  71793. */
  71794. getReflectionTextureMatrix(): Matrix;
  71795. /**
  71796. * Sets the reflection texture matrix
  71797. * @param value Reflection texture matrix
  71798. */
  71799. setReflectionTextureMatrix(value: Matrix): void;
  71800. /**
  71801. * Parses text to create a cube texture
  71802. * @param parsedTexture define the serialized text to read from
  71803. * @param scene defines the hosting scene
  71804. * @param rootUrl defines the root url of the cube texture
  71805. * @returns a cube texture
  71806. */
  71807. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71808. /**
  71809. * Makes a clone, or deep copy, of the cube texture
  71810. * @returns a new cube texture
  71811. */
  71812. clone(): CubeTexture;
  71813. }
  71814. }
  71815. declare module BABYLON {
  71816. /**
  71817. * Manages the defines for the Material
  71818. */
  71819. export class MaterialDefines {
  71820. /** @hidden */
  71821. protected _keys: string[];
  71822. private _isDirty;
  71823. /** @hidden */
  71824. _renderId: number;
  71825. /** @hidden */
  71826. _areLightsDirty: boolean;
  71827. /** @hidden */
  71828. _areAttributesDirty: boolean;
  71829. /** @hidden */
  71830. _areTexturesDirty: boolean;
  71831. /** @hidden */
  71832. _areFresnelDirty: boolean;
  71833. /** @hidden */
  71834. _areMiscDirty: boolean;
  71835. /** @hidden */
  71836. _areImageProcessingDirty: boolean;
  71837. /** @hidden */
  71838. _normals: boolean;
  71839. /** @hidden */
  71840. _uvs: boolean;
  71841. /** @hidden */
  71842. _needNormals: boolean;
  71843. /** @hidden */
  71844. _needUVs: boolean;
  71845. [id: string]: any;
  71846. /**
  71847. * Specifies if the material needs to be re-calculated
  71848. */
  71849. readonly isDirty: boolean;
  71850. /**
  71851. * Marks the material to indicate that it has been re-calculated
  71852. */
  71853. markAsProcessed(): void;
  71854. /**
  71855. * Marks the material to indicate that it needs to be re-calculated
  71856. */
  71857. markAsUnprocessed(): void;
  71858. /**
  71859. * Marks the material to indicate all of its defines need to be re-calculated
  71860. */
  71861. markAllAsDirty(): void;
  71862. /**
  71863. * Marks the material to indicate that image processing needs to be re-calculated
  71864. */
  71865. markAsImageProcessingDirty(): void;
  71866. /**
  71867. * Marks the material to indicate the lights need to be re-calculated
  71868. */
  71869. markAsLightDirty(): void;
  71870. /**
  71871. * Marks the attribute state as changed
  71872. */
  71873. markAsAttributesDirty(): void;
  71874. /**
  71875. * Marks the texture state as changed
  71876. */
  71877. markAsTexturesDirty(): void;
  71878. /**
  71879. * Marks the fresnel state as changed
  71880. */
  71881. markAsFresnelDirty(): void;
  71882. /**
  71883. * Marks the misc state as changed
  71884. */
  71885. markAsMiscDirty(): void;
  71886. /**
  71887. * Rebuilds the material defines
  71888. */
  71889. rebuild(): void;
  71890. /**
  71891. * Specifies if two material defines are equal
  71892. * @param other - A material define instance to compare to
  71893. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71894. */
  71895. isEqual(other: MaterialDefines): boolean;
  71896. /**
  71897. * Clones this instance's defines to another instance
  71898. * @param other - material defines to clone values to
  71899. */
  71900. cloneTo(other: MaterialDefines): void;
  71901. /**
  71902. * Resets the material define values
  71903. */
  71904. reset(): void;
  71905. /**
  71906. * Converts the material define values to a string
  71907. * @returns - String of material define information
  71908. */
  71909. toString(): string;
  71910. }
  71911. }
  71912. declare module BABYLON {
  71913. /**
  71914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71916. * 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;
  71917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71918. */
  71919. export class ColorCurves {
  71920. private _dirty;
  71921. private _tempColor;
  71922. private _globalCurve;
  71923. private _highlightsCurve;
  71924. private _midtonesCurve;
  71925. private _shadowsCurve;
  71926. private _positiveCurve;
  71927. private _negativeCurve;
  71928. private _globalHue;
  71929. private _globalDensity;
  71930. private _globalSaturation;
  71931. private _globalExposure;
  71932. /**
  71933. * Gets the global Hue value.
  71934. * 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).
  71935. */
  71936. /**
  71937. * Sets the global Hue value.
  71938. * 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).
  71939. */
  71940. globalHue: number;
  71941. /**
  71942. * Gets the global Density value.
  71943. * 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.
  71944. * Values less than zero provide a filter of opposite hue.
  71945. */
  71946. /**
  71947. * Sets the global Density value.
  71948. * 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.
  71949. * Values less than zero provide a filter of opposite hue.
  71950. */
  71951. globalDensity: number;
  71952. /**
  71953. * Gets the global Saturation value.
  71954. * 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.
  71955. */
  71956. /**
  71957. * Sets the global Saturation value.
  71958. * 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.
  71959. */
  71960. globalSaturation: number;
  71961. /**
  71962. * Gets the global Exposure value.
  71963. * 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.
  71964. */
  71965. /**
  71966. * Sets the global Exposure value.
  71967. * 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.
  71968. */
  71969. globalExposure: number;
  71970. private _highlightsHue;
  71971. private _highlightsDensity;
  71972. private _highlightsSaturation;
  71973. private _highlightsExposure;
  71974. /**
  71975. * Gets the highlights Hue value.
  71976. * 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).
  71977. */
  71978. /**
  71979. * Sets the highlights Hue value.
  71980. * 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).
  71981. */
  71982. highlightsHue: number;
  71983. /**
  71984. * Gets the highlights Density value.
  71985. * 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.
  71986. * Values less than zero provide a filter of opposite hue.
  71987. */
  71988. /**
  71989. * Sets the highlights Density value.
  71990. * 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.
  71991. * Values less than zero provide a filter of opposite hue.
  71992. */
  71993. highlightsDensity: number;
  71994. /**
  71995. * Gets the highlights Saturation value.
  71996. * 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.
  71997. */
  71998. /**
  71999. * Sets the highlights Saturation value.
  72000. * 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.
  72001. */
  72002. highlightsSaturation: number;
  72003. /**
  72004. * Gets the highlights Exposure value.
  72005. * 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.
  72006. */
  72007. /**
  72008. * Sets the highlights Exposure value.
  72009. * 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.
  72010. */
  72011. highlightsExposure: number;
  72012. private _midtonesHue;
  72013. private _midtonesDensity;
  72014. private _midtonesSaturation;
  72015. private _midtonesExposure;
  72016. /**
  72017. * Gets the midtones Hue value.
  72018. * 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).
  72019. */
  72020. /**
  72021. * Sets the midtones Hue value.
  72022. * 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).
  72023. */
  72024. midtonesHue: number;
  72025. /**
  72026. * Gets the midtones Density value.
  72027. * 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.
  72028. * Values less than zero provide a filter of opposite hue.
  72029. */
  72030. /**
  72031. * Sets the midtones Density value.
  72032. * 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.
  72033. * Values less than zero provide a filter of opposite hue.
  72034. */
  72035. midtonesDensity: number;
  72036. /**
  72037. * Gets the midtones Saturation value.
  72038. * 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.
  72039. */
  72040. /**
  72041. * Sets the midtones Saturation value.
  72042. * 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.
  72043. */
  72044. midtonesSaturation: number;
  72045. /**
  72046. * Gets the midtones Exposure value.
  72047. * 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.
  72048. */
  72049. /**
  72050. * Sets the midtones Exposure value.
  72051. * 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.
  72052. */
  72053. midtonesExposure: number;
  72054. private _shadowsHue;
  72055. private _shadowsDensity;
  72056. private _shadowsSaturation;
  72057. private _shadowsExposure;
  72058. /**
  72059. * Gets the shadows Hue value.
  72060. * 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).
  72061. */
  72062. /**
  72063. * Sets the shadows Hue value.
  72064. * 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).
  72065. */
  72066. shadowsHue: number;
  72067. /**
  72068. * Gets the shadows Density value.
  72069. * 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.
  72070. * Values less than zero provide a filter of opposite hue.
  72071. */
  72072. /**
  72073. * Sets the shadows Density value.
  72074. * 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.
  72075. * Values less than zero provide a filter of opposite hue.
  72076. */
  72077. shadowsDensity: number;
  72078. /**
  72079. * Gets the shadows Saturation value.
  72080. * 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.
  72081. */
  72082. /**
  72083. * Sets the shadows Saturation value.
  72084. * 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.
  72085. */
  72086. shadowsSaturation: number;
  72087. /**
  72088. * Gets the shadows Exposure value.
  72089. * 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.
  72090. */
  72091. /**
  72092. * Sets the shadows Exposure value.
  72093. * 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.
  72094. */
  72095. shadowsExposure: number;
  72096. /**
  72097. * Returns the class name
  72098. * @returns The class name
  72099. */
  72100. getClassName(): string;
  72101. /**
  72102. * Binds the color curves to the shader.
  72103. * @param colorCurves The color curve to bind
  72104. * @param effect The effect to bind to
  72105. * @param positiveUniform The positive uniform shader parameter
  72106. * @param neutralUniform The neutral uniform shader parameter
  72107. * @param negativeUniform The negative uniform shader parameter
  72108. */
  72109. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  72110. /**
  72111. * Prepare the list of uniforms associated with the ColorCurves effects.
  72112. * @param uniformsList The list of uniforms used in the effect
  72113. */
  72114. static PrepareUniforms(uniformsList: string[]): void;
  72115. /**
  72116. * Returns color grading data based on a hue, density, saturation and exposure value.
  72117. * @param filterHue The hue of the color filter.
  72118. * @param filterDensity The density of the color filter.
  72119. * @param saturation The saturation.
  72120. * @param exposure The exposure.
  72121. * @param result The result data container.
  72122. */
  72123. private getColorGradingDataToRef;
  72124. /**
  72125. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  72126. * @param value The input slider value in range [-100,100].
  72127. * @returns Adjusted value.
  72128. */
  72129. private static applyColorGradingSliderNonlinear;
  72130. /**
  72131. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  72132. * @param hue The hue (H) input.
  72133. * @param saturation The saturation (S) input.
  72134. * @param brightness The brightness (B) input.
  72135. * @result An RGBA color represented as Vector4.
  72136. */
  72137. private static fromHSBToRef;
  72138. /**
  72139. * Returns a value clamped between min and max
  72140. * @param value The value to clamp
  72141. * @param min The minimum of value
  72142. * @param max The maximum of value
  72143. * @returns The clamped value.
  72144. */
  72145. private static clamp;
  72146. /**
  72147. * Clones the current color curve instance.
  72148. * @return The cloned curves
  72149. */
  72150. clone(): ColorCurves;
  72151. /**
  72152. * Serializes the current color curve instance to a json representation.
  72153. * @return a JSON representation
  72154. */
  72155. serialize(): any;
  72156. /**
  72157. * Parses the color curve from a json representation.
  72158. * @param source the JSON source to parse
  72159. * @return The parsed curves
  72160. */
  72161. static Parse(source: any): ColorCurves;
  72162. }
  72163. }
  72164. declare module BABYLON {
  72165. /**
  72166. * Interface to follow in your material defines to integrate easily the
  72167. * Image proccessing functions.
  72168. * @hidden
  72169. */
  72170. export interface IImageProcessingConfigurationDefines {
  72171. IMAGEPROCESSING: boolean;
  72172. VIGNETTE: boolean;
  72173. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72174. VIGNETTEBLENDMODEOPAQUE: boolean;
  72175. TONEMAPPING: boolean;
  72176. TONEMAPPING_ACES: boolean;
  72177. CONTRAST: boolean;
  72178. EXPOSURE: boolean;
  72179. COLORCURVES: boolean;
  72180. COLORGRADING: boolean;
  72181. COLORGRADING3D: boolean;
  72182. SAMPLER3DGREENDEPTH: boolean;
  72183. SAMPLER3DBGRMAP: boolean;
  72184. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72185. }
  72186. /**
  72187. * @hidden
  72188. */
  72189. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  72190. IMAGEPROCESSING: boolean;
  72191. VIGNETTE: boolean;
  72192. VIGNETTEBLENDMODEMULTIPLY: boolean;
  72193. VIGNETTEBLENDMODEOPAQUE: boolean;
  72194. TONEMAPPING: boolean;
  72195. TONEMAPPING_ACES: boolean;
  72196. CONTRAST: boolean;
  72197. COLORCURVES: boolean;
  72198. COLORGRADING: boolean;
  72199. COLORGRADING3D: boolean;
  72200. SAMPLER3DGREENDEPTH: boolean;
  72201. SAMPLER3DBGRMAP: boolean;
  72202. IMAGEPROCESSINGPOSTPROCESS: boolean;
  72203. EXPOSURE: boolean;
  72204. constructor();
  72205. }
  72206. /**
  72207. * This groups together the common properties used for image processing either in direct forward pass
  72208. * or through post processing effect depending on the use of the image processing pipeline in your scene
  72209. * or not.
  72210. */
  72211. export class ImageProcessingConfiguration {
  72212. /**
  72213. * Default tone mapping applied in BabylonJS.
  72214. */
  72215. static readonly TONEMAPPING_STANDARD: number;
  72216. /**
  72217. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  72218. * to other engines rendering to increase portability.
  72219. */
  72220. static readonly TONEMAPPING_ACES: number;
  72221. /**
  72222. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  72223. */
  72224. colorCurves: Nullable<ColorCurves>;
  72225. private _colorCurvesEnabled;
  72226. /**
  72227. * Gets wether the color curves effect is enabled.
  72228. */
  72229. /**
  72230. * Sets wether the color curves effect is enabled.
  72231. */
  72232. colorCurvesEnabled: boolean;
  72233. private _colorGradingTexture;
  72234. /**
  72235. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72236. */
  72237. /**
  72238. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  72239. */
  72240. colorGradingTexture: Nullable<BaseTexture>;
  72241. private _colorGradingEnabled;
  72242. /**
  72243. * Gets wether the color grading effect is enabled.
  72244. */
  72245. /**
  72246. * Sets wether the color grading effect is enabled.
  72247. */
  72248. colorGradingEnabled: boolean;
  72249. private _colorGradingWithGreenDepth;
  72250. /**
  72251. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  72252. */
  72253. /**
  72254. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  72255. */
  72256. colorGradingWithGreenDepth: boolean;
  72257. private _colorGradingBGR;
  72258. /**
  72259. * Gets wether the color grading texture contains BGR values.
  72260. */
  72261. /**
  72262. * Sets wether the color grading texture contains BGR values.
  72263. */
  72264. colorGradingBGR: boolean;
  72265. /** @hidden */
  72266. _exposure: number;
  72267. /**
  72268. * Gets the Exposure used in the effect.
  72269. */
  72270. /**
  72271. * Sets the Exposure used in the effect.
  72272. */
  72273. exposure: number;
  72274. private _toneMappingEnabled;
  72275. /**
  72276. * Gets wether the tone mapping effect is enabled.
  72277. */
  72278. /**
  72279. * Sets wether the tone mapping effect is enabled.
  72280. */
  72281. toneMappingEnabled: boolean;
  72282. private _toneMappingType;
  72283. /**
  72284. * Gets the type of tone mapping effect.
  72285. */
  72286. /**
  72287. * Sets the type of tone mapping effect used in BabylonJS.
  72288. */
  72289. toneMappingType: number;
  72290. protected _contrast: number;
  72291. /**
  72292. * Gets the contrast used in the effect.
  72293. */
  72294. /**
  72295. * Sets the contrast used in the effect.
  72296. */
  72297. contrast: number;
  72298. /**
  72299. * Vignette stretch size.
  72300. */
  72301. vignetteStretch: number;
  72302. /**
  72303. * Vignette centre X Offset.
  72304. */
  72305. vignetteCentreX: number;
  72306. /**
  72307. * Vignette centre Y Offset.
  72308. */
  72309. vignetteCentreY: number;
  72310. /**
  72311. * Vignette weight or intensity of the vignette effect.
  72312. */
  72313. vignetteWeight: number;
  72314. /**
  72315. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72316. * if vignetteEnabled is set to true.
  72317. */
  72318. vignetteColor: Color4;
  72319. /**
  72320. * Camera field of view used by the Vignette effect.
  72321. */
  72322. vignetteCameraFov: number;
  72323. private _vignetteBlendMode;
  72324. /**
  72325. * Gets the vignette blend mode allowing different kind of effect.
  72326. */
  72327. /**
  72328. * Sets the vignette blend mode allowing different kind of effect.
  72329. */
  72330. vignetteBlendMode: number;
  72331. private _vignetteEnabled;
  72332. /**
  72333. * Gets wether the vignette effect is enabled.
  72334. */
  72335. /**
  72336. * Sets wether the vignette effect is enabled.
  72337. */
  72338. vignetteEnabled: boolean;
  72339. private _applyByPostProcess;
  72340. /**
  72341. * Gets wether the image processing is applied through a post process or not.
  72342. */
  72343. /**
  72344. * Sets wether the image processing is applied through a post process or not.
  72345. */
  72346. applyByPostProcess: boolean;
  72347. private _isEnabled;
  72348. /**
  72349. * Gets wether the image processing is enabled or not.
  72350. */
  72351. /**
  72352. * Sets wether the image processing is enabled or not.
  72353. */
  72354. isEnabled: boolean;
  72355. /**
  72356. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72357. */
  72358. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72359. /**
  72360. * Method called each time the image processing information changes requires to recompile the effect.
  72361. */
  72362. protected _updateParameters(): void;
  72363. /**
  72364. * Gets the current class name.
  72365. * @return "ImageProcessingConfiguration"
  72366. */
  72367. getClassName(): string;
  72368. /**
  72369. * Prepare the list of uniforms associated with the Image Processing effects.
  72370. * @param uniforms The list of uniforms used in the effect
  72371. * @param defines the list of defines currently in use
  72372. */
  72373. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72374. /**
  72375. * Prepare the list of samplers associated with the Image Processing effects.
  72376. * @param samplersList The list of uniforms used in the effect
  72377. * @param defines the list of defines currently in use
  72378. */
  72379. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72380. /**
  72381. * Prepare the list of defines associated to the shader.
  72382. * @param defines the list of defines to complete
  72383. * @param forPostProcess Define if we are currently in post process mode or not
  72384. */
  72385. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72386. /**
  72387. * Returns true if all the image processing information are ready.
  72388. * @returns True if ready, otherwise, false
  72389. */
  72390. isReady(): boolean;
  72391. /**
  72392. * Binds the image processing to the shader.
  72393. * @param effect The effect to bind to
  72394. * @param aspectRatio Define the current aspect ratio of the effect
  72395. */
  72396. bind(effect: Effect, aspectRatio?: number): void;
  72397. /**
  72398. * Clones the current image processing instance.
  72399. * @return The cloned image processing
  72400. */
  72401. clone(): ImageProcessingConfiguration;
  72402. /**
  72403. * Serializes the current image processing instance to a json representation.
  72404. * @return a JSON representation
  72405. */
  72406. serialize(): any;
  72407. /**
  72408. * Parses the image processing from a json representation.
  72409. * @param source the JSON source to parse
  72410. * @return The parsed image processing
  72411. */
  72412. static Parse(source: any): ImageProcessingConfiguration;
  72413. private static _VIGNETTEMODE_MULTIPLY;
  72414. private static _VIGNETTEMODE_OPAQUE;
  72415. /**
  72416. * Used to apply the vignette as a mix with the pixel color.
  72417. */
  72418. static readonly VIGNETTEMODE_MULTIPLY: number;
  72419. /**
  72420. * Used to apply the vignette as a replacement of the pixel color.
  72421. */
  72422. static readonly VIGNETTEMODE_OPAQUE: number;
  72423. }
  72424. }
  72425. declare module BABYLON {
  72426. /** @hidden */
  72427. export var postprocessVertexShader: {
  72428. name: string;
  72429. shader: string;
  72430. };
  72431. }
  72432. declare module BABYLON {
  72433. /** Defines supported spaces */
  72434. export enum Space {
  72435. /** Local (object) space */
  72436. LOCAL = 0,
  72437. /** World space */
  72438. WORLD = 1,
  72439. /** Bone space */
  72440. BONE = 2
  72441. }
  72442. /** Defines the 3 main axes */
  72443. export class Axis {
  72444. /** X axis */
  72445. static X: Vector3;
  72446. /** Y axis */
  72447. static Y: Vector3;
  72448. /** Z axis */
  72449. static Z: Vector3;
  72450. }
  72451. }
  72452. declare module BABYLON {
  72453. /**
  72454. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72455. * This is the base of the follow, arc rotate cameras and Free camera
  72456. * @see http://doc.babylonjs.com/features/cameras
  72457. */
  72458. export class TargetCamera extends Camera {
  72459. private static _RigCamTransformMatrix;
  72460. private static _TargetTransformMatrix;
  72461. private static _TargetFocalPoint;
  72462. /**
  72463. * Define the current direction the camera is moving to
  72464. */
  72465. cameraDirection: Vector3;
  72466. /**
  72467. * Define the current rotation the camera is rotating to
  72468. */
  72469. cameraRotation: Vector2;
  72470. /**
  72471. * When set, the up vector of the camera will be updated by the rotation of the camera
  72472. */
  72473. updateUpVectorFromRotation: boolean;
  72474. private _tmpQuaternion;
  72475. /**
  72476. * Define the current rotation of the camera
  72477. */
  72478. rotation: Vector3;
  72479. /**
  72480. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72481. */
  72482. rotationQuaternion: Quaternion;
  72483. /**
  72484. * Define the current speed of the camera
  72485. */
  72486. speed: number;
  72487. /**
  72488. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72489. * around all axis.
  72490. */
  72491. noRotationConstraint: boolean;
  72492. /**
  72493. * Define the current target of the camera as an object or a position.
  72494. */
  72495. lockedTarget: any;
  72496. /** @hidden */
  72497. _currentTarget: Vector3;
  72498. /** @hidden */
  72499. _initialFocalDistance: number;
  72500. /** @hidden */
  72501. _viewMatrix: Matrix;
  72502. /** @hidden */
  72503. _camMatrix: Matrix;
  72504. /** @hidden */
  72505. _cameraTransformMatrix: Matrix;
  72506. /** @hidden */
  72507. _cameraRotationMatrix: Matrix;
  72508. /** @hidden */
  72509. _referencePoint: Vector3;
  72510. /** @hidden */
  72511. _transformedReferencePoint: Vector3;
  72512. protected _globalCurrentTarget: Vector3;
  72513. protected _globalCurrentUpVector: Vector3;
  72514. /** @hidden */
  72515. _reset: () => void;
  72516. private _defaultUp;
  72517. /**
  72518. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72519. * This is the base of the follow, arc rotate cameras and Free camera
  72520. * @see http://doc.babylonjs.com/features/cameras
  72521. * @param name Defines the name of the camera in the scene
  72522. * @param position Defines the start position of the camera in the scene
  72523. * @param scene Defines the scene the camera belongs to
  72524. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72525. */
  72526. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72527. /**
  72528. * Gets the position in front of the camera at a given distance.
  72529. * @param distance The distance from the camera we want the position to be
  72530. * @returns the position
  72531. */
  72532. getFrontPosition(distance: number): Vector3;
  72533. /** @hidden */
  72534. _getLockedTargetPosition(): Nullable<Vector3>;
  72535. private _storedPosition;
  72536. private _storedRotation;
  72537. private _storedRotationQuaternion;
  72538. /**
  72539. * Store current camera state of the camera (fov, position, rotation, etc..)
  72540. * @returns the camera
  72541. */
  72542. storeState(): Camera;
  72543. /**
  72544. * Restored camera state. You must call storeState() first
  72545. * @returns whether it was successful or not
  72546. * @hidden
  72547. */
  72548. _restoreStateValues(): boolean;
  72549. /** @hidden */
  72550. _initCache(): void;
  72551. /** @hidden */
  72552. _updateCache(ignoreParentClass?: boolean): void;
  72553. /** @hidden */
  72554. _isSynchronizedViewMatrix(): boolean;
  72555. /** @hidden */
  72556. _computeLocalCameraSpeed(): number;
  72557. /**
  72558. * Defines the target the camera should look at.
  72559. * @param target Defines the new target as a Vector or a mesh
  72560. */
  72561. setTarget(target: Vector3): void;
  72562. /**
  72563. * Return the current target position of the camera. This value is expressed in local space.
  72564. * @returns the target position
  72565. */
  72566. getTarget(): Vector3;
  72567. /** @hidden */
  72568. _decideIfNeedsToMove(): boolean;
  72569. /** @hidden */
  72570. _updatePosition(): void;
  72571. /** @hidden */
  72572. _checkInputs(): void;
  72573. protected _updateCameraRotationMatrix(): void;
  72574. /**
  72575. * 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)
  72576. * @returns the current camera
  72577. */
  72578. private _rotateUpVectorWithCameraRotationMatrix;
  72579. private _cachedRotationZ;
  72580. private _cachedQuaternionRotationZ;
  72581. /** @hidden */
  72582. _getViewMatrix(): Matrix;
  72583. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72584. /**
  72585. * @hidden
  72586. */
  72587. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72588. /**
  72589. * @hidden
  72590. */
  72591. _updateRigCameras(): void;
  72592. private _getRigCamPositionAndTarget;
  72593. /**
  72594. * Gets the current object class name.
  72595. * @return the class name
  72596. */
  72597. getClassName(): string;
  72598. }
  72599. }
  72600. declare module BABYLON {
  72601. /**
  72602. * Gather the list of keyboard event types as constants.
  72603. */
  72604. export class KeyboardEventTypes {
  72605. /**
  72606. * The keydown event is fired when a key becomes active (pressed).
  72607. */
  72608. static readonly KEYDOWN: number;
  72609. /**
  72610. * The keyup event is fired when a key has been released.
  72611. */
  72612. static readonly KEYUP: number;
  72613. }
  72614. /**
  72615. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72616. */
  72617. export class KeyboardInfo {
  72618. /**
  72619. * Defines the type of event (KeyboardEventTypes)
  72620. */
  72621. type: number;
  72622. /**
  72623. * Defines the related dom event
  72624. */
  72625. event: KeyboardEvent;
  72626. /**
  72627. * Instantiates a new keyboard info.
  72628. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72629. * @param type Defines the type of event (KeyboardEventTypes)
  72630. * @param event Defines the related dom event
  72631. */
  72632. constructor(
  72633. /**
  72634. * Defines the type of event (KeyboardEventTypes)
  72635. */
  72636. type: number,
  72637. /**
  72638. * Defines the related dom event
  72639. */
  72640. event: KeyboardEvent);
  72641. }
  72642. /**
  72643. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72644. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72645. */
  72646. export class KeyboardInfoPre extends KeyboardInfo {
  72647. /**
  72648. * Defines the type of event (KeyboardEventTypes)
  72649. */
  72650. type: number;
  72651. /**
  72652. * Defines the related dom event
  72653. */
  72654. event: KeyboardEvent;
  72655. /**
  72656. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72657. */
  72658. skipOnPointerObservable: boolean;
  72659. /**
  72660. * Instantiates a new keyboard pre info.
  72661. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72662. * @param type Defines the type of event (KeyboardEventTypes)
  72663. * @param event Defines the related dom event
  72664. */
  72665. constructor(
  72666. /**
  72667. * Defines the type of event (KeyboardEventTypes)
  72668. */
  72669. type: number,
  72670. /**
  72671. * Defines the related dom event
  72672. */
  72673. event: KeyboardEvent);
  72674. }
  72675. }
  72676. declare module BABYLON {
  72677. /**
  72678. * Manage the keyboard inputs to control the movement of a free camera.
  72679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72680. */
  72681. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72682. /**
  72683. * Defines the camera the input is attached to.
  72684. */
  72685. camera: FreeCamera;
  72686. /**
  72687. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72688. */
  72689. keysUp: number[];
  72690. /**
  72691. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72692. */
  72693. keysDown: number[];
  72694. /**
  72695. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72696. */
  72697. keysLeft: number[];
  72698. /**
  72699. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72700. */
  72701. keysRight: number[];
  72702. private _keys;
  72703. private _onCanvasBlurObserver;
  72704. private _onKeyboardObserver;
  72705. private _engine;
  72706. private _scene;
  72707. /**
  72708. * Attach the input controls to a specific dom element to get the input from.
  72709. * @param element Defines the element the controls should be listened from
  72710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72711. */
  72712. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72713. /**
  72714. * Detach the current controls from the specified dom element.
  72715. * @param element Defines the element to stop listening the inputs from
  72716. */
  72717. detachControl(element: Nullable<HTMLElement>): void;
  72718. /**
  72719. * Update the current camera state depending on the inputs that have been used this frame.
  72720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72721. */
  72722. checkInputs(): void;
  72723. /**
  72724. * Gets the class name of the current intput.
  72725. * @returns the class name
  72726. */
  72727. getClassName(): string;
  72728. /** @hidden */
  72729. _onLostFocus(): void;
  72730. /**
  72731. * Get the friendly name associated with the input class.
  72732. * @returns the input friendly name
  72733. */
  72734. getSimpleName(): string;
  72735. }
  72736. }
  72737. declare module BABYLON {
  72738. /**
  72739. * Interface describing all the common properties and methods a shadow light needs to implement.
  72740. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72741. * as well as binding the different shadow properties to the effects.
  72742. */
  72743. export interface IShadowLight extends Light {
  72744. /**
  72745. * The light id in the scene (used in scene.findLighById for instance)
  72746. */
  72747. id: string;
  72748. /**
  72749. * The position the shdow will be casted from.
  72750. */
  72751. position: Vector3;
  72752. /**
  72753. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72754. */
  72755. direction: Vector3;
  72756. /**
  72757. * The transformed position. Position of the light in world space taking parenting in account.
  72758. */
  72759. transformedPosition: Vector3;
  72760. /**
  72761. * The transformed direction. Direction of the light in world space taking parenting in account.
  72762. */
  72763. transformedDirection: Vector3;
  72764. /**
  72765. * The friendly name of the light in the scene.
  72766. */
  72767. name: string;
  72768. /**
  72769. * Defines the shadow projection clipping minimum z value.
  72770. */
  72771. shadowMinZ: number;
  72772. /**
  72773. * Defines the shadow projection clipping maximum z value.
  72774. */
  72775. shadowMaxZ: number;
  72776. /**
  72777. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72778. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72779. */
  72780. computeTransformedInformation(): boolean;
  72781. /**
  72782. * Gets the scene the light belongs to.
  72783. * @returns The scene
  72784. */
  72785. getScene(): Scene;
  72786. /**
  72787. * Callback defining a custom Projection Matrix Builder.
  72788. * This can be used to override the default projection matrix computation.
  72789. */
  72790. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72791. /**
  72792. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72793. * @param matrix The materix to updated with the projection information
  72794. * @param viewMatrix The transform matrix of the light
  72795. * @param renderList The list of mesh to render in the map
  72796. * @returns The current light
  72797. */
  72798. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72799. /**
  72800. * Gets the current depth scale used in ESM.
  72801. * @returns The scale
  72802. */
  72803. getDepthScale(): number;
  72804. /**
  72805. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72806. * @returns true if a cube texture needs to be use
  72807. */
  72808. needCube(): boolean;
  72809. /**
  72810. * Detects if the projection matrix requires to be recomputed this frame.
  72811. * @returns true if it requires to be recomputed otherwise, false.
  72812. */
  72813. needProjectionMatrixCompute(): boolean;
  72814. /**
  72815. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72816. */
  72817. forceProjectionMatrixCompute(): void;
  72818. /**
  72819. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72820. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72821. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72822. */
  72823. getShadowDirection(faceIndex?: number): Vector3;
  72824. /**
  72825. * Gets the minZ used for shadow according to both the scene and the light.
  72826. * @param activeCamera The camera we are returning the min for
  72827. * @returns the depth min z
  72828. */
  72829. getDepthMinZ(activeCamera: Camera): number;
  72830. /**
  72831. * Gets the maxZ used for shadow according to both the scene and the light.
  72832. * @param activeCamera The camera we are returning the max for
  72833. * @returns the depth max z
  72834. */
  72835. getDepthMaxZ(activeCamera: Camera): number;
  72836. }
  72837. /**
  72838. * Base implementation IShadowLight
  72839. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72840. */
  72841. export abstract class ShadowLight extends Light implements IShadowLight {
  72842. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72843. protected _position: Vector3;
  72844. protected _setPosition(value: Vector3): void;
  72845. /**
  72846. * Sets the position the shadow will be casted from. Also use as the light position for both
  72847. * point and spot lights.
  72848. */
  72849. /**
  72850. * Sets the position the shadow will be casted from. Also use as the light position for both
  72851. * point and spot lights.
  72852. */
  72853. position: Vector3;
  72854. protected _direction: Vector3;
  72855. protected _setDirection(value: Vector3): void;
  72856. /**
  72857. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72858. * Also use as the light direction on spot and directional lights.
  72859. */
  72860. /**
  72861. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72862. * Also use as the light direction on spot and directional lights.
  72863. */
  72864. direction: Vector3;
  72865. private _shadowMinZ;
  72866. /**
  72867. * Gets the shadow projection clipping minimum z value.
  72868. */
  72869. /**
  72870. * Sets the shadow projection clipping minimum z value.
  72871. */
  72872. shadowMinZ: number;
  72873. private _shadowMaxZ;
  72874. /**
  72875. * Sets the shadow projection clipping maximum z value.
  72876. */
  72877. /**
  72878. * Gets the shadow projection clipping maximum z value.
  72879. */
  72880. shadowMaxZ: number;
  72881. /**
  72882. * Callback defining a custom Projection Matrix Builder.
  72883. * This can be used to override the default projection matrix computation.
  72884. */
  72885. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72886. /**
  72887. * The transformed position. Position of the light in world space taking parenting in account.
  72888. */
  72889. transformedPosition: Vector3;
  72890. /**
  72891. * The transformed direction. Direction of the light in world space taking parenting in account.
  72892. */
  72893. transformedDirection: Vector3;
  72894. private _needProjectionMatrixCompute;
  72895. /**
  72896. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72897. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72898. */
  72899. computeTransformedInformation(): boolean;
  72900. /**
  72901. * Return the depth scale used for the shadow map.
  72902. * @returns the depth scale.
  72903. */
  72904. getDepthScale(): number;
  72905. /**
  72906. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72907. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72908. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72909. */
  72910. getShadowDirection(faceIndex?: number): Vector3;
  72911. /**
  72912. * Returns the ShadowLight absolute position in the World.
  72913. * @returns the position vector in world space
  72914. */
  72915. getAbsolutePosition(): Vector3;
  72916. /**
  72917. * Sets the ShadowLight direction toward the passed target.
  72918. * @param target The point to target in local space
  72919. * @returns the updated ShadowLight direction
  72920. */
  72921. setDirectionToTarget(target: Vector3): Vector3;
  72922. /**
  72923. * Returns the light rotation in euler definition.
  72924. * @returns the x y z rotation in local space.
  72925. */
  72926. getRotation(): Vector3;
  72927. /**
  72928. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72929. * @returns true if a cube texture needs to be use
  72930. */
  72931. needCube(): boolean;
  72932. /**
  72933. * Detects if the projection matrix requires to be recomputed this frame.
  72934. * @returns true if it requires to be recomputed otherwise, false.
  72935. */
  72936. needProjectionMatrixCompute(): boolean;
  72937. /**
  72938. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72939. */
  72940. forceProjectionMatrixCompute(): void;
  72941. /** @hidden */
  72942. _initCache(): void;
  72943. /** @hidden */
  72944. _isSynchronized(): boolean;
  72945. /**
  72946. * Computes the world matrix of the node
  72947. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72948. * @returns the world matrix
  72949. */
  72950. computeWorldMatrix(force?: boolean): Matrix;
  72951. /**
  72952. * Gets the minZ used for shadow according to both the scene and the light.
  72953. * @param activeCamera The camera we are returning the min for
  72954. * @returns the depth min z
  72955. */
  72956. getDepthMinZ(activeCamera: Camera): number;
  72957. /**
  72958. * Gets the maxZ used for shadow according to both the scene and the light.
  72959. * @param activeCamera The camera we are returning the max for
  72960. * @returns the depth max z
  72961. */
  72962. getDepthMaxZ(activeCamera: Camera): number;
  72963. /**
  72964. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72965. * @param matrix The materix to updated with the projection information
  72966. * @param viewMatrix The transform matrix of the light
  72967. * @param renderList The list of mesh to render in the map
  72968. * @returns The current light
  72969. */
  72970. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72971. }
  72972. }
  72973. declare module BABYLON {
  72974. /**
  72975. * "Static Class" containing the most commonly used helper while dealing with material for
  72976. * rendering purpose.
  72977. *
  72978. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72979. *
  72980. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72981. */
  72982. export class MaterialHelper {
  72983. /**
  72984. * Bind the current view position to an effect.
  72985. * @param effect The effect to be bound
  72986. * @param scene The scene the eyes position is used from
  72987. */
  72988. static BindEyePosition(effect: Effect, scene: Scene): void;
  72989. /**
  72990. * Helps preparing the defines values about the UVs in used in the effect.
  72991. * UVs are shared as much as we can accross channels in the shaders.
  72992. * @param texture The texture we are preparing the UVs for
  72993. * @param defines The defines to update
  72994. * @param key The channel key "diffuse", "specular"... used in the shader
  72995. */
  72996. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72997. /**
  72998. * Binds a texture matrix value to its corrsponding uniform
  72999. * @param texture The texture to bind the matrix for
  73000. * @param uniformBuffer The uniform buffer receivin the data
  73001. * @param key The channel key "diffuse", "specular"... used in the shader
  73002. */
  73003. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73004. /**
  73005. * Gets the current status of the fog (should it be enabled?)
  73006. * @param mesh defines the mesh to evaluate for fog support
  73007. * @param scene defines the hosting scene
  73008. * @returns true if fog must be enabled
  73009. */
  73010. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73011. /**
  73012. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73013. * @param mesh defines the current mesh
  73014. * @param scene defines the current scene
  73015. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73016. * @param pointsCloud defines if point cloud rendering has to be turned on
  73017. * @param fogEnabled defines if fog has to be turned on
  73018. * @param alphaTest defines if alpha testing has to be turned on
  73019. * @param defines defines the current list of defines
  73020. */
  73021. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73022. /**
  73023. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73024. * @param scene defines the current scene
  73025. * @param engine defines the current engine
  73026. * @param defines specifies the list of active defines
  73027. * @param useInstances defines if instances have to be turned on
  73028. * @param useClipPlane defines if clip plane have to be turned on
  73029. */
  73030. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73031. /**
  73032. * Prepares the defines for bones
  73033. * @param mesh The mesh containing the geometry data we will draw
  73034. * @param defines The defines to update
  73035. */
  73036. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73037. /**
  73038. * Prepares the defines for morph targets
  73039. * @param mesh The mesh containing the geometry data we will draw
  73040. * @param defines The defines to update
  73041. */
  73042. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73043. /**
  73044. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73045. * @param mesh The mesh containing the geometry data we will draw
  73046. * @param defines The defines to update
  73047. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73048. * @param useBones Precise whether bones should be used or not (override mesh info)
  73049. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73050. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73051. * @returns false if defines are considered not dirty and have not been checked
  73052. */
  73053. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73054. /**
  73055. * Prepares the defines related to multiview
  73056. * @param scene The scene we are intending to draw
  73057. * @param defines The defines to update
  73058. */
  73059. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73060. /**
  73061. * Prepares the defines related to the light information passed in parameter
  73062. * @param scene The scene we are intending to draw
  73063. * @param mesh The mesh the effect is compiling for
  73064. * @param light The light the effect is compiling for
  73065. * @param lightIndex The index of the light
  73066. * @param defines The defines to update
  73067. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73068. * @param state Defines the current state regarding what is needed (normals, etc...)
  73069. */
  73070. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73071. needNormals: boolean;
  73072. needRebuild: boolean;
  73073. shadowEnabled: boolean;
  73074. specularEnabled: boolean;
  73075. lightmapMode: boolean;
  73076. }): void;
  73077. /**
  73078. * Prepares the defines related to the light information passed in parameter
  73079. * @param scene The scene we are intending to draw
  73080. * @param mesh The mesh the effect is compiling for
  73081. * @param defines The defines to update
  73082. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73083. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73084. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73085. * @returns true if normals will be required for the rest of the effect
  73086. */
  73087. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73088. /**
  73089. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73090. * @param lightIndex defines the light index
  73091. * @param uniformsList The uniform list
  73092. * @param samplersList The sampler list
  73093. * @param projectedLightTexture defines if projected texture must be used
  73094. * @param uniformBuffersList defines an optional list of uniform buffers
  73095. */
  73096. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73097. /**
  73098. * Prepares the uniforms and samplers list to be used in the effect
  73099. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73100. * @param samplersList The sampler list
  73101. * @param defines The defines helping in the list generation
  73102. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73103. */
  73104. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73105. /**
  73106. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73107. * @param defines The defines to update while falling back
  73108. * @param fallbacks The authorized effect fallbacks
  73109. * @param maxSimultaneousLights The maximum number of lights allowed
  73110. * @param rank the current rank of the Effect
  73111. * @returns The newly affected rank
  73112. */
  73113. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73114. private static _TmpMorphInfluencers;
  73115. /**
  73116. * Prepares the list of attributes required for morph targets according to the effect defines.
  73117. * @param attribs The current list of supported attribs
  73118. * @param mesh The mesh to prepare the morph targets attributes for
  73119. * @param influencers The number of influencers
  73120. */
  73121. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73122. /**
  73123. * Prepares the list of attributes required for morph targets according to the effect defines.
  73124. * @param attribs The current list of supported attribs
  73125. * @param mesh The mesh to prepare the morph targets attributes for
  73126. * @param defines The current Defines of the effect
  73127. */
  73128. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73129. /**
  73130. * Prepares the list of attributes required for bones according to the effect defines.
  73131. * @param attribs The current list of supported attribs
  73132. * @param mesh The mesh to prepare the bones attributes for
  73133. * @param defines The current Defines of the effect
  73134. * @param fallbacks The current efffect fallback strategy
  73135. */
  73136. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73137. /**
  73138. * Check and prepare the list of attributes required for instances according to the effect defines.
  73139. * @param attribs The current list of supported attribs
  73140. * @param defines The current MaterialDefines of the effect
  73141. */
  73142. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73143. /**
  73144. * Add the list of attributes required for instances to the attribs array.
  73145. * @param attribs The current list of supported attribs
  73146. */
  73147. static PushAttributesForInstances(attribs: string[]): void;
  73148. /**
  73149. * Binds the light shadow information to the effect for the given mesh.
  73150. * @param light The light containing the generator
  73151. * @param scene The scene the lights belongs to
  73152. * @param mesh The mesh we are binding the information to render
  73153. * @param lightIndex The light index in the effect used to render the mesh
  73154. * @param effect The effect we are binding the data to
  73155. */
  73156. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73157. /**
  73158. * Binds the light information to the effect.
  73159. * @param light The light containing the generator
  73160. * @param effect The effect we are binding the data to
  73161. * @param lightIndex The light index in the effect used to render
  73162. */
  73163. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73164. /**
  73165. * Binds the lights information from the scene to the effect for the given mesh.
  73166. * @param light Light to bind
  73167. * @param lightIndex Light index
  73168. * @param scene The scene where the light belongs to
  73169. * @param mesh The mesh we are binding the information to render
  73170. * @param effect The effect we are binding the data to
  73171. * @param useSpecular Defines if specular is supported
  73172. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73173. */
  73174. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73175. /**
  73176. * Binds the lights information from the scene to the effect for the given mesh.
  73177. * @param scene The scene the lights belongs to
  73178. * @param mesh The mesh we are binding the information to render
  73179. * @param effect The effect we are binding the data to
  73180. * @param defines The generated defines for the effect
  73181. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73182. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73183. */
  73184. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73185. private static _tempFogColor;
  73186. /**
  73187. * Binds the fog information from the scene to the effect for the given mesh.
  73188. * @param scene The scene the lights belongs to
  73189. * @param mesh The mesh we are binding the information to render
  73190. * @param effect The effect we are binding the data to
  73191. * @param linearSpace Defines if the fog effect is applied in linear space
  73192. */
  73193. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73194. /**
  73195. * Binds the bones information from the mesh to the effect.
  73196. * @param mesh The mesh we are binding the information to render
  73197. * @param effect The effect we are binding the data to
  73198. */
  73199. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73200. /**
  73201. * Binds the morph targets information from the mesh to the effect.
  73202. * @param abstractMesh The mesh we are binding the information to render
  73203. * @param effect The effect we are binding the data to
  73204. */
  73205. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73206. /**
  73207. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73208. * @param defines The generated defines used in the effect
  73209. * @param effect The effect we are binding the data to
  73210. * @param scene The scene we are willing to render with logarithmic scale for
  73211. */
  73212. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73213. /**
  73214. * Binds the clip plane information from the scene to the effect.
  73215. * @param scene The scene the clip plane information are extracted from
  73216. * @param effect The effect we are binding the data to
  73217. */
  73218. static BindClipPlane(effect: Effect, scene: Scene): void;
  73219. }
  73220. }
  73221. declare module BABYLON {
  73222. /** @hidden */
  73223. export var packingFunctions: {
  73224. name: string;
  73225. shader: string;
  73226. };
  73227. }
  73228. declare module BABYLON {
  73229. /** @hidden */
  73230. export var shadowMapPixelShader: {
  73231. name: string;
  73232. shader: string;
  73233. };
  73234. }
  73235. declare module BABYLON {
  73236. /** @hidden */
  73237. export var bonesDeclaration: {
  73238. name: string;
  73239. shader: string;
  73240. };
  73241. }
  73242. declare module BABYLON {
  73243. /** @hidden */
  73244. export var morphTargetsVertexGlobalDeclaration: {
  73245. name: string;
  73246. shader: string;
  73247. };
  73248. }
  73249. declare module BABYLON {
  73250. /** @hidden */
  73251. export var morphTargetsVertexDeclaration: {
  73252. name: string;
  73253. shader: string;
  73254. };
  73255. }
  73256. declare module BABYLON {
  73257. /** @hidden */
  73258. export var instancesDeclaration: {
  73259. name: string;
  73260. shader: string;
  73261. };
  73262. }
  73263. declare module BABYLON {
  73264. /** @hidden */
  73265. export var helperFunctions: {
  73266. name: string;
  73267. shader: string;
  73268. };
  73269. }
  73270. declare module BABYLON {
  73271. /** @hidden */
  73272. export var morphTargetsVertex: {
  73273. name: string;
  73274. shader: string;
  73275. };
  73276. }
  73277. declare module BABYLON {
  73278. /** @hidden */
  73279. export var instancesVertex: {
  73280. name: string;
  73281. shader: string;
  73282. };
  73283. }
  73284. declare module BABYLON {
  73285. /** @hidden */
  73286. export var bonesVertex: {
  73287. name: string;
  73288. shader: string;
  73289. };
  73290. }
  73291. declare module BABYLON {
  73292. /** @hidden */
  73293. export var shadowMapVertexShader: {
  73294. name: string;
  73295. shader: string;
  73296. };
  73297. }
  73298. declare module BABYLON {
  73299. /** @hidden */
  73300. export var depthBoxBlurPixelShader: {
  73301. name: string;
  73302. shader: string;
  73303. };
  73304. }
  73305. declare module BABYLON {
  73306. /**
  73307. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73308. */
  73309. export interface ICustomShaderOptions {
  73310. /**
  73311. * Gets or sets the custom shader name to use
  73312. */
  73313. shaderName: string;
  73314. /**
  73315. * The list of attribute names used in the shader
  73316. */
  73317. attributes?: string[];
  73318. /**
  73319. * The list of unifrom names used in the shader
  73320. */
  73321. uniforms?: string[];
  73322. /**
  73323. * The list of sampler names used in the shader
  73324. */
  73325. samplers?: string[];
  73326. /**
  73327. * The list of defines used in the shader
  73328. */
  73329. defines?: string[];
  73330. }
  73331. /**
  73332. * Interface to implement to create a shadow generator compatible with BJS.
  73333. */
  73334. export interface IShadowGenerator {
  73335. /**
  73336. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73337. * @returns The render target texture if present otherwise, null
  73338. */
  73339. getShadowMap(): Nullable<RenderTargetTexture>;
  73340. /**
  73341. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73342. * @returns The render target texture if the shadow map is present otherwise, null
  73343. */
  73344. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73345. /**
  73346. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73347. * @param subMesh The submesh we want to render in the shadow map
  73348. * @param useInstances Defines wether will draw in the map using instances
  73349. * @returns true if ready otherwise, false
  73350. */
  73351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73352. /**
  73353. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73354. * @param defines Defines of the material we want to update
  73355. * @param lightIndex Index of the light in the enabled light list of the material
  73356. */
  73357. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73358. /**
  73359. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73360. * defined in the generator but impacting the effect).
  73361. * It implies the unifroms available on the materials are the standard BJS ones.
  73362. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73363. * @param effect The effect we are binfing the information for
  73364. */
  73365. bindShadowLight(lightIndex: string, effect: Effect): void;
  73366. /**
  73367. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73368. * (eq to shadow prjection matrix * light transform matrix)
  73369. * @returns The transform matrix used to create the shadow map
  73370. */
  73371. getTransformMatrix(): Matrix;
  73372. /**
  73373. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73374. * Cube and 2D textures for instance.
  73375. */
  73376. recreateShadowMap(): void;
  73377. /**
  73378. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73379. * @param onCompiled Callback triggered at the and of the effects compilation
  73380. * @param options Sets of optional options forcing the compilation with different modes
  73381. */
  73382. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73383. useInstances: boolean;
  73384. }>): void;
  73385. /**
  73386. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73387. * @param options Sets of optional options forcing the compilation with different modes
  73388. * @returns A promise that resolves when the compilation completes
  73389. */
  73390. forceCompilationAsync(options?: Partial<{
  73391. useInstances: boolean;
  73392. }>): Promise<void>;
  73393. /**
  73394. * Serializes the shadow generator setup to a json object.
  73395. * @returns The serialized JSON object
  73396. */
  73397. serialize(): any;
  73398. /**
  73399. * Disposes the Shadow map and related Textures and effects.
  73400. */
  73401. dispose(): void;
  73402. }
  73403. /**
  73404. * Default implementation IShadowGenerator.
  73405. * This is the main object responsible of generating shadows in the framework.
  73406. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73407. */
  73408. export class ShadowGenerator implements IShadowGenerator {
  73409. /**
  73410. * Shadow generator mode None: no filtering applied.
  73411. */
  73412. static readonly FILTER_NONE: number;
  73413. /**
  73414. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73415. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73416. */
  73417. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73418. /**
  73419. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73420. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73421. */
  73422. static readonly FILTER_POISSONSAMPLING: number;
  73423. /**
  73424. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73425. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73426. */
  73427. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73428. /**
  73429. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73430. * edge artifacts on steep falloff.
  73431. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73432. */
  73433. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73434. /**
  73435. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73436. * edge artifacts on steep falloff.
  73437. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73438. */
  73439. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73440. /**
  73441. * Shadow generator mode PCF: Percentage Closer Filtering
  73442. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73443. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73444. */
  73445. static readonly FILTER_PCF: number;
  73446. /**
  73447. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73448. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73449. * Contact Hardening
  73450. */
  73451. static readonly FILTER_PCSS: number;
  73452. /**
  73453. * Reserved for PCF and PCSS
  73454. * Highest Quality.
  73455. *
  73456. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73457. *
  73458. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73459. */
  73460. static readonly QUALITY_HIGH: number;
  73461. /**
  73462. * Reserved for PCF and PCSS
  73463. * Good tradeoff for quality/perf cross devices
  73464. *
  73465. * Execute PCF on a 3*3 kernel.
  73466. *
  73467. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73468. */
  73469. static readonly QUALITY_MEDIUM: number;
  73470. /**
  73471. * Reserved for PCF and PCSS
  73472. * The lowest quality but the fastest.
  73473. *
  73474. * Execute PCF on a 1*1 kernel.
  73475. *
  73476. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73477. */
  73478. static readonly QUALITY_LOW: number;
  73479. /** Gets or sets the custom shader name to use */
  73480. customShaderOptions: ICustomShaderOptions;
  73481. /**
  73482. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73483. */
  73484. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73485. /**
  73486. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73487. */
  73488. onAfterShadowMapRenderObservable: Observable<Effect>;
  73489. /**
  73490. * Observable triggered before a mesh is rendered in the shadow map.
  73491. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73492. */
  73493. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73494. /**
  73495. * Observable triggered after a mesh is rendered in the shadow map.
  73496. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73497. */
  73498. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73499. private _bias;
  73500. /**
  73501. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73502. */
  73503. /**
  73504. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73505. */
  73506. bias: number;
  73507. private _normalBias;
  73508. /**
  73509. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73510. */
  73511. /**
  73512. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73513. */
  73514. normalBias: number;
  73515. private _blurBoxOffset;
  73516. /**
  73517. * Gets the blur box offset: offset applied during the blur pass.
  73518. * Only useful if useKernelBlur = false
  73519. */
  73520. /**
  73521. * Sets the blur box offset: offset applied during the blur pass.
  73522. * Only useful if useKernelBlur = false
  73523. */
  73524. blurBoxOffset: number;
  73525. private _blurScale;
  73526. /**
  73527. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73528. * 2 means half of the size.
  73529. */
  73530. /**
  73531. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73532. * 2 means half of the size.
  73533. */
  73534. blurScale: number;
  73535. private _blurKernel;
  73536. /**
  73537. * Gets the blur kernel: kernel size of the blur pass.
  73538. * Only useful if useKernelBlur = true
  73539. */
  73540. /**
  73541. * Sets the blur kernel: kernel size of the blur pass.
  73542. * Only useful if useKernelBlur = true
  73543. */
  73544. blurKernel: number;
  73545. private _useKernelBlur;
  73546. /**
  73547. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73548. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73549. */
  73550. /**
  73551. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73552. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73553. */
  73554. useKernelBlur: boolean;
  73555. private _depthScale;
  73556. /**
  73557. * Gets the depth scale used in ESM mode.
  73558. */
  73559. /**
  73560. * Sets the depth scale used in ESM mode.
  73561. * This can override the scale stored on the light.
  73562. */
  73563. depthScale: number;
  73564. private _filter;
  73565. /**
  73566. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73567. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73568. */
  73569. /**
  73570. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73571. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73572. */
  73573. filter: number;
  73574. /**
  73575. * Gets if the current filter is set to Poisson Sampling.
  73576. */
  73577. /**
  73578. * Sets the current filter to Poisson Sampling.
  73579. */
  73580. usePoissonSampling: boolean;
  73581. /**
  73582. * Gets if the current filter is set to ESM.
  73583. */
  73584. /**
  73585. * Sets the current filter is to ESM.
  73586. */
  73587. useExponentialShadowMap: boolean;
  73588. /**
  73589. * Gets if the current filter is set to filtered ESM.
  73590. */
  73591. /**
  73592. * Gets if the current filter is set to filtered ESM.
  73593. */
  73594. useBlurExponentialShadowMap: boolean;
  73595. /**
  73596. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73597. * exponential to prevent steep falloff artifacts).
  73598. */
  73599. /**
  73600. * Sets the current filter to "close ESM" (using the inverse of the
  73601. * exponential to prevent steep falloff artifacts).
  73602. */
  73603. useCloseExponentialShadowMap: boolean;
  73604. /**
  73605. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73606. * exponential to prevent steep falloff artifacts).
  73607. */
  73608. /**
  73609. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73610. * exponential to prevent steep falloff artifacts).
  73611. */
  73612. useBlurCloseExponentialShadowMap: boolean;
  73613. /**
  73614. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73615. */
  73616. /**
  73617. * Sets the current filter to "PCF" (percentage closer filtering).
  73618. */
  73619. usePercentageCloserFiltering: boolean;
  73620. private _filteringQuality;
  73621. /**
  73622. * Gets the PCF or PCSS Quality.
  73623. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73624. */
  73625. /**
  73626. * Sets the PCF or PCSS Quality.
  73627. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73628. */
  73629. filteringQuality: number;
  73630. /**
  73631. * Gets if the current filter is set to "PCSS" (contact hardening).
  73632. */
  73633. /**
  73634. * Sets the current filter to "PCSS" (contact hardening).
  73635. */
  73636. useContactHardeningShadow: boolean;
  73637. private _contactHardeningLightSizeUVRatio;
  73638. /**
  73639. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73640. * Using a ratio helps keeping shape stability independently of the map size.
  73641. *
  73642. * It does not account for the light projection as it was having too much
  73643. * instability during the light setup or during light position changes.
  73644. *
  73645. * Only valid if useContactHardeningShadow is true.
  73646. */
  73647. /**
  73648. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73649. * Using a ratio helps keeping shape stability independently of the map size.
  73650. *
  73651. * It does not account for the light projection as it was having too much
  73652. * instability during the light setup or during light position changes.
  73653. *
  73654. * Only valid if useContactHardeningShadow is true.
  73655. */
  73656. contactHardeningLightSizeUVRatio: number;
  73657. private _darkness;
  73658. /** Gets or sets the actual darkness of a shadow */
  73659. darkness: number;
  73660. /**
  73661. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73662. * 0 means strongest and 1 would means no shadow.
  73663. * @returns the darkness.
  73664. */
  73665. getDarkness(): number;
  73666. /**
  73667. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73668. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73669. * @returns the shadow generator allowing fluent coding.
  73670. */
  73671. setDarkness(darkness: number): ShadowGenerator;
  73672. private _transparencyShadow;
  73673. /** Gets or sets the ability to have transparent shadow */
  73674. transparencyShadow: boolean;
  73675. /**
  73676. * Sets the ability to have transparent shadow (boolean).
  73677. * @param transparent True if transparent else False
  73678. * @returns the shadow generator allowing fluent coding
  73679. */
  73680. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73681. private _shadowMap;
  73682. private _shadowMap2;
  73683. /**
  73684. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73685. * @returns The render target texture if present otherwise, null
  73686. */
  73687. getShadowMap(): Nullable<RenderTargetTexture>;
  73688. /**
  73689. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73690. * @returns The render target texture if the shadow map is present otherwise, null
  73691. */
  73692. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73693. /**
  73694. * Gets the class name of that object
  73695. * @returns "ShadowGenerator"
  73696. */
  73697. getClassName(): string;
  73698. /**
  73699. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73700. * @param mesh Mesh to add
  73701. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73702. * @returns the Shadow Generator itself
  73703. */
  73704. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73705. /**
  73706. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73707. * @param mesh Mesh to remove
  73708. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73709. * @returns the Shadow Generator itself
  73710. */
  73711. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73712. /**
  73713. * Controls the extent to which the shadows fade out at the edge of the frustum
  73714. * Used only by directionals and spots
  73715. */
  73716. frustumEdgeFalloff: number;
  73717. private _light;
  73718. /**
  73719. * Returns the associated light object.
  73720. * @returns the light generating the shadow
  73721. */
  73722. getLight(): IShadowLight;
  73723. /**
  73724. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73725. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73726. * It might on the other hand introduce peter panning.
  73727. */
  73728. forceBackFacesOnly: boolean;
  73729. private _scene;
  73730. private _lightDirection;
  73731. private _effect;
  73732. private _viewMatrix;
  73733. private _projectionMatrix;
  73734. private _transformMatrix;
  73735. private _cachedPosition;
  73736. private _cachedDirection;
  73737. private _cachedDefines;
  73738. private _currentRenderID;
  73739. private _boxBlurPostprocess;
  73740. private _kernelBlurXPostprocess;
  73741. private _kernelBlurYPostprocess;
  73742. private _blurPostProcesses;
  73743. private _mapSize;
  73744. private _currentFaceIndex;
  73745. private _currentFaceIndexCache;
  73746. private _textureType;
  73747. private _defaultTextureMatrix;
  73748. /** @hidden */
  73749. static _SceneComponentInitialization: (scene: Scene) => void;
  73750. /**
  73751. * Creates a ShadowGenerator object.
  73752. * A ShadowGenerator is the required tool to use the shadows.
  73753. * Each light casting shadows needs to use its own ShadowGenerator.
  73754. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73755. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73756. * @param light The light object generating the shadows.
  73757. * @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.
  73758. */
  73759. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73760. private _initializeGenerator;
  73761. private _initializeShadowMap;
  73762. private _initializeBlurRTTAndPostProcesses;
  73763. private _renderForShadowMap;
  73764. private _renderSubMeshForShadowMap;
  73765. private _applyFilterValues;
  73766. /**
  73767. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73768. * @param onCompiled Callback triggered at the and of the effects compilation
  73769. * @param options Sets of optional options forcing the compilation with different modes
  73770. */
  73771. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73772. useInstances: boolean;
  73773. }>): void;
  73774. /**
  73775. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73776. * @param options Sets of optional options forcing the compilation with different modes
  73777. * @returns A promise that resolves when the compilation completes
  73778. */
  73779. forceCompilationAsync(options?: Partial<{
  73780. useInstances: boolean;
  73781. }>): Promise<void>;
  73782. /**
  73783. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73784. * @param subMesh The submesh we want to render in the shadow map
  73785. * @param useInstances Defines wether will draw in the map using instances
  73786. * @returns true if ready otherwise, false
  73787. */
  73788. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73789. /**
  73790. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73791. * @param defines Defines of the material we want to update
  73792. * @param lightIndex Index of the light in the enabled light list of the material
  73793. */
  73794. prepareDefines(defines: any, lightIndex: number): void;
  73795. /**
  73796. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73797. * defined in the generator but impacting the effect).
  73798. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73799. * @param effect The effect we are binfing the information for
  73800. */
  73801. bindShadowLight(lightIndex: string, effect: Effect): void;
  73802. /**
  73803. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73804. * (eq to shadow prjection matrix * light transform matrix)
  73805. * @returns The transform matrix used to create the shadow map
  73806. */
  73807. getTransformMatrix(): Matrix;
  73808. /**
  73809. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73810. * Cube and 2D textures for instance.
  73811. */
  73812. recreateShadowMap(): void;
  73813. private _disposeBlurPostProcesses;
  73814. private _disposeRTTandPostProcesses;
  73815. /**
  73816. * Disposes the ShadowGenerator.
  73817. * Returns nothing.
  73818. */
  73819. dispose(): void;
  73820. /**
  73821. * Serializes the shadow generator setup to a json object.
  73822. * @returns The serialized JSON object
  73823. */
  73824. serialize(): any;
  73825. /**
  73826. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73827. * @param parsedShadowGenerator The JSON object to parse
  73828. * @param scene The scene to create the shadow map for
  73829. * @returns The parsed shadow generator
  73830. */
  73831. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73832. }
  73833. }
  73834. declare module BABYLON {
  73835. /**
  73836. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73837. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73838. * 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.
  73839. */
  73840. export abstract class Light extends Node {
  73841. /**
  73842. * Falloff Default: light is falling off following the material specification:
  73843. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73844. */
  73845. static readonly FALLOFF_DEFAULT: number;
  73846. /**
  73847. * Falloff Physical: light is falling off following the inverse squared distance law.
  73848. */
  73849. static readonly FALLOFF_PHYSICAL: number;
  73850. /**
  73851. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73852. * to enhance interoperability with other engines.
  73853. */
  73854. static readonly FALLOFF_GLTF: number;
  73855. /**
  73856. * Falloff Standard: light is falling off like in the standard material
  73857. * to enhance interoperability with other materials.
  73858. */
  73859. static readonly FALLOFF_STANDARD: number;
  73860. /**
  73861. * If every light affecting the material is in this lightmapMode,
  73862. * material.lightmapTexture adds or multiplies
  73863. * (depends on material.useLightmapAsShadowmap)
  73864. * after every other light calculations.
  73865. */
  73866. static readonly LIGHTMAP_DEFAULT: number;
  73867. /**
  73868. * material.lightmapTexture as only diffuse lighting from this light
  73869. * adds only specular lighting from this light
  73870. * adds dynamic shadows
  73871. */
  73872. static readonly LIGHTMAP_SPECULAR: number;
  73873. /**
  73874. * material.lightmapTexture as only lighting
  73875. * no light calculation from this light
  73876. * only adds dynamic shadows from this light
  73877. */
  73878. static readonly LIGHTMAP_SHADOWSONLY: number;
  73879. /**
  73880. * Each light type uses the default quantity according to its type:
  73881. * point/spot lights use luminous intensity
  73882. * directional lights use illuminance
  73883. */
  73884. static readonly INTENSITYMODE_AUTOMATIC: number;
  73885. /**
  73886. * lumen (lm)
  73887. */
  73888. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73889. /**
  73890. * candela (lm/sr)
  73891. */
  73892. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73893. /**
  73894. * lux (lm/m^2)
  73895. */
  73896. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73897. /**
  73898. * nit (cd/m^2)
  73899. */
  73900. static readonly INTENSITYMODE_LUMINANCE: number;
  73901. /**
  73902. * Light type const id of the point light.
  73903. */
  73904. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73905. /**
  73906. * Light type const id of the directional light.
  73907. */
  73908. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73909. /**
  73910. * Light type const id of the spot light.
  73911. */
  73912. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73913. /**
  73914. * Light type const id of the hemispheric light.
  73915. */
  73916. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73917. /**
  73918. * Diffuse gives the basic color to an object.
  73919. */
  73920. diffuse: Color3;
  73921. /**
  73922. * Specular produces a highlight color on an object.
  73923. * Note: This is note affecting PBR materials.
  73924. */
  73925. specular: Color3;
  73926. /**
  73927. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73928. * falling off base on range or angle.
  73929. * This can be set to any values in Light.FALLOFF_x.
  73930. *
  73931. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73932. * other types of materials.
  73933. */
  73934. falloffType: number;
  73935. /**
  73936. * Strength of the light.
  73937. * Note: By default it is define in the framework own unit.
  73938. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73939. */
  73940. intensity: number;
  73941. private _range;
  73942. protected _inverseSquaredRange: number;
  73943. /**
  73944. * Defines how far from the source the light is impacting in scene units.
  73945. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73946. */
  73947. /**
  73948. * Defines how far from the source the light is impacting in scene units.
  73949. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73950. */
  73951. range: number;
  73952. /**
  73953. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73954. * of light.
  73955. */
  73956. private _photometricScale;
  73957. private _intensityMode;
  73958. /**
  73959. * Gets the photometric scale used to interpret the intensity.
  73960. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73961. */
  73962. /**
  73963. * Sets the photometric scale used to interpret the intensity.
  73964. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73965. */
  73966. intensityMode: number;
  73967. private _radius;
  73968. /**
  73969. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73970. */
  73971. /**
  73972. * sets the light radius used by PBR Materials to simulate soft area lights.
  73973. */
  73974. radius: number;
  73975. private _renderPriority;
  73976. /**
  73977. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73978. * exceeding the number allowed of the materials.
  73979. */
  73980. renderPriority: number;
  73981. private _shadowEnabled;
  73982. /**
  73983. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73984. * the current shadow generator.
  73985. */
  73986. /**
  73987. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73988. * the current shadow generator.
  73989. */
  73990. shadowEnabled: boolean;
  73991. private _includedOnlyMeshes;
  73992. /**
  73993. * Gets the only meshes impacted by this light.
  73994. */
  73995. /**
  73996. * Sets the only meshes impacted by this light.
  73997. */
  73998. includedOnlyMeshes: AbstractMesh[];
  73999. private _excludedMeshes;
  74000. /**
  74001. * Gets the meshes not impacted by this light.
  74002. */
  74003. /**
  74004. * Sets the meshes not impacted by this light.
  74005. */
  74006. excludedMeshes: AbstractMesh[];
  74007. private _excludeWithLayerMask;
  74008. /**
  74009. * Gets the layer id use to find what meshes are not impacted by the light.
  74010. * Inactive if 0
  74011. */
  74012. /**
  74013. * Sets the layer id use to find what meshes are not impacted by the light.
  74014. * Inactive if 0
  74015. */
  74016. excludeWithLayerMask: number;
  74017. private _includeOnlyWithLayerMask;
  74018. /**
  74019. * Gets the layer id use to find what meshes are impacted by the light.
  74020. * Inactive if 0
  74021. */
  74022. /**
  74023. * Sets the layer id use to find what meshes are impacted by the light.
  74024. * Inactive if 0
  74025. */
  74026. includeOnlyWithLayerMask: number;
  74027. private _lightmapMode;
  74028. /**
  74029. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74030. */
  74031. /**
  74032. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74033. */
  74034. lightmapMode: number;
  74035. /**
  74036. * Shadow generator associted to the light.
  74037. * @hidden Internal use only.
  74038. */
  74039. _shadowGenerator: Nullable<IShadowGenerator>;
  74040. /**
  74041. * @hidden Internal use only.
  74042. */
  74043. _excludedMeshesIds: string[];
  74044. /**
  74045. * @hidden Internal use only.
  74046. */
  74047. _includedOnlyMeshesIds: string[];
  74048. /**
  74049. * The current light unifom buffer.
  74050. * @hidden Internal use only.
  74051. */
  74052. _uniformBuffer: UniformBuffer;
  74053. /**
  74054. * Creates a Light object in the scene.
  74055. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74056. * @param name The firendly name of the light
  74057. * @param scene The scene the light belongs too
  74058. */
  74059. constructor(name: string, scene: Scene);
  74060. protected abstract _buildUniformLayout(): void;
  74061. /**
  74062. * Sets the passed Effect "effect" with the Light information.
  74063. * @param effect The effect to update
  74064. * @param lightIndex The index of the light in the effect to update
  74065. * @returns The light
  74066. */
  74067. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74068. /**
  74069. * Returns the string "Light".
  74070. * @returns the class name
  74071. */
  74072. getClassName(): string;
  74073. /** @hidden */
  74074. readonly _isLight: boolean;
  74075. /**
  74076. * Converts the light information to a readable string for debug purpose.
  74077. * @param fullDetails Supports for multiple levels of logging within scene loading
  74078. * @returns the human readable light info
  74079. */
  74080. toString(fullDetails?: boolean): string;
  74081. /** @hidden */
  74082. protected _syncParentEnabledState(): void;
  74083. /**
  74084. * Set the enabled state of this node.
  74085. * @param value - the new enabled state
  74086. */
  74087. setEnabled(value: boolean): void;
  74088. /**
  74089. * Returns the Light associated shadow generator if any.
  74090. * @return the associated shadow generator.
  74091. */
  74092. getShadowGenerator(): Nullable<IShadowGenerator>;
  74093. /**
  74094. * Returns a Vector3, the absolute light position in the World.
  74095. * @returns the world space position of the light
  74096. */
  74097. getAbsolutePosition(): Vector3;
  74098. /**
  74099. * Specifies if the light will affect the passed mesh.
  74100. * @param mesh The mesh to test against the light
  74101. * @return true the mesh is affected otherwise, false.
  74102. */
  74103. canAffectMesh(mesh: AbstractMesh): boolean;
  74104. /**
  74105. * Sort function to order lights for rendering.
  74106. * @param a First Light object to compare to second.
  74107. * @param b Second Light object to compare first.
  74108. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74109. */
  74110. static CompareLightsPriority(a: Light, b: Light): number;
  74111. /**
  74112. * Releases resources associated with this node.
  74113. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74114. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74115. */
  74116. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74117. /**
  74118. * Returns the light type ID (integer).
  74119. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74120. */
  74121. getTypeID(): number;
  74122. /**
  74123. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74124. * @returns the scaled intensity in intensity mode unit
  74125. */
  74126. getScaledIntensity(): number;
  74127. /**
  74128. * Returns a new Light object, named "name", from the current one.
  74129. * @param name The name of the cloned light
  74130. * @returns the new created light
  74131. */
  74132. clone(name: string): Nullable<Light>;
  74133. /**
  74134. * Serializes the current light into a Serialization object.
  74135. * @returns the serialized object.
  74136. */
  74137. serialize(): any;
  74138. /**
  74139. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74140. * This new light is named "name" and added to the passed scene.
  74141. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74142. * @param name The friendly name of the light
  74143. * @param scene The scene the new light will belong to
  74144. * @returns the constructor function
  74145. */
  74146. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74147. /**
  74148. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74149. * @param parsedLight The JSON representation of the light
  74150. * @param scene The scene to create the parsed light in
  74151. * @returns the created light after parsing
  74152. */
  74153. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74154. private _hookArrayForExcluded;
  74155. private _hookArrayForIncludedOnly;
  74156. private _resyncMeshes;
  74157. /**
  74158. * Forces the meshes to update their light related information in their rendering used effects
  74159. * @hidden Internal Use Only
  74160. */
  74161. _markMeshesAsLightDirty(): void;
  74162. /**
  74163. * Recomputes the cached photometric scale if needed.
  74164. */
  74165. private _computePhotometricScale;
  74166. /**
  74167. * Returns the Photometric Scale according to the light type and intensity mode.
  74168. */
  74169. private _getPhotometricScale;
  74170. /**
  74171. * Reorder the light in the scene according to their defined priority.
  74172. * @hidden Internal Use Only
  74173. */
  74174. _reorderLightsInScene(): void;
  74175. /**
  74176. * Prepares the list of defines specific to the light type.
  74177. * @param defines the list of defines
  74178. * @param lightIndex defines the index of the light for the effect
  74179. */
  74180. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74181. }
  74182. }
  74183. declare module BABYLON {
  74184. /**
  74185. * Interface used to define Action
  74186. */
  74187. export interface IAction {
  74188. /**
  74189. * Trigger for the action
  74190. */
  74191. trigger: number;
  74192. /** Options of the trigger */
  74193. triggerOptions: any;
  74194. /**
  74195. * Gets the trigger parameters
  74196. * @returns the trigger parameters
  74197. */
  74198. getTriggerParameter(): any;
  74199. /**
  74200. * Internal only - executes current action event
  74201. * @hidden
  74202. */
  74203. _executeCurrent(evt?: ActionEvent): void;
  74204. /**
  74205. * Serialize placeholder for child classes
  74206. * @param parent of child
  74207. * @returns the serialized object
  74208. */
  74209. serialize(parent: any): any;
  74210. /**
  74211. * Internal only
  74212. * @hidden
  74213. */
  74214. _prepare(): void;
  74215. /**
  74216. * Internal only - manager for action
  74217. * @hidden
  74218. */
  74219. _actionManager: AbstractActionManager;
  74220. /**
  74221. * Adds action to chain of actions, may be a DoNothingAction
  74222. * @param action defines the next action to execute
  74223. * @returns The action passed in
  74224. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74225. */
  74226. then(action: IAction): IAction;
  74227. }
  74228. /**
  74229. * The action to be carried out following a trigger
  74230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  74231. */
  74232. export class Action implements IAction {
  74233. /** the trigger, with or without parameters, for the action */
  74234. triggerOptions: any;
  74235. /**
  74236. * Trigger for the action
  74237. */
  74238. trigger: number;
  74239. /**
  74240. * Internal only - manager for action
  74241. * @hidden
  74242. */
  74243. _actionManager: ActionManager;
  74244. private _nextActiveAction;
  74245. private _child;
  74246. private _condition?;
  74247. private _triggerParameter;
  74248. /**
  74249. * An event triggered prior to action being executed.
  74250. */
  74251. onBeforeExecuteObservable: Observable<Action>;
  74252. /**
  74253. * Creates a new Action
  74254. * @param triggerOptions the trigger, with or without parameters, for the action
  74255. * @param condition an optional determinant of action
  74256. */
  74257. constructor(
  74258. /** the trigger, with or without parameters, for the action */
  74259. triggerOptions: any, condition?: Condition);
  74260. /**
  74261. * Internal only
  74262. * @hidden
  74263. */
  74264. _prepare(): void;
  74265. /**
  74266. * Gets the trigger parameters
  74267. * @returns the trigger parameters
  74268. */
  74269. getTriggerParameter(): any;
  74270. /**
  74271. * Internal only - executes current action event
  74272. * @hidden
  74273. */
  74274. _executeCurrent(evt?: ActionEvent): void;
  74275. /**
  74276. * Execute placeholder for child classes
  74277. * @param evt optional action event
  74278. */
  74279. execute(evt?: ActionEvent): void;
  74280. /**
  74281. * Skips to next active action
  74282. */
  74283. skipToNextActiveAction(): void;
  74284. /**
  74285. * Adds action to chain of actions, may be a DoNothingAction
  74286. * @param action defines the next action to execute
  74287. * @returns The action passed in
  74288. * @see https://www.babylonjs-playground.com/#1T30HR#0
  74289. */
  74290. then(action: Action): Action;
  74291. /**
  74292. * Internal only
  74293. * @hidden
  74294. */
  74295. _getProperty(propertyPath: string): string;
  74296. /**
  74297. * Internal only
  74298. * @hidden
  74299. */
  74300. _getEffectiveTarget(target: any, propertyPath: string): any;
  74301. /**
  74302. * Serialize placeholder for child classes
  74303. * @param parent of child
  74304. * @returns the serialized object
  74305. */
  74306. serialize(parent: any): any;
  74307. /**
  74308. * Internal only called by serialize
  74309. * @hidden
  74310. */
  74311. protected _serialize(serializedAction: any, parent?: any): any;
  74312. /**
  74313. * Internal only
  74314. * @hidden
  74315. */
  74316. static _SerializeValueAsString: (value: any) => string;
  74317. /**
  74318. * Internal only
  74319. * @hidden
  74320. */
  74321. static _GetTargetProperty: (target: Node | Scene) => {
  74322. name: string;
  74323. targetType: string;
  74324. value: string;
  74325. };
  74326. }
  74327. }
  74328. declare module BABYLON {
  74329. /**
  74330. * A Condition applied to an Action
  74331. */
  74332. export class Condition {
  74333. /**
  74334. * Internal only - manager for action
  74335. * @hidden
  74336. */
  74337. _actionManager: ActionManager;
  74338. /**
  74339. * Internal only
  74340. * @hidden
  74341. */
  74342. _evaluationId: number;
  74343. /**
  74344. * Internal only
  74345. * @hidden
  74346. */
  74347. _currentResult: boolean;
  74348. /**
  74349. * Creates a new Condition
  74350. * @param actionManager the manager of the action the condition is applied to
  74351. */
  74352. constructor(actionManager: ActionManager);
  74353. /**
  74354. * Check if the current condition is valid
  74355. * @returns a boolean
  74356. */
  74357. isValid(): boolean;
  74358. /**
  74359. * Internal only
  74360. * @hidden
  74361. */
  74362. _getProperty(propertyPath: string): string;
  74363. /**
  74364. * Internal only
  74365. * @hidden
  74366. */
  74367. _getEffectiveTarget(target: any, propertyPath: string): any;
  74368. /**
  74369. * Serialize placeholder for child classes
  74370. * @returns the serialized object
  74371. */
  74372. serialize(): any;
  74373. /**
  74374. * Internal only
  74375. * @hidden
  74376. */
  74377. protected _serialize(serializedCondition: any): any;
  74378. }
  74379. /**
  74380. * Defines specific conditional operators as extensions of Condition
  74381. */
  74382. export class ValueCondition extends Condition {
  74383. /** path to specify the property of the target the conditional operator uses */
  74384. propertyPath: string;
  74385. /** the value compared by the conditional operator against the current value of the property */
  74386. value: any;
  74387. /** the conditional operator, default ValueCondition.IsEqual */
  74388. operator: number;
  74389. /**
  74390. * Internal only
  74391. * @hidden
  74392. */
  74393. private static _IsEqual;
  74394. /**
  74395. * Internal only
  74396. * @hidden
  74397. */
  74398. private static _IsDifferent;
  74399. /**
  74400. * Internal only
  74401. * @hidden
  74402. */
  74403. private static _IsGreater;
  74404. /**
  74405. * Internal only
  74406. * @hidden
  74407. */
  74408. private static _IsLesser;
  74409. /**
  74410. * returns the number for IsEqual
  74411. */
  74412. static readonly IsEqual: number;
  74413. /**
  74414. * Returns the number for IsDifferent
  74415. */
  74416. static readonly IsDifferent: number;
  74417. /**
  74418. * Returns the number for IsGreater
  74419. */
  74420. static readonly IsGreater: number;
  74421. /**
  74422. * Returns the number for IsLesser
  74423. */
  74424. static readonly IsLesser: number;
  74425. /**
  74426. * Internal only The action manager for the condition
  74427. * @hidden
  74428. */
  74429. _actionManager: ActionManager;
  74430. /**
  74431. * Internal only
  74432. * @hidden
  74433. */
  74434. private _target;
  74435. /**
  74436. * Internal only
  74437. * @hidden
  74438. */
  74439. private _effectiveTarget;
  74440. /**
  74441. * Internal only
  74442. * @hidden
  74443. */
  74444. private _property;
  74445. /**
  74446. * Creates a new ValueCondition
  74447. * @param actionManager manager for the action the condition applies to
  74448. * @param target for the action
  74449. * @param propertyPath path to specify the property of the target the conditional operator uses
  74450. * @param value the value compared by the conditional operator against the current value of the property
  74451. * @param operator the conditional operator, default ValueCondition.IsEqual
  74452. */
  74453. constructor(actionManager: ActionManager, target: any,
  74454. /** path to specify the property of the target the conditional operator uses */
  74455. propertyPath: string,
  74456. /** the value compared by the conditional operator against the current value of the property */
  74457. value: any,
  74458. /** the conditional operator, default ValueCondition.IsEqual */
  74459. operator?: number);
  74460. /**
  74461. * Compares the given value with the property value for the specified conditional operator
  74462. * @returns the result of the comparison
  74463. */
  74464. isValid(): boolean;
  74465. /**
  74466. * Serialize the ValueCondition into a JSON compatible object
  74467. * @returns serialization object
  74468. */
  74469. serialize(): any;
  74470. /**
  74471. * Gets the name of the conditional operator for the ValueCondition
  74472. * @param operator the conditional operator
  74473. * @returns the name
  74474. */
  74475. static GetOperatorName(operator: number): string;
  74476. }
  74477. /**
  74478. * Defines a predicate condition as an extension of Condition
  74479. */
  74480. export class PredicateCondition extends Condition {
  74481. /** defines the predicate function used to validate the condition */
  74482. predicate: () => boolean;
  74483. /**
  74484. * Internal only - manager for action
  74485. * @hidden
  74486. */
  74487. _actionManager: ActionManager;
  74488. /**
  74489. * Creates a new PredicateCondition
  74490. * @param actionManager manager for the action the condition applies to
  74491. * @param predicate defines the predicate function used to validate the condition
  74492. */
  74493. constructor(actionManager: ActionManager,
  74494. /** defines the predicate function used to validate the condition */
  74495. predicate: () => boolean);
  74496. /**
  74497. * @returns the validity of the predicate condition
  74498. */
  74499. isValid(): boolean;
  74500. }
  74501. /**
  74502. * Defines a state condition as an extension of Condition
  74503. */
  74504. export class StateCondition extends Condition {
  74505. /** Value to compare with target state */
  74506. value: string;
  74507. /**
  74508. * Internal only - manager for action
  74509. * @hidden
  74510. */
  74511. _actionManager: ActionManager;
  74512. /**
  74513. * Internal only
  74514. * @hidden
  74515. */
  74516. private _target;
  74517. /**
  74518. * Creates a new StateCondition
  74519. * @param actionManager manager for the action the condition applies to
  74520. * @param target of the condition
  74521. * @param value to compare with target state
  74522. */
  74523. constructor(actionManager: ActionManager, target: any,
  74524. /** Value to compare with target state */
  74525. value: string);
  74526. /**
  74527. * Gets a boolean indicating if the current condition is met
  74528. * @returns the validity of the state
  74529. */
  74530. isValid(): boolean;
  74531. /**
  74532. * Serialize the StateCondition into a JSON compatible object
  74533. * @returns serialization object
  74534. */
  74535. serialize(): any;
  74536. }
  74537. }
  74538. declare module BABYLON {
  74539. /**
  74540. * This defines an action responsible to toggle a boolean once triggered.
  74541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74542. */
  74543. export class SwitchBooleanAction extends Action {
  74544. /**
  74545. * The path to the boolean property in the target object
  74546. */
  74547. propertyPath: string;
  74548. private _target;
  74549. private _effectiveTarget;
  74550. private _property;
  74551. /**
  74552. * Instantiate the action
  74553. * @param triggerOptions defines the trigger options
  74554. * @param target defines the object containing the boolean
  74555. * @param propertyPath defines the path to the boolean property in the target object
  74556. * @param condition defines the trigger related conditions
  74557. */
  74558. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74559. /** @hidden */
  74560. _prepare(): void;
  74561. /**
  74562. * Execute the action toggle the boolean value.
  74563. */
  74564. execute(): void;
  74565. /**
  74566. * Serializes the actions and its related information.
  74567. * @param parent defines the object to serialize in
  74568. * @returns the serialized object
  74569. */
  74570. serialize(parent: any): any;
  74571. }
  74572. /**
  74573. * This defines an action responsible to set a the state field of the target
  74574. * to a desired value once triggered.
  74575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74576. */
  74577. export class SetStateAction extends Action {
  74578. /**
  74579. * The value to store in the state field.
  74580. */
  74581. value: string;
  74582. private _target;
  74583. /**
  74584. * Instantiate the action
  74585. * @param triggerOptions defines the trigger options
  74586. * @param target defines the object containing the state property
  74587. * @param value defines the value to store in the state field
  74588. * @param condition defines the trigger related conditions
  74589. */
  74590. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74591. /**
  74592. * Execute the action and store the value on the target state property.
  74593. */
  74594. execute(): void;
  74595. /**
  74596. * Serializes the actions and its related information.
  74597. * @param parent defines the object to serialize in
  74598. * @returns the serialized object
  74599. */
  74600. serialize(parent: any): any;
  74601. }
  74602. /**
  74603. * This defines an action responsible to set a property of the target
  74604. * to a desired value once triggered.
  74605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74606. */
  74607. export class SetValueAction extends Action {
  74608. /**
  74609. * The path of the property to set in the target.
  74610. */
  74611. propertyPath: string;
  74612. /**
  74613. * The value to set in the property
  74614. */
  74615. value: any;
  74616. private _target;
  74617. private _effectiveTarget;
  74618. private _property;
  74619. /**
  74620. * Instantiate the action
  74621. * @param triggerOptions defines the trigger options
  74622. * @param target defines the object containing the property
  74623. * @param propertyPath defines the path of the property to set in the target
  74624. * @param value defines the value to set in the property
  74625. * @param condition defines the trigger related conditions
  74626. */
  74627. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74628. /** @hidden */
  74629. _prepare(): void;
  74630. /**
  74631. * Execute the action and set the targetted property to the desired value.
  74632. */
  74633. execute(): void;
  74634. /**
  74635. * Serializes the actions and its related information.
  74636. * @param parent defines the object to serialize in
  74637. * @returns the serialized object
  74638. */
  74639. serialize(parent: any): any;
  74640. }
  74641. /**
  74642. * This defines an action responsible to increment the target value
  74643. * to a desired value once triggered.
  74644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74645. */
  74646. export class IncrementValueAction extends Action {
  74647. /**
  74648. * The path of the property to increment in the target.
  74649. */
  74650. propertyPath: string;
  74651. /**
  74652. * The value we should increment the property by.
  74653. */
  74654. value: any;
  74655. private _target;
  74656. private _effectiveTarget;
  74657. private _property;
  74658. /**
  74659. * Instantiate the action
  74660. * @param triggerOptions defines the trigger options
  74661. * @param target defines the object containing the property
  74662. * @param propertyPath defines the path of the property to increment in the target
  74663. * @param value defines the value value we should increment the property by
  74664. * @param condition defines the trigger related conditions
  74665. */
  74666. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74667. /** @hidden */
  74668. _prepare(): void;
  74669. /**
  74670. * Execute the action and increment the target of the value amount.
  74671. */
  74672. execute(): void;
  74673. /**
  74674. * Serializes the actions and its related information.
  74675. * @param parent defines the object to serialize in
  74676. * @returns the serialized object
  74677. */
  74678. serialize(parent: any): any;
  74679. }
  74680. /**
  74681. * This defines an action responsible to start an animation once triggered.
  74682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74683. */
  74684. export class PlayAnimationAction extends Action {
  74685. /**
  74686. * Where the animation should start (animation frame)
  74687. */
  74688. from: number;
  74689. /**
  74690. * Where the animation should stop (animation frame)
  74691. */
  74692. to: number;
  74693. /**
  74694. * Define if the animation should loop or stop after the first play.
  74695. */
  74696. loop?: boolean;
  74697. private _target;
  74698. /**
  74699. * Instantiate the action
  74700. * @param triggerOptions defines the trigger options
  74701. * @param target defines the target animation or animation name
  74702. * @param from defines from where the animation should start (animation frame)
  74703. * @param end defines where the animation should stop (animation frame)
  74704. * @param loop defines if the animation should loop or stop after the first play
  74705. * @param condition defines the trigger related conditions
  74706. */
  74707. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74708. /** @hidden */
  74709. _prepare(): void;
  74710. /**
  74711. * Execute the action and play the animation.
  74712. */
  74713. execute(): void;
  74714. /**
  74715. * Serializes the actions and its related information.
  74716. * @param parent defines the object to serialize in
  74717. * @returns the serialized object
  74718. */
  74719. serialize(parent: any): any;
  74720. }
  74721. /**
  74722. * This defines an action responsible to stop an animation once triggered.
  74723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74724. */
  74725. export class StopAnimationAction extends Action {
  74726. private _target;
  74727. /**
  74728. * Instantiate the action
  74729. * @param triggerOptions defines the trigger options
  74730. * @param target defines the target animation or animation name
  74731. * @param condition defines the trigger related conditions
  74732. */
  74733. constructor(triggerOptions: any, target: any, condition?: Condition);
  74734. /** @hidden */
  74735. _prepare(): void;
  74736. /**
  74737. * Execute the action and stop the animation.
  74738. */
  74739. execute(): void;
  74740. /**
  74741. * Serializes the actions and its related information.
  74742. * @param parent defines the object to serialize in
  74743. * @returns the serialized object
  74744. */
  74745. serialize(parent: any): any;
  74746. }
  74747. /**
  74748. * This defines an action responsible that does nothing once triggered.
  74749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74750. */
  74751. export class DoNothingAction extends Action {
  74752. /**
  74753. * Instantiate the action
  74754. * @param triggerOptions defines the trigger options
  74755. * @param condition defines the trigger related conditions
  74756. */
  74757. constructor(triggerOptions?: any, condition?: Condition);
  74758. /**
  74759. * Execute the action and do nothing.
  74760. */
  74761. execute(): void;
  74762. /**
  74763. * Serializes the actions and its related information.
  74764. * @param parent defines the object to serialize in
  74765. * @returns the serialized object
  74766. */
  74767. serialize(parent: any): any;
  74768. }
  74769. /**
  74770. * This defines an action responsible to trigger several actions once triggered.
  74771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74772. */
  74773. export class CombineAction extends Action {
  74774. /**
  74775. * The list of aggregated animations to run.
  74776. */
  74777. children: Action[];
  74778. /**
  74779. * Instantiate the action
  74780. * @param triggerOptions defines the trigger options
  74781. * @param children defines the list of aggregated animations to run
  74782. * @param condition defines the trigger related conditions
  74783. */
  74784. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74785. /** @hidden */
  74786. _prepare(): void;
  74787. /**
  74788. * Execute the action and executes all the aggregated actions.
  74789. */
  74790. execute(evt: ActionEvent): void;
  74791. /**
  74792. * Serializes the actions and its related information.
  74793. * @param parent defines the object to serialize in
  74794. * @returns the serialized object
  74795. */
  74796. serialize(parent: any): any;
  74797. }
  74798. /**
  74799. * This defines an action responsible to run code (external event) once triggered.
  74800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74801. */
  74802. export class ExecuteCodeAction extends Action {
  74803. /**
  74804. * The callback function to run.
  74805. */
  74806. func: (evt: ActionEvent) => void;
  74807. /**
  74808. * Instantiate the action
  74809. * @param triggerOptions defines the trigger options
  74810. * @param func defines the callback function to run
  74811. * @param condition defines the trigger related conditions
  74812. */
  74813. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74814. /**
  74815. * Execute the action and run the attached code.
  74816. */
  74817. execute(evt: ActionEvent): void;
  74818. }
  74819. /**
  74820. * This defines an action responsible to set the parent property of the target once triggered.
  74821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74822. */
  74823. export class SetParentAction extends Action {
  74824. private _parent;
  74825. private _target;
  74826. /**
  74827. * Instantiate the action
  74828. * @param triggerOptions defines the trigger options
  74829. * @param target defines the target containing the parent property
  74830. * @param parent defines from where the animation should start (animation frame)
  74831. * @param condition defines the trigger related conditions
  74832. */
  74833. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74834. /** @hidden */
  74835. _prepare(): void;
  74836. /**
  74837. * Execute the action and set the parent property.
  74838. */
  74839. execute(): void;
  74840. /**
  74841. * Serializes the actions and its related information.
  74842. * @param parent defines the object to serialize in
  74843. * @returns the serialized object
  74844. */
  74845. serialize(parent: any): any;
  74846. }
  74847. }
  74848. declare module BABYLON {
  74849. /**
  74850. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74851. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74853. */
  74854. export class ActionManager extends AbstractActionManager {
  74855. /**
  74856. * Nothing
  74857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74858. */
  74859. static readonly NothingTrigger: number;
  74860. /**
  74861. * On pick
  74862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74863. */
  74864. static readonly OnPickTrigger: number;
  74865. /**
  74866. * On left pick
  74867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74868. */
  74869. static readonly OnLeftPickTrigger: number;
  74870. /**
  74871. * On right pick
  74872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74873. */
  74874. static readonly OnRightPickTrigger: number;
  74875. /**
  74876. * On center pick
  74877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74878. */
  74879. static readonly OnCenterPickTrigger: number;
  74880. /**
  74881. * On pick down
  74882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74883. */
  74884. static readonly OnPickDownTrigger: number;
  74885. /**
  74886. * On double pick
  74887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74888. */
  74889. static readonly OnDoublePickTrigger: number;
  74890. /**
  74891. * On pick up
  74892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74893. */
  74894. static readonly OnPickUpTrigger: number;
  74895. /**
  74896. * On pick out.
  74897. * This trigger will only be raised if you also declared a OnPickDown
  74898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74899. */
  74900. static readonly OnPickOutTrigger: number;
  74901. /**
  74902. * On long press
  74903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74904. */
  74905. static readonly OnLongPressTrigger: number;
  74906. /**
  74907. * On pointer over
  74908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74909. */
  74910. static readonly OnPointerOverTrigger: number;
  74911. /**
  74912. * On pointer out
  74913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74914. */
  74915. static readonly OnPointerOutTrigger: number;
  74916. /**
  74917. * On every frame
  74918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74919. */
  74920. static readonly OnEveryFrameTrigger: number;
  74921. /**
  74922. * On intersection enter
  74923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74924. */
  74925. static readonly OnIntersectionEnterTrigger: number;
  74926. /**
  74927. * On intersection exit
  74928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74929. */
  74930. static readonly OnIntersectionExitTrigger: number;
  74931. /**
  74932. * On key down
  74933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74934. */
  74935. static readonly OnKeyDownTrigger: number;
  74936. /**
  74937. * On key up
  74938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74939. */
  74940. static readonly OnKeyUpTrigger: number;
  74941. private _scene;
  74942. /**
  74943. * Creates a new action manager
  74944. * @param scene defines the hosting scene
  74945. */
  74946. constructor(scene: Scene);
  74947. /**
  74948. * Releases all associated resources
  74949. */
  74950. dispose(): void;
  74951. /**
  74952. * Gets hosting scene
  74953. * @returns the hosting scene
  74954. */
  74955. getScene(): Scene;
  74956. /**
  74957. * Does this action manager handles actions of any of the given triggers
  74958. * @param triggers defines the triggers to be tested
  74959. * @return a boolean indicating whether one (or more) of the triggers is handled
  74960. */
  74961. hasSpecificTriggers(triggers: number[]): boolean;
  74962. /**
  74963. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74964. * speed.
  74965. * @param triggerA defines the trigger to be tested
  74966. * @param triggerB defines the trigger to be tested
  74967. * @return a boolean indicating whether one (or more) of the triggers is handled
  74968. */
  74969. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74970. /**
  74971. * Does this action manager handles actions of a given trigger
  74972. * @param trigger defines the trigger to be tested
  74973. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74974. * @return whether the trigger is handled
  74975. */
  74976. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74977. /**
  74978. * Does this action manager has pointer triggers
  74979. */
  74980. readonly hasPointerTriggers: boolean;
  74981. /**
  74982. * Does this action manager has pick triggers
  74983. */
  74984. readonly hasPickTriggers: boolean;
  74985. /**
  74986. * Registers an action to this action manager
  74987. * @param action defines the action to be registered
  74988. * @return the action amended (prepared) after registration
  74989. */
  74990. registerAction(action: IAction): Nullable<IAction>;
  74991. /**
  74992. * Unregisters an action to this action manager
  74993. * @param action defines the action to be unregistered
  74994. * @return a boolean indicating whether the action has been unregistered
  74995. */
  74996. unregisterAction(action: IAction): Boolean;
  74997. /**
  74998. * Process a specific trigger
  74999. * @param trigger defines the trigger to process
  75000. * @param evt defines the event details to be processed
  75001. */
  75002. processTrigger(trigger: number, evt?: IActionEvent): void;
  75003. /** @hidden */
  75004. _getEffectiveTarget(target: any, propertyPath: string): any;
  75005. /** @hidden */
  75006. _getProperty(propertyPath: string): string;
  75007. /**
  75008. * Serialize this manager to a JSON object
  75009. * @param name defines the property name to store this manager
  75010. * @returns a JSON representation of this manager
  75011. */
  75012. serialize(name: string): any;
  75013. /**
  75014. * Creates a new ActionManager from a JSON data
  75015. * @param parsedActions defines the JSON data to read from
  75016. * @param object defines the hosting mesh
  75017. * @param scene defines the hosting scene
  75018. */
  75019. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  75020. /**
  75021. * Get a trigger name by index
  75022. * @param trigger defines the trigger index
  75023. * @returns a trigger name
  75024. */
  75025. static GetTriggerName(trigger: number): string;
  75026. }
  75027. }
  75028. declare module BABYLON {
  75029. /**
  75030. * Class representing a ray with position and direction
  75031. */
  75032. export class Ray {
  75033. /** origin point */
  75034. origin: Vector3;
  75035. /** direction */
  75036. direction: Vector3;
  75037. /** length of the ray */
  75038. length: number;
  75039. private static readonly TmpVector3;
  75040. private _tmpRay;
  75041. /**
  75042. * Creates a new ray
  75043. * @param origin origin point
  75044. * @param direction direction
  75045. * @param length length of the ray
  75046. */
  75047. constructor(
  75048. /** origin point */
  75049. origin: Vector3,
  75050. /** direction */
  75051. direction: Vector3,
  75052. /** length of the ray */
  75053. length?: number);
  75054. /**
  75055. * Checks if the ray intersects a box
  75056. * @param minimum bound of the box
  75057. * @param maximum bound of the box
  75058. * @param intersectionTreshold extra extend to be added to the box in all direction
  75059. * @returns if the box was hit
  75060. */
  75061. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  75062. /**
  75063. * Checks if the ray intersects a box
  75064. * @param box the bounding box to check
  75065. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  75066. * @returns if the box was hit
  75067. */
  75068. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  75069. /**
  75070. * If the ray hits a sphere
  75071. * @param sphere the bounding sphere to check
  75072. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  75073. * @returns true if it hits the sphere
  75074. */
  75075. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  75076. /**
  75077. * If the ray hits a triange
  75078. * @param vertex0 triangle vertex
  75079. * @param vertex1 triangle vertex
  75080. * @param vertex2 triangle vertex
  75081. * @returns intersection information if hit
  75082. */
  75083. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  75084. /**
  75085. * Checks if ray intersects a plane
  75086. * @param plane the plane to check
  75087. * @returns the distance away it was hit
  75088. */
  75089. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  75090. /**
  75091. * Calculate the intercept of a ray on a given axis
  75092. * @param axis to check 'x' | 'y' | 'z'
  75093. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  75094. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  75095. */
  75096. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  75097. /**
  75098. * Checks if ray intersects a mesh
  75099. * @param mesh the mesh to check
  75100. * @param fastCheck if only the bounding box should checked
  75101. * @returns picking info of the intersecton
  75102. */
  75103. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  75104. /**
  75105. * Checks if ray intersects a mesh
  75106. * @param meshes the meshes to check
  75107. * @param fastCheck if only the bounding box should checked
  75108. * @param results array to store result in
  75109. * @returns Array of picking infos
  75110. */
  75111. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  75112. private _comparePickingInfo;
  75113. private static smallnum;
  75114. private static rayl;
  75115. /**
  75116. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  75117. * @param sega the first point of the segment to test the intersection against
  75118. * @param segb the second point of the segment to test the intersection against
  75119. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  75120. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  75121. */
  75122. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  75123. /**
  75124. * Update the ray from viewport position
  75125. * @param x position
  75126. * @param y y position
  75127. * @param viewportWidth viewport width
  75128. * @param viewportHeight viewport height
  75129. * @param world world matrix
  75130. * @param view view matrix
  75131. * @param projection projection matrix
  75132. * @returns this ray updated
  75133. */
  75134. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75135. /**
  75136. * Creates a ray with origin and direction of 0,0,0
  75137. * @returns the new ray
  75138. */
  75139. static Zero(): Ray;
  75140. /**
  75141. * Creates a new ray from screen space and viewport
  75142. * @param x position
  75143. * @param y y position
  75144. * @param viewportWidth viewport width
  75145. * @param viewportHeight viewport height
  75146. * @param world world matrix
  75147. * @param view view matrix
  75148. * @param projection projection matrix
  75149. * @returns new ray
  75150. */
  75151. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  75152. /**
  75153. * 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
  75154. * transformed to the given world matrix.
  75155. * @param origin The origin point
  75156. * @param end The end point
  75157. * @param world a matrix to transform the ray to. Default is the identity matrix.
  75158. * @returns the new ray
  75159. */
  75160. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  75161. /**
  75162. * Transforms a ray by a matrix
  75163. * @param ray ray to transform
  75164. * @param matrix matrix to apply
  75165. * @returns the resulting new ray
  75166. */
  75167. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  75168. /**
  75169. * Transforms a ray by a matrix
  75170. * @param ray ray to transform
  75171. * @param matrix matrix to apply
  75172. * @param result ray to store result in
  75173. */
  75174. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  75175. /**
  75176. * Unproject a ray from screen space to object space
  75177. * @param sourceX defines the screen space x coordinate to use
  75178. * @param sourceY defines the screen space y coordinate to use
  75179. * @param viewportWidth defines the current width of the viewport
  75180. * @param viewportHeight defines the current height of the viewport
  75181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  75182. * @param view defines the view matrix to use
  75183. * @param projection defines the projection matrix to use
  75184. */
  75185. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  75186. }
  75187. /**
  75188. * Type used to define predicate used to select faces when a mesh intersection is detected
  75189. */
  75190. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  75191. interface Scene {
  75192. /** @hidden */
  75193. _tempPickingRay: Nullable<Ray>;
  75194. /** @hidden */
  75195. _cachedRayForTransform: Ray;
  75196. /** @hidden */
  75197. _pickWithRayInverseMatrix: Matrix;
  75198. /** @hidden */
  75199. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  75200. /** @hidden */
  75201. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  75202. }
  75203. }
  75204. declare module BABYLON {
  75205. /**
  75206. * Groups all the scene component constants in one place to ease maintenance.
  75207. * @hidden
  75208. */
  75209. export class SceneComponentConstants {
  75210. static readonly NAME_EFFECTLAYER: string;
  75211. static readonly NAME_LAYER: string;
  75212. static readonly NAME_LENSFLARESYSTEM: string;
  75213. static readonly NAME_BOUNDINGBOXRENDERER: string;
  75214. static readonly NAME_PARTICLESYSTEM: string;
  75215. static readonly NAME_GAMEPAD: string;
  75216. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  75217. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  75218. static readonly NAME_DEPTHRENDERER: string;
  75219. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  75220. static readonly NAME_SPRITE: string;
  75221. static readonly NAME_OUTLINERENDERER: string;
  75222. static readonly NAME_PROCEDURALTEXTURE: string;
  75223. static readonly NAME_SHADOWGENERATOR: string;
  75224. static readonly NAME_OCTREE: string;
  75225. static readonly NAME_PHYSICSENGINE: string;
  75226. static readonly NAME_AUDIO: string;
  75227. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  75228. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75229. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  75230. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  75231. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  75232. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  75233. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  75234. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  75235. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  75236. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  75237. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  75238. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  75239. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  75240. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  75241. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  75242. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  75243. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  75244. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  75245. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  75246. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  75247. static readonly STEP_AFTERRENDER_AUDIO: number;
  75248. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  75249. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  75250. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  75251. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  75252. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  75253. static readonly STEP_POINTERMOVE_SPRITE: number;
  75254. static readonly STEP_POINTERDOWN_SPRITE: number;
  75255. static readonly STEP_POINTERUP_SPRITE: number;
  75256. }
  75257. /**
  75258. * This represents a scene component.
  75259. *
  75260. * This is used to decouple the dependency the scene is having on the different workloads like
  75261. * layers, post processes...
  75262. */
  75263. export interface ISceneComponent {
  75264. /**
  75265. * The name of the component. Each component must have a unique name.
  75266. */
  75267. name: string;
  75268. /**
  75269. * The scene the component belongs to.
  75270. */
  75271. scene: Scene;
  75272. /**
  75273. * Register the component to one instance of a scene.
  75274. */
  75275. register(): void;
  75276. /**
  75277. * Rebuilds the elements related to this component in case of
  75278. * context lost for instance.
  75279. */
  75280. rebuild(): void;
  75281. /**
  75282. * Disposes the component and the associated ressources.
  75283. */
  75284. dispose(): void;
  75285. }
  75286. /**
  75287. * This represents a SERIALIZABLE scene component.
  75288. *
  75289. * This extends Scene Component to add Serialization methods on top.
  75290. */
  75291. export interface ISceneSerializableComponent extends ISceneComponent {
  75292. /**
  75293. * Adds all the elements from the container to the scene
  75294. * @param container the container holding the elements
  75295. */
  75296. addFromContainer(container: AbstractScene): void;
  75297. /**
  75298. * Removes all the elements in the container from the scene
  75299. * @param container contains the elements to remove
  75300. * @param dispose if the removed element should be disposed (default: false)
  75301. */
  75302. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75303. /**
  75304. * Serializes the component data to the specified json object
  75305. * @param serializationObject The object to serialize to
  75306. */
  75307. serialize(serializationObject: any): void;
  75308. }
  75309. /**
  75310. * Strong typing of a Mesh related stage step action
  75311. */
  75312. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75313. /**
  75314. * Strong typing of a Evaluate Sub Mesh related stage step action
  75315. */
  75316. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75317. /**
  75318. * Strong typing of a Active Mesh related stage step action
  75319. */
  75320. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75321. /**
  75322. * Strong typing of a Camera related stage step action
  75323. */
  75324. export type CameraStageAction = (camera: Camera) => void;
  75325. /**
  75326. * Strong typing of a Camera Frame buffer related stage step action
  75327. */
  75328. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75329. /**
  75330. * Strong typing of a Render Target related stage step action
  75331. */
  75332. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75333. /**
  75334. * Strong typing of a RenderingGroup related stage step action
  75335. */
  75336. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75337. /**
  75338. * Strong typing of a Mesh Render related stage step action
  75339. */
  75340. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75341. /**
  75342. * Strong typing of a simple stage step action
  75343. */
  75344. export type SimpleStageAction = () => void;
  75345. /**
  75346. * Strong typing of a render target action.
  75347. */
  75348. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75349. /**
  75350. * Strong typing of a pointer move action.
  75351. */
  75352. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75353. /**
  75354. * Strong typing of a pointer up/down action.
  75355. */
  75356. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75357. /**
  75358. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75359. * @hidden
  75360. */
  75361. export class Stage<T extends Function> extends Array<{
  75362. index: number;
  75363. component: ISceneComponent;
  75364. action: T;
  75365. }> {
  75366. /**
  75367. * Hide ctor from the rest of the world.
  75368. * @param items The items to add.
  75369. */
  75370. private constructor();
  75371. /**
  75372. * Creates a new Stage.
  75373. * @returns A new instance of a Stage
  75374. */
  75375. static Create<T extends Function>(): Stage<T>;
  75376. /**
  75377. * Registers a step in an ordered way in the targeted stage.
  75378. * @param index Defines the position to register the step in
  75379. * @param component Defines the component attached to the step
  75380. * @param action Defines the action to launch during the step
  75381. */
  75382. registerStep(index: number, component: ISceneComponent, action: T): void;
  75383. /**
  75384. * Clears all the steps from the stage.
  75385. */
  75386. clear(): void;
  75387. }
  75388. }
  75389. declare module BABYLON {
  75390. interface Scene {
  75391. /** @hidden */
  75392. _pointerOverSprite: Nullable<Sprite>;
  75393. /** @hidden */
  75394. _pickedDownSprite: Nullable<Sprite>;
  75395. /** @hidden */
  75396. _tempSpritePickingRay: Nullable<Ray>;
  75397. /**
  75398. * All of the sprite managers added to this scene
  75399. * @see http://doc.babylonjs.com/babylon101/sprites
  75400. */
  75401. spriteManagers: Array<ISpriteManager>;
  75402. /**
  75403. * An event triggered when sprites rendering is about to start
  75404. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75405. */
  75406. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75407. /**
  75408. * An event triggered when sprites rendering is done
  75409. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75410. */
  75411. onAfterSpritesRenderingObservable: Observable<Scene>;
  75412. /** @hidden */
  75413. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75414. /** Launch a ray to try to pick a sprite in the scene
  75415. * @param x position on screen
  75416. * @param y position on screen
  75417. * @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
  75418. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75419. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75420. * @returns a PickingInfo
  75421. */
  75422. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75423. /** Use the given ray to pick a sprite in the scene
  75424. * @param ray The ray (in world space) to use to pick meshes
  75425. * @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
  75426. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75427. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75428. * @returns a PickingInfo
  75429. */
  75430. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75431. /**
  75432. * Force the sprite under the pointer
  75433. * @param sprite defines the sprite to use
  75434. */
  75435. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75436. /**
  75437. * Gets the sprite under the pointer
  75438. * @returns a Sprite or null if no sprite is under the pointer
  75439. */
  75440. getPointerOverSprite(): Nullable<Sprite>;
  75441. }
  75442. /**
  75443. * Defines the sprite scene component responsible to manage sprites
  75444. * in a given scene.
  75445. */
  75446. export class SpriteSceneComponent implements ISceneComponent {
  75447. /**
  75448. * The component name helpfull to identify the component in the list of scene components.
  75449. */
  75450. readonly name: string;
  75451. /**
  75452. * The scene the component belongs to.
  75453. */
  75454. scene: Scene;
  75455. /** @hidden */
  75456. private _spritePredicate;
  75457. /**
  75458. * Creates a new instance of the component for the given scene
  75459. * @param scene Defines the scene to register the component in
  75460. */
  75461. constructor(scene: Scene);
  75462. /**
  75463. * Registers the component in a given scene
  75464. */
  75465. register(): void;
  75466. /**
  75467. * Rebuilds the elements related to this component in case of
  75468. * context lost for instance.
  75469. */
  75470. rebuild(): void;
  75471. /**
  75472. * Disposes the component and the associated ressources.
  75473. */
  75474. dispose(): void;
  75475. private _pickSpriteButKeepRay;
  75476. private _pointerMove;
  75477. private _pointerDown;
  75478. private _pointerUp;
  75479. }
  75480. }
  75481. declare module BABYLON {
  75482. /** @hidden */
  75483. export var fogFragmentDeclaration: {
  75484. name: string;
  75485. shader: string;
  75486. };
  75487. }
  75488. declare module BABYLON {
  75489. /** @hidden */
  75490. export var fogFragment: {
  75491. name: string;
  75492. shader: string;
  75493. };
  75494. }
  75495. declare module BABYLON {
  75496. /** @hidden */
  75497. export var spritesPixelShader: {
  75498. name: string;
  75499. shader: string;
  75500. };
  75501. }
  75502. declare module BABYLON {
  75503. /** @hidden */
  75504. export var fogVertexDeclaration: {
  75505. name: string;
  75506. shader: string;
  75507. };
  75508. }
  75509. declare module BABYLON {
  75510. /** @hidden */
  75511. export var spritesVertexShader: {
  75512. name: string;
  75513. shader: string;
  75514. };
  75515. }
  75516. declare module BABYLON {
  75517. /**
  75518. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75519. */
  75520. export interface ISpriteManager extends IDisposable {
  75521. /**
  75522. * Restricts the camera to viewing objects with the same layerMask.
  75523. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75524. */
  75525. layerMask: number;
  75526. /**
  75527. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75528. */
  75529. isPickable: boolean;
  75530. /**
  75531. * Specifies the rendering group id for this mesh (0 by default)
  75532. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75533. */
  75534. renderingGroupId: number;
  75535. /**
  75536. * Defines the list of sprites managed by the manager.
  75537. */
  75538. sprites: Array<Sprite>;
  75539. /**
  75540. * Tests the intersection of a sprite with a specific ray.
  75541. * @param ray The ray we are sending to test the collision
  75542. * @param camera The camera space we are sending rays in
  75543. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75544. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75545. * @returns picking info or null.
  75546. */
  75547. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75548. /**
  75549. * Renders the list of sprites on screen.
  75550. */
  75551. render(): void;
  75552. }
  75553. /**
  75554. * Class used to manage multiple sprites on the same spritesheet
  75555. * @see http://doc.babylonjs.com/babylon101/sprites
  75556. */
  75557. export class SpriteManager implements ISpriteManager {
  75558. /** defines the manager's name */
  75559. name: string;
  75560. /** Gets the list of sprites */
  75561. sprites: Sprite[];
  75562. /** Gets or sets the rendering group id (0 by default) */
  75563. renderingGroupId: number;
  75564. /** Gets or sets camera layer mask */
  75565. layerMask: number;
  75566. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75567. fogEnabled: boolean;
  75568. /** Gets or sets a boolean indicating if the sprites are pickable */
  75569. isPickable: boolean;
  75570. /** Defines the default width of a cell in the spritesheet */
  75571. cellWidth: number;
  75572. /** Defines the default height of a cell in the spritesheet */
  75573. cellHeight: number;
  75574. /**
  75575. * An event triggered when the manager is disposed.
  75576. */
  75577. onDisposeObservable: Observable<SpriteManager>;
  75578. private _onDisposeObserver;
  75579. /**
  75580. * Callback called when the manager is disposed
  75581. */
  75582. onDispose: () => void;
  75583. private _capacity;
  75584. private _spriteTexture;
  75585. private _epsilon;
  75586. private _scene;
  75587. private _vertexData;
  75588. private _buffer;
  75589. private _vertexBuffers;
  75590. private _indexBuffer;
  75591. private _effectBase;
  75592. private _effectFog;
  75593. /**
  75594. * Gets or sets the spritesheet texture
  75595. */
  75596. texture: Texture;
  75597. /**
  75598. * Creates a new sprite manager
  75599. * @param name defines the manager's name
  75600. * @param imgUrl defines the sprite sheet url
  75601. * @param capacity defines the maximum allowed number of sprites
  75602. * @param cellSize defines the size of a sprite cell
  75603. * @param scene defines the hosting scene
  75604. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75605. * @param samplingMode defines the smapling mode to use with spritesheet
  75606. */
  75607. constructor(
  75608. /** defines the manager's name */
  75609. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75610. private _appendSpriteVertex;
  75611. /**
  75612. * Intersects the sprites with a ray
  75613. * @param ray defines the ray to intersect with
  75614. * @param camera defines the current active camera
  75615. * @param predicate defines a predicate used to select candidate sprites
  75616. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75617. * @returns null if no hit or a PickingInfo
  75618. */
  75619. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75620. /**
  75621. * Render all child sprites
  75622. */
  75623. render(): void;
  75624. /**
  75625. * Release associated resources
  75626. */
  75627. dispose(): void;
  75628. }
  75629. }
  75630. declare module BABYLON {
  75631. /**
  75632. * Class used to represent a sprite
  75633. * @see http://doc.babylonjs.com/babylon101/sprites
  75634. */
  75635. export class Sprite {
  75636. /** defines the name */
  75637. name: string;
  75638. /** Gets or sets the current world position */
  75639. position: Vector3;
  75640. /** Gets or sets the main color */
  75641. color: Color4;
  75642. /** Gets or sets the width */
  75643. width: number;
  75644. /** Gets or sets the height */
  75645. height: number;
  75646. /** Gets or sets rotation angle */
  75647. angle: number;
  75648. /** Gets or sets the cell index in the sprite sheet */
  75649. cellIndex: number;
  75650. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75651. invertU: number;
  75652. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75653. invertV: number;
  75654. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75655. disposeWhenFinishedAnimating: boolean;
  75656. /** Gets the list of attached animations */
  75657. animations: Animation[];
  75658. /** Gets or sets a boolean indicating if the sprite can be picked */
  75659. isPickable: boolean;
  75660. /**
  75661. * Gets or sets the associated action manager
  75662. */
  75663. actionManager: Nullable<ActionManager>;
  75664. private _animationStarted;
  75665. private _loopAnimation;
  75666. private _fromIndex;
  75667. private _toIndex;
  75668. private _delay;
  75669. private _direction;
  75670. private _manager;
  75671. private _time;
  75672. private _onAnimationEnd;
  75673. /**
  75674. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75675. */
  75676. isVisible: boolean;
  75677. /**
  75678. * Gets or sets the sprite size
  75679. */
  75680. size: number;
  75681. /**
  75682. * Creates a new Sprite
  75683. * @param name defines the name
  75684. * @param manager defines the manager
  75685. */
  75686. constructor(
  75687. /** defines the name */
  75688. name: string, manager: ISpriteManager);
  75689. /**
  75690. * Starts an animation
  75691. * @param from defines the initial key
  75692. * @param to defines the end key
  75693. * @param loop defines if the animation must loop
  75694. * @param delay defines the start delay (in ms)
  75695. * @param onAnimationEnd defines a callback to call when animation ends
  75696. */
  75697. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75698. /** Stops current animation (if any) */
  75699. stopAnimation(): void;
  75700. /** @hidden */
  75701. _animate(deltaTime: number): void;
  75702. /** Release associated resources */
  75703. dispose(): void;
  75704. }
  75705. }
  75706. declare module BABYLON {
  75707. /**
  75708. * Information about the result of picking within a scene
  75709. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75710. */
  75711. export class PickingInfo {
  75712. /** @hidden */
  75713. _pickingUnavailable: boolean;
  75714. /**
  75715. * If the pick collided with an object
  75716. */
  75717. hit: boolean;
  75718. /**
  75719. * Distance away where the pick collided
  75720. */
  75721. distance: number;
  75722. /**
  75723. * The location of pick collision
  75724. */
  75725. pickedPoint: Nullable<Vector3>;
  75726. /**
  75727. * The mesh corresponding the the pick collision
  75728. */
  75729. pickedMesh: Nullable<AbstractMesh>;
  75730. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75731. bu: number;
  75732. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75733. bv: number;
  75734. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75735. faceId: number;
  75736. /** Id of the the submesh that was picked */
  75737. subMeshId: number;
  75738. /** If a sprite was picked, this will be the sprite the pick collided with */
  75739. pickedSprite: Nullable<Sprite>;
  75740. /**
  75741. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75742. */
  75743. originMesh: Nullable<AbstractMesh>;
  75744. /**
  75745. * The ray that was used to perform the picking.
  75746. */
  75747. ray: Nullable<Ray>;
  75748. /**
  75749. * Gets the normal correspodning to the face the pick collided with
  75750. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75751. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75752. * @returns The normal correspodning to the face the pick collided with
  75753. */
  75754. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75755. /**
  75756. * Gets the texture coordinates of where the pick occured
  75757. * @returns the vector containing the coordnates of the texture
  75758. */
  75759. getTextureCoordinates(): Nullable<Vector2>;
  75760. }
  75761. }
  75762. declare module BABYLON {
  75763. /**
  75764. * Gather the list of pointer event types as constants.
  75765. */
  75766. export class PointerEventTypes {
  75767. /**
  75768. * 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.
  75769. */
  75770. static readonly POINTERDOWN: number;
  75771. /**
  75772. * The pointerup event is fired when a pointer is no longer active.
  75773. */
  75774. static readonly POINTERUP: number;
  75775. /**
  75776. * The pointermove event is fired when a pointer changes coordinates.
  75777. */
  75778. static readonly POINTERMOVE: number;
  75779. /**
  75780. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75781. */
  75782. static readonly POINTERWHEEL: number;
  75783. /**
  75784. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75785. */
  75786. static readonly POINTERPICK: number;
  75787. /**
  75788. * The pointertap event is fired when a the object has been touched and released without drag.
  75789. */
  75790. static readonly POINTERTAP: number;
  75791. /**
  75792. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75793. */
  75794. static readonly POINTERDOUBLETAP: number;
  75795. }
  75796. /**
  75797. * Base class of pointer info types.
  75798. */
  75799. export class PointerInfoBase {
  75800. /**
  75801. * Defines the type of event (PointerEventTypes)
  75802. */
  75803. type: number;
  75804. /**
  75805. * Defines the related dom event
  75806. */
  75807. event: PointerEvent | MouseWheelEvent;
  75808. /**
  75809. * Instantiates the base class of pointers info.
  75810. * @param type Defines the type of event (PointerEventTypes)
  75811. * @param event Defines the related dom event
  75812. */
  75813. constructor(
  75814. /**
  75815. * Defines the type of event (PointerEventTypes)
  75816. */
  75817. type: number,
  75818. /**
  75819. * Defines the related dom event
  75820. */
  75821. event: PointerEvent | MouseWheelEvent);
  75822. }
  75823. /**
  75824. * This class is used to store pointer related info for the onPrePointerObservable event.
  75825. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75826. */
  75827. export class PointerInfoPre extends PointerInfoBase {
  75828. /**
  75829. * Ray from a pointer if availible (eg. 6dof controller)
  75830. */
  75831. ray: Nullable<Ray>;
  75832. /**
  75833. * Defines the local position of the pointer on the canvas.
  75834. */
  75835. localPosition: Vector2;
  75836. /**
  75837. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75838. */
  75839. skipOnPointerObservable: boolean;
  75840. /**
  75841. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75842. * @param type Defines the type of event (PointerEventTypes)
  75843. * @param event Defines the related dom event
  75844. * @param localX Defines the local x coordinates of the pointer when the event occured
  75845. * @param localY Defines the local y coordinates of the pointer when the event occured
  75846. */
  75847. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75848. }
  75849. /**
  75850. * This type contains all the data related to a pointer event in Babylon.js.
  75851. * 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.
  75852. */
  75853. export class PointerInfo extends PointerInfoBase {
  75854. /**
  75855. * Defines the picking info associated to the info (if any)\
  75856. */
  75857. pickInfo: Nullable<PickingInfo>;
  75858. /**
  75859. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75860. * @param type Defines the type of event (PointerEventTypes)
  75861. * @param event Defines the related dom event
  75862. * @param pickInfo Defines the picking info associated to the info (if any)\
  75863. */
  75864. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75865. /**
  75866. * Defines the picking info associated to the info (if any)\
  75867. */
  75868. pickInfo: Nullable<PickingInfo>);
  75869. }
  75870. /**
  75871. * Data relating to a touch event on the screen.
  75872. */
  75873. export interface PointerTouch {
  75874. /**
  75875. * X coordinate of touch.
  75876. */
  75877. x: number;
  75878. /**
  75879. * Y coordinate of touch.
  75880. */
  75881. y: number;
  75882. /**
  75883. * Id of touch. Unique for each finger.
  75884. */
  75885. pointerId: number;
  75886. /**
  75887. * Event type passed from DOM.
  75888. */
  75889. type: any;
  75890. }
  75891. }
  75892. declare module BABYLON {
  75893. /**
  75894. * Manage the mouse inputs to control the movement of a free camera.
  75895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75896. */
  75897. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75898. /**
  75899. * Define if touch is enabled in the mouse input
  75900. */
  75901. touchEnabled: boolean;
  75902. /**
  75903. * Defines the camera the input is attached to.
  75904. */
  75905. camera: FreeCamera;
  75906. /**
  75907. * Defines the buttons associated with the input to handle camera move.
  75908. */
  75909. buttons: number[];
  75910. /**
  75911. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75912. */
  75913. angularSensibility: number;
  75914. private _pointerInput;
  75915. private _onMouseMove;
  75916. private _observer;
  75917. private previousPosition;
  75918. /**
  75919. * Observable for when a pointer move event occurs containing the move offset
  75920. */
  75921. onPointerMovedObservable: Observable<{
  75922. offsetX: number;
  75923. offsetY: number;
  75924. }>;
  75925. /**
  75926. * @hidden
  75927. * If the camera should be rotated automatically based on pointer movement
  75928. */
  75929. _allowCameraRotation: boolean;
  75930. /**
  75931. * Manage the mouse inputs to control the movement of a free camera.
  75932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75933. * @param touchEnabled Defines if touch is enabled or not
  75934. */
  75935. constructor(
  75936. /**
  75937. * Define if touch is enabled in the mouse input
  75938. */
  75939. touchEnabled?: boolean);
  75940. /**
  75941. * Attach the input controls to a specific dom element to get the input from.
  75942. * @param element Defines the element the controls should be listened from
  75943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75944. */
  75945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75946. /**
  75947. * Called on JS contextmenu event.
  75948. * Override this method to provide functionality.
  75949. */
  75950. protected onContextMenu(evt: PointerEvent): void;
  75951. /**
  75952. * Detach the current controls from the specified dom element.
  75953. * @param element Defines the element to stop listening the inputs from
  75954. */
  75955. detachControl(element: Nullable<HTMLElement>): void;
  75956. /**
  75957. * Gets the class name of the current intput.
  75958. * @returns the class name
  75959. */
  75960. getClassName(): string;
  75961. /**
  75962. * Get the friendly name associated with the input class.
  75963. * @returns the input friendly name
  75964. */
  75965. getSimpleName(): string;
  75966. }
  75967. }
  75968. declare module BABYLON {
  75969. /**
  75970. * Manage the touch inputs to control the movement of a free camera.
  75971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75972. */
  75973. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75974. /**
  75975. * Defines the camera the input is attached to.
  75976. */
  75977. camera: FreeCamera;
  75978. /**
  75979. * Defines the touch sensibility for rotation.
  75980. * The higher the faster.
  75981. */
  75982. touchAngularSensibility: number;
  75983. /**
  75984. * Defines the touch sensibility for move.
  75985. * The higher the faster.
  75986. */
  75987. touchMoveSensibility: number;
  75988. private _offsetX;
  75989. private _offsetY;
  75990. private _pointerPressed;
  75991. private _pointerInput;
  75992. private _observer;
  75993. private _onLostFocus;
  75994. /**
  75995. * Attach the input controls to a specific dom element to get the input from.
  75996. * @param element Defines the element the controls should be listened from
  75997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75998. */
  75999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76000. /**
  76001. * Detach the current controls from the specified dom element.
  76002. * @param element Defines the element to stop listening the inputs from
  76003. */
  76004. detachControl(element: Nullable<HTMLElement>): void;
  76005. /**
  76006. * Update the current camera state depending on the inputs that have been used this frame.
  76007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  76008. */
  76009. checkInputs(): void;
  76010. /**
  76011. * Gets the class name of the current intput.
  76012. * @returns the class name
  76013. */
  76014. getClassName(): string;
  76015. /**
  76016. * Get the friendly name associated with the input class.
  76017. * @returns the input friendly name
  76018. */
  76019. getSimpleName(): string;
  76020. }
  76021. }
  76022. declare module BABYLON {
  76023. /**
  76024. * Default Inputs manager for the FreeCamera.
  76025. * It groups all the default supported inputs for ease of use.
  76026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  76027. */
  76028. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  76029. /**
  76030. * @hidden
  76031. */
  76032. _mouseInput: Nullable<FreeCameraMouseInput>;
  76033. /**
  76034. * Instantiates a new FreeCameraInputsManager.
  76035. * @param camera Defines the camera the inputs belong to
  76036. */
  76037. constructor(camera: FreeCamera);
  76038. /**
  76039. * Add keyboard input support to the input manager.
  76040. * @returns the current input manager
  76041. */
  76042. addKeyboard(): FreeCameraInputsManager;
  76043. /**
  76044. * Add mouse input support to the input manager.
  76045. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  76046. * @returns the current input manager
  76047. */
  76048. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  76049. /**
  76050. * Removes the mouse input support from the manager
  76051. * @returns the current input manager
  76052. */
  76053. removeMouse(): FreeCameraInputsManager;
  76054. /**
  76055. * Add touch input support to the input manager.
  76056. * @returns the current input manager
  76057. */
  76058. addTouch(): FreeCameraInputsManager;
  76059. /**
  76060. * Remove all attached input methods from a camera
  76061. */
  76062. clear(): void;
  76063. }
  76064. }
  76065. declare module BABYLON {
  76066. /**
  76067. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76068. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  76069. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76070. */
  76071. export class FreeCamera extends TargetCamera {
  76072. /**
  76073. * Define the collision ellipsoid of the camera.
  76074. * This is helpful to simulate a camera body like the player body around the camera
  76075. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  76076. */
  76077. ellipsoid: Vector3;
  76078. /**
  76079. * Define an offset for the position of the ellipsoid around the camera.
  76080. * This can be helpful to determine the center of the body near the gravity center of the body
  76081. * instead of its head.
  76082. */
  76083. ellipsoidOffset: Vector3;
  76084. /**
  76085. * Enable or disable collisions of the camera with the rest of the scene objects.
  76086. */
  76087. checkCollisions: boolean;
  76088. /**
  76089. * Enable or disable gravity on the camera.
  76090. */
  76091. applyGravity: boolean;
  76092. /**
  76093. * Define the input manager associated to the camera.
  76094. */
  76095. inputs: FreeCameraInputsManager;
  76096. /**
  76097. * Gets the input sensibility for a mouse input. (default is 2000.0)
  76098. * Higher values reduce sensitivity.
  76099. */
  76100. /**
  76101. * Sets the input sensibility for a mouse input. (default is 2000.0)
  76102. * Higher values reduce sensitivity.
  76103. */
  76104. angularSensibility: number;
  76105. /**
  76106. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  76107. */
  76108. keysUp: number[];
  76109. /**
  76110. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  76111. */
  76112. keysDown: number[];
  76113. /**
  76114. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  76115. */
  76116. keysLeft: number[];
  76117. /**
  76118. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  76119. */
  76120. keysRight: number[];
  76121. /**
  76122. * Event raised when the camera collide with a mesh in the scene.
  76123. */
  76124. onCollide: (collidedMesh: AbstractMesh) => void;
  76125. private _collider;
  76126. private _needMoveForGravity;
  76127. private _oldPosition;
  76128. private _diffPosition;
  76129. private _newPosition;
  76130. /** @hidden */
  76131. _localDirection: Vector3;
  76132. /** @hidden */
  76133. _transformedDirection: Vector3;
  76134. /**
  76135. * Instantiates a Free Camera.
  76136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  76137. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  76138. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  76139. * @param name Define the name of the camera in the scene
  76140. * @param position Define the start position of the camera in the scene
  76141. * @param scene Define the scene the camera belongs to
  76142. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76143. */
  76144. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76145. /**
  76146. * Attached controls to the current camera.
  76147. * @param element Defines the element the controls should be listened from
  76148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  76149. */
  76150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76151. /**
  76152. * Detach the current controls from the camera.
  76153. * The camera will stop reacting to inputs.
  76154. * @param element Defines the element to stop listening the inputs from
  76155. */
  76156. detachControl(element: HTMLElement): void;
  76157. private _collisionMask;
  76158. /**
  76159. * Define a collision mask to limit the list of object the camera can collide with
  76160. */
  76161. collisionMask: number;
  76162. /** @hidden */
  76163. _collideWithWorld(displacement: Vector3): void;
  76164. private _onCollisionPositionChange;
  76165. /** @hidden */
  76166. _checkInputs(): void;
  76167. /** @hidden */
  76168. _decideIfNeedsToMove(): boolean;
  76169. /** @hidden */
  76170. _updatePosition(): void;
  76171. /**
  76172. * Destroy the camera and release the current resources hold by it.
  76173. */
  76174. dispose(): void;
  76175. /**
  76176. * Gets the current object class name.
  76177. * @return the class name
  76178. */
  76179. getClassName(): string;
  76180. }
  76181. }
  76182. declare module BABYLON {
  76183. /**
  76184. * Represents a gamepad control stick position
  76185. */
  76186. export class StickValues {
  76187. /**
  76188. * The x component of the control stick
  76189. */
  76190. x: number;
  76191. /**
  76192. * The y component of the control stick
  76193. */
  76194. y: number;
  76195. /**
  76196. * Initializes the gamepad x and y control stick values
  76197. * @param x The x component of the gamepad control stick value
  76198. * @param y The y component of the gamepad control stick value
  76199. */
  76200. constructor(
  76201. /**
  76202. * The x component of the control stick
  76203. */
  76204. x: number,
  76205. /**
  76206. * The y component of the control stick
  76207. */
  76208. y: number);
  76209. }
  76210. /**
  76211. * An interface which manages callbacks for gamepad button changes
  76212. */
  76213. export interface GamepadButtonChanges {
  76214. /**
  76215. * Called when a gamepad has been changed
  76216. */
  76217. changed: boolean;
  76218. /**
  76219. * Called when a gamepad press event has been triggered
  76220. */
  76221. pressChanged: boolean;
  76222. /**
  76223. * Called when a touch event has been triggered
  76224. */
  76225. touchChanged: boolean;
  76226. /**
  76227. * Called when a value has changed
  76228. */
  76229. valueChanged: boolean;
  76230. }
  76231. /**
  76232. * Represents a gamepad
  76233. */
  76234. export class Gamepad {
  76235. /**
  76236. * The id of the gamepad
  76237. */
  76238. id: string;
  76239. /**
  76240. * The index of the gamepad
  76241. */
  76242. index: number;
  76243. /**
  76244. * The browser gamepad
  76245. */
  76246. browserGamepad: any;
  76247. /**
  76248. * Specifies what type of gamepad this represents
  76249. */
  76250. type: number;
  76251. private _leftStick;
  76252. private _rightStick;
  76253. /** @hidden */
  76254. _isConnected: boolean;
  76255. private _leftStickAxisX;
  76256. private _leftStickAxisY;
  76257. private _rightStickAxisX;
  76258. private _rightStickAxisY;
  76259. /**
  76260. * Triggered when the left control stick has been changed
  76261. */
  76262. private _onleftstickchanged;
  76263. /**
  76264. * Triggered when the right control stick has been changed
  76265. */
  76266. private _onrightstickchanged;
  76267. /**
  76268. * Represents a gamepad controller
  76269. */
  76270. static GAMEPAD: number;
  76271. /**
  76272. * Represents a generic controller
  76273. */
  76274. static GENERIC: number;
  76275. /**
  76276. * Represents an XBox controller
  76277. */
  76278. static XBOX: number;
  76279. /**
  76280. * Represents a pose-enabled controller
  76281. */
  76282. static POSE_ENABLED: number;
  76283. /**
  76284. * Represents an Dual Shock controller
  76285. */
  76286. static DUALSHOCK: number;
  76287. /**
  76288. * Specifies whether the left control stick should be Y-inverted
  76289. */
  76290. protected _invertLeftStickY: boolean;
  76291. /**
  76292. * Specifies if the gamepad has been connected
  76293. */
  76294. readonly isConnected: boolean;
  76295. /**
  76296. * Initializes the gamepad
  76297. * @param id The id of the gamepad
  76298. * @param index The index of the gamepad
  76299. * @param browserGamepad The browser gamepad
  76300. * @param leftStickX The x component of the left joystick
  76301. * @param leftStickY The y component of the left joystick
  76302. * @param rightStickX The x component of the right joystick
  76303. * @param rightStickY The y component of the right joystick
  76304. */
  76305. constructor(
  76306. /**
  76307. * The id of the gamepad
  76308. */
  76309. id: string,
  76310. /**
  76311. * The index of the gamepad
  76312. */
  76313. index: number,
  76314. /**
  76315. * The browser gamepad
  76316. */
  76317. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76318. /**
  76319. * Callback triggered when the left joystick has changed
  76320. * @param callback
  76321. */
  76322. onleftstickchanged(callback: (values: StickValues) => void): void;
  76323. /**
  76324. * Callback triggered when the right joystick has changed
  76325. * @param callback
  76326. */
  76327. onrightstickchanged(callback: (values: StickValues) => void): void;
  76328. /**
  76329. * Gets the left joystick
  76330. */
  76331. /**
  76332. * Sets the left joystick values
  76333. */
  76334. leftStick: StickValues;
  76335. /**
  76336. * Gets the right joystick
  76337. */
  76338. /**
  76339. * Sets the right joystick value
  76340. */
  76341. rightStick: StickValues;
  76342. /**
  76343. * Updates the gamepad joystick positions
  76344. */
  76345. update(): void;
  76346. /**
  76347. * Disposes the gamepad
  76348. */
  76349. dispose(): void;
  76350. }
  76351. /**
  76352. * Represents a generic gamepad
  76353. */
  76354. export class GenericPad extends Gamepad {
  76355. private _buttons;
  76356. private _onbuttondown;
  76357. private _onbuttonup;
  76358. /**
  76359. * Observable triggered when a button has been pressed
  76360. */
  76361. onButtonDownObservable: Observable<number>;
  76362. /**
  76363. * Observable triggered when a button has been released
  76364. */
  76365. onButtonUpObservable: Observable<number>;
  76366. /**
  76367. * Callback triggered when a button has been pressed
  76368. * @param callback Called when a button has been pressed
  76369. */
  76370. onbuttondown(callback: (buttonPressed: number) => void): void;
  76371. /**
  76372. * Callback triggered when a button has been released
  76373. * @param callback Called when a button has been released
  76374. */
  76375. onbuttonup(callback: (buttonReleased: number) => void): void;
  76376. /**
  76377. * Initializes the generic gamepad
  76378. * @param id The id of the generic gamepad
  76379. * @param index The index of the generic gamepad
  76380. * @param browserGamepad The browser gamepad
  76381. */
  76382. constructor(id: string, index: number, browserGamepad: any);
  76383. private _setButtonValue;
  76384. /**
  76385. * Updates the generic gamepad
  76386. */
  76387. update(): void;
  76388. /**
  76389. * Disposes the generic gamepad
  76390. */
  76391. dispose(): void;
  76392. }
  76393. }
  76394. declare module BABYLON {
  76395. interface Engine {
  76396. /**
  76397. * Creates a raw texture
  76398. * @param data defines the data to store in the texture
  76399. * @param width defines the width of the texture
  76400. * @param height defines the height of the texture
  76401. * @param format defines the format of the data
  76402. * @param generateMipMaps defines if the engine should generate the mip levels
  76403. * @param invertY defines if data must be stored with Y axis inverted
  76404. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76405. * @param compression defines the compression used (null by default)
  76406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76407. * @returns the raw texture inside an InternalTexture
  76408. */
  76409. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76410. /**
  76411. * Update a raw texture
  76412. * @param texture defines the texture to update
  76413. * @param data defines the data to store in the texture
  76414. * @param format defines the format of the data
  76415. * @param invertY defines if data must be stored with Y axis inverted
  76416. */
  76417. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76418. /**
  76419. * Update a raw texture
  76420. * @param texture defines the texture to update
  76421. * @param data defines the data to store in the texture
  76422. * @param format defines the format of the data
  76423. * @param invertY defines if data must be stored with Y axis inverted
  76424. * @param compression defines the compression used (null by default)
  76425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76426. */
  76427. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76428. /**
  76429. * Creates a new raw cube texture
  76430. * @param data defines the array of data to use to create each face
  76431. * @param size defines the size of the textures
  76432. * @param format defines the format of the data
  76433. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76434. * @param generateMipMaps defines if the engine should generate the mip levels
  76435. * @param invertY defines if data must be stored with Y axis inverted
  76436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76437. * @param compression defines the compression used (null by default)
  76438. * @returns the cube texture as an InternalTexture
  76439. */
  76440. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76441. /**
  76442. * Update a raw cube texture
  76443. * @param texture defines the texture to udpdate
  76444. * @param data defines the data to store
  76445. * @param format defines the data format
  76446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76447. * @param invertY defines if data must be stored with Y axis inverted
  76448. */
  76449. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76450. /**
  76451. * Update a raw cube texture
  76452. * @param texture defines the texture to udpdate
  76453. * @param data defines the data to store
  76454. * @param format defines the data format
  76455. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76456. * @param invertY defines if data must be stored with Y axis inverted
  76457. * @param compression defines the compression used (null by default)
  76458. */
  76459. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76460. /**
  76461. * Update a raw cube texture
  76462. * @param texture defines the texture to udpdate
  76463. * @param data defines the data to store
  76464. * @param format defines the data format
  76465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76466. * @param invertY defines if data must be stored with Y axis inverted
  76467. * @param compression defines the compression used (null by default)
  76468. * @param level defines which level of the texture to update
  76469. */
  76470. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76471. /**
  76472. * Creates a new raw cube texture from a specified url
  76473. * @param url defines the url where the data is located
  76474. * @param scene defines the current scene
  76475. * @param size defines the size of the textures
  76476. * @param format defines the format of the data
  76477. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76478. * @param noMipmap defines if the engine should avoid generating the mip levels
  76479. * @param callback defines a callback used to extract texture data from loaded data
  76480. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76481. * @param onLoad defines a callback called when texture is loaded
  76482. * @param onError defines a callback called if there is an error
  76483. * @returns the cube texture as an InternalTexture
  76484. */
  76485. 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>): InternalTexture;
  76486. /**
  76487. * Creates a new raw cube texture from a specified url
  76488. * @param url defines the url where the data is located
  76489. * @param scene defines the current scene
  76490. * @param size defines the size of the textures
  76491. * @param format defines the format of the data
  76492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76493. * @param noMipmap defines if the engine should avoid generating the mip levels
  76494. * @param callback defines a callback used to extract texture data from loaded data
  76495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76496. * @param onLoad defines a callback called when texture is loaded
  76497. * @param onError defines a callback called if there is an error
  76498. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76499. * @param invertY defines if data must be stored with Y axis inverted
  76500. * @returns the cube texture as an InternalTexture
  76501. */
  76502. 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;
  76503. /**
  76504. * Creates a new raw 3D texture
  76505. * @param data defines the data used to create the texture
  76506. * @param width defines the width of the texture
  76507. * @param height defines the height of the texture
  76508. * @param depth defines the depth of the texture
  76509. * @param format defines the format of the texture
  76510. * @param generateMipMaps defines if the engine must generate mip levels
  76511. * @param invertY defines if data must be stored with Y axis inverted
  76512. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76513. * @param compression defines the compressed used (can be null)
  76514. * @param textureType defines the compressed used (can be null)
  76515. * @returns a new raw 3D texture (stored in an InternalTexture)
  76516. */
  76517. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76518. /**
  76519. * Update a raw 3D texture
  76520. * @param texture defines the texture to update
  76521. * @param data defines the data to store
  76522. * @param format defines the data format
  76523. * @param invertY defines if data must be stored with Y axis inverted
  76524. */
  76525. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76526. /**
  76527. * Update a raw 3D texture
  76528. * @param texture defines the texture to update
  76529. * @param data defines the data to store
  76530. * @param format defines the data format
  76531. * @param invertY defines if data must be stored with Y axis inverted
  76532. * @param compression defines the used compression (can be null)
  76533. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76534. */
  76535. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76536. }
  76537. }
  76538. declare module BABYLON {
  76539. /**
  76540. * Raw texture can help creating a texture directly from an array of data.
  76541. * This can be super useful if you either get the data from an uncompressed source or
  76542. * if you wish to create your texture pixel by pixel.
  76543. */
  76544. export class RawTexture extends Texture {
  76545. /**
  76546. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76547. */
  76548. format: number;
  76549. private _engine;
  76550. /**
  76551. * Instantiates a new RawTexture.
  76552. * Raw texture can help creating a texture directly from an array of data.
  76553. * This can be super useful if you either get the data from an uncompressed source or
  76554. * if you wish to create your texture pixel by pixel.
  76555. * @param data define the array of data to use to create the texture
  76556. * @param width define the width of the texture
  76557. * @param height define the height of the texture
  76558. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76559. * @param scene define the scene the texture belongs to
  76560. * @param generateMipMaps define whether mip maps should be generated or not
  76561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76563. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76564. */
  76565. constructor(data: ArrayBufferView, width: number, height: number,
  76566. /**
  76567. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76568. */
  76569. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76570. /**
  76571. * Updates the texture underlying data.
  76572. * @param data Define the new data of the texture
  76573. */
  76574. update(data: ArrayBufferView): void;
  76575. /**
  76576. * Creates a luminance texture from some data.
  76577. * @param data Define the texture data
  76578. * @param width Define the width of the texture
  76579. * @param height Define the height of the texture
  76580. * @param scene Define the scene the texture belongs to
  76581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76584. * @returns the luminance texture
  76585. */
  76586. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76587. /**
  76588. * Creates a luminance alpha texture from some data.
  76589. * @param data Define the texture data
  76590. * @param width Define the width of the texture
  76591. * @param height Define the height of the texture
  76592. * @param scene Define the scene the texture belongs to
  76593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76596. * @returns the luminance alpha texture
  76597. */
  76598. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76599. /**
  76600. * Creates an alpha texture from some data.
  76601. * @param data Define the texture data
  76602. * @param width Define the width of the texture
  76603. * @param height Define the height of the texture
  76604. * @param scene Define the scene the texture belongs to
  76605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76608. * @returns the alpha texture
  76609. */
  76610. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76611. /**
  76612. * Creates a RGB texture from some data.
  76613. * @param data Define the texture data
  76614. * @param width Define the width of the texture
  76615. * @param height Define the height of the texture
  76616. * @param scene Define the scene the texture belongs to
  76617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76620. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76621. * @returns the RGB alpha texture
  76622. */
  76623. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76624. /**
  76625. * Creates a RGBA texture from some data.
  76626. * @param data Define the texture data
  76627. * @param width Define the width of the texture
  76628. * @param height Define the height of the texture
  76629. * @param scene Define the scene the texture belongs to
  76630. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76631. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76632. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76633. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76634. * @returns the RGBA texture
  76635. */
  76636. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76637. /**
  76638. * Creates a R texture from some data.
  76639. * @param data Define the texture data
  76640. * @param width Define the width of the texture
  76641. * @param height Define the height of the texture
  76642. * @param scene Define the scene the texture belongs to
  76643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76647. * @returns the R texture
  76648. */
  76649. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76650. }
  76651. }
  76652. declare module BABYLON {
  76653. /**
  76654. * Interface for the size containing width and height
  76655. */
  76656. export interface ISize {
  76657. /**
  76658. * Width
  76659. */
  76660. width: number;
  76661. /**
  76662. * Heighht
  76663. */
  76664. height: number;
  76665. }
  76666. /**
  76667. * Size containing widht and height
  76668. */
  76669. export class Size implements ISize {
  76670. /**
  76671. * Width
  76672. */
  76673. width: number;
  76674. /**
  76675. * Height
  76676. */
  76677. height: number;
  76678. /**
  76679. * Creates a Size object from the given width and height (floats).
  76680. * @param width width of the new size
  76681. * @param height height of the new size
  76682. */
  76683. constructor(width: number, height: number);
  76684. /**
  76685. * Returns a string with the Size width and height
  76686. * @returns a string with the Size width and height
  76687. */
  76688. toString(): string;
  76689. /**
  76690. * "Size"
  76691. * @returns the string "Size"
  76692. */
  76693. getClassName(): string;
  76694. /**
  76695. * Returns the Size hash code.
  76696. * @returns a hash code for a unique width and height
  76697. */
  76698. getHashCode(): number;
  76699. /**
  76700. * Updates the current size from the given one.
  76701. * @param src the given size
  76702. */
  76703. copyFrom(src: Size): void;
  76704. /**
  76705. * Updates in place the current Size from the given floats.
  76706. * @param width width of the new size
  76707. * @param height height of the new size
  76708. * @returns the updated Size.
  76709. */
  76710. copyFromFloats(width: number, height: number): Size;
  76711. /**
  76712. * Updates in place the current Size from the given floats.
  76713. * @param width width to set
  76714. * @param height height to set
  76715. * @returns the updated Size.
  76716. */
  76717. set(width: number, height: number): Size;
  76718. /**
  76719. * Multiplies the width and height by numbers
  76720. * @param w factor to multiple the width by
  76721. * @param h factor to multiple the height by
  76722. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76723. */
  76724. multiplyByFloats(w: number, h: number): Size;
  76725. /**
  76726. * Clones the size
  76727. * @returns a new Size copied from the given one.
  76728. */
  76729. clone(): Size;
  76730. /**
  76731. * True if the current Size and the given one width and height are strictly equal.
  76732. * @param other the other size to compare against
  76733. * @returns True if the current Size and the given one width and height are strictly equal.
  76734. */
  76735. equals(other: Size): boolean;
  76736. /**
  76737. * The surface of the Size : width * height (float).
  76738. */
  76739. readonly surface: number;
  76740. /**
  76741. * Create a new size of zero
  76742. * @returns a new Size set to (0.0, 0.0)
  76743. */
  76744. static Zero(): Size;
  76745. /**
  76746. * Sums the width and height of two sizes
  76747. * @param otherSize size to add to this size
  76748. * @returns a new Size set as the addition result of the current Size and the given one.
  76749. */
  76750. add(otherSize: Size): Size;
  76751. /**
  76752. * Subtracts the width and height of two
  76753. * @param otherSize size to subtract to this size
  76754. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76755. */
  76756. subtract(otherSize: Size): Size;
  76757. /**
  76758. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76759. * @param start starting size to lerp between
  76760. * @param end end size to lerp between
  76761. * @param amount amount to lerp between the start and end values
  76762. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76763. */
  76764. static Lerp(start: Size, end: Size, amount: number): Size;
  76765. }
  76766. }
  76767. declare module BABYLON {
  76768. /**
  76769. * Defines a runtime animation
  76770. */
  76771. export class RuntimeAnimation {
  76772. private _events;
  76773. /**
  76774. * The current frame of the runtime animation
  76775. */
  76776. private _currentFrame;
  76777. /**
  76778. * The animation used by the runtime animation
  76779. */
  76780. private _animation;
  76781. /**
  76782. * The target of the runtime animation
  76783. */
  76784. private _target;
  76785. /**
  76786. * The initiating animatable
  76787. */
  76788. private _host;
  76789. /**
  76790. * The original value of the runtime animation
  76791. */
  76792. private _originalValue;
  76793. /**
  76794. * The original blend value of the runtime animation
  76795. */
  76796. private _originalBlendValue;
  76797. /**
  76798. * The offsets cache of the runtime animation
  76799. */
  76800. private _offsetsCache;
  76801. /**
  76802. * The high limits cache of the runtime animation
  76803. */
  76804. private _highLimitsCache;
  76805. /**
  76806. * Specifies if the runtime animation has been stopped
  76807. */
  76808. private _stopped;
  76809. /**
  76810. * The blending factor of the runtime animation
  76811. */
  76812. private _blendingFactor;
  76813. /**
  76814. * The BabylonJS scene
  76815. */
  76816. private _scene;
  76817. /**
  76818. * The current value of the runtime animation
  76819. */
  76820. private _currentValue;
  76821. /** @hidden */
  76822. _animationState: _IAnimationState;
  76823. /**
  76824. * The active target of the runtime animation
  76825. */
  76826. private _activeTargets;
  76827. private _currentActiveTarget;
  76828. private _directTarget;
  76829. /**
  76830. * The target path of the runtime animation
  76831. */
  76832. private _targetPath;
  76833. /**
  76834. * The weight of the runtime animation
  76835. */
  76836. private _weight;
  76837. /**
  76838. * The ratio offset of the runtime animation
  76839. */
  76840. private _ratioOffset;
  76841. /**
  76842. * The previous delay of the runtime animation
  76843. */
  76844. private _previousDelay;
  76845. /**
  76846. * The previous ratio of the runtime animation
  76847. */
  76848. private _previousRatio;
  76849. private _enableBlending;
  76850. private _keys;
  76851. private _minFrame;
  76852. private _maxFrame;
  76853. private _minValue;
  76854. private _maxValue;
  76855. private _targetIsArray;
  76856. /**
  76857. * Gets the current frame of the runtime animation
  76858. */
  76859. readonly currentFrame: number;
  76860. /**
  76861. * Gets the weight of the runtime animation
  76862. */
  76863. readonly weight: number;
  76864. /**
  76865. * Gets the current value of the runtime animation
  76866. */
  76867. readonly currentValue: any;
  76868. /**
  76869. * Gets the target path of the runtime animation
  76870. */
  76871. readonly targetPath: string;
  76872. /**
  76873. * Gets the actual target of the runtime animation
  76874. */
  76875. readonly target: any;
  76876. /** @hidden */
  76877. _onLoop: () => void;
  76878. /**
  76879. * Create a new RuntimeAnimation object
  76880. * @param target defines the target of the animation
  76881. * @param animation defines the source animation object
  76882. * @param scene defines the hosting scene
  76883. * @param host defines the initiating Animatable
  76884. */
  76885. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76886. private _preparePath;
  76887. /**
  76888. * Gets the animation from the runtime animation
  76889. */
  76890. readonly animation: Animation;
  76891. /**
  76892. * Resets the runtime animation to the beginning
  76893. * @param restoreOriginal defines whether to restore the target property to the original value
  76894. */
  76895. reset(restoreOriginal?: boolean): void;
  76896. /**
  76897. * Specifies if the runtime animation is stopped
  76898. * @returns Boolean specifying if the runtime animation is stopped
  76899. */
  76900. isStopped(): boolean;
  76901. /**
  76902. * Disposes of the runtime animation
  76903. */
  76904. dispose(): void;
  76905. /**
  76906. * Apply the interpolated value to the target
  76907. * @param currentValue defines the value computed by the animation
  76908. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76909. */
  76910. setValue(currentValue: any, weight: number): void;
  76911. private _getOriginalValues;
  76912. private _setValue;
  76913. /**
  76914. * Gets the loop pmode of the runtime animation
  76915. * @returns Loop Mode
  76916. */
  76917. private _getCorrectLoopMode;
  76918. /**
  76919. * Move the current animation to a given frame
  76920. * @param frame defines the frame to move to
  76921. */
  76922. goToFrame(frame: number): void;
  76923. /**
  76924. * @hidden Internal use only
  76925. */
  76926. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76927. /**
  76928. * Execute the current animation
  76929. * @param delay defines the delay to add to the current frame
  76930. * @param from defines the lower bound of the animation range
  76931. * @param to defines the upper bound of the animation range
  76932. * @param loop defines if the current animation must loop
  76933. * @param speedRatio defines the current speed ratio
  76934. * @param weight defines the weight of the animation (default is -1 so no weight)
  76935. * @param onLoop optional callback called when animation loops
  76936. * @returns a boolean indicating if the animation is running
  76937. */
  76938. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76939. }
  76940. }
  76941. declare module BABYLON {
  76942. /**
  76943. * Class used to store an actual running animation
  76944. */
  76945. export class Animatable {
  76946. /** defines the target object */
  76947. target: any;
  76948. /** defines the starting frame number (default is 0) */
  76949. fromFrame: number;
  76950. /** defines the ending frame number (default is 100) */
  76951. toFrame: number;
  76952. /** defines if the animation must loop (default is false) */
  76953. loopAnimation: boolean;
  76954. /** defines a callback to call when animation ends if it is not looping */
  76955. onAnimationEnd?: (() => void) | null | undefined;
  76956. /** defines a callback to call when animation loops */
  76957. onAnimationLoop?: (() => void) | null | undefined;
  76958. private _localDelayOffset;
  76959. private _pausedDelay;
  76960. private _runtimeAnimations;
  76961. private _paused;
  76962. private _scene;
  76963. private _speedRatio;
  76964. private _weight;
  76965. private _syncRoot;
  76966. /**
  76967. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76968. * This will only apply for non looping animation (default is true)
  76969. */
  76970. disposeOnEnd: boolean;
  76971. /**
  76972. * Gets a boolean indicating if the animation has started
  76973. */
  76974. animationStarted: boolean;
  76975. /**
  76976. * Observer raised when the animation ends
  76977. */
  76978. onAnimationEndObservable: Observable<Animatable>;
  76979. /**
  76980. * Observer raised when the animation loops
  76981. */
  76982. onAnimationLoopObservable: Observable<Animatable>;
  76983. /**
  76984. * Gets the root Animatable used to synchronize and normalize animations
  76985. */
  76986. readonly syncRoot: Nullable<Animatable>;
  76987. /**
  76988. * Gets the current frame of the first RuntimeAnimation
  76989. * Used to synchronize Animatables
  76990. */
  76991. readonly masterFrame: number;
  76992. /**
  76993. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76994. */
  76995. weight: number;
  76996. /**
  76997. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76998. */
  76999. speedRatio: number;
  77000. /**
  77001. * Creates a new Animatable
  77002. * @param scene defines the hosting scene
  77003. * @param target defines the target object
  77004. * @param fromFrame defines the starting frame number (default is 0)
  77005. * @param toFrame defines the ending frame number (default is 100)
  77006. * @param loopAnimation defines if the animation must loop (default is false)
  77007. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77008. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77009. * @param animations defines a group of animation to add to the new Animatable
  77010. * @param onAnimationLoop defines a callback to call when animation loops
  77011. */
  77012. constructor(scene: Scene,
  77013. /** defines the target object */
  77014. target: any,
  77015. /** defines the starting frame number (default is 0) */
  77016. fromFrame?: number,
  77017. /** defines the ending frame number (default is 100) */
  77018. toFrame?: number,
  77019. /** defines if the animation must loop (default is false) */
  77020. loopAnimation?: boolean, speedRatio?: number,
  77021. /** defines a callback to call when animation ends if it is not looping */
  77022. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77023. /** defines a callback to call when animation loops */
  77024. onAnimationLoop?: (() => void) | null | undefined);
  77025. /**
  77026. * Synchronize and normalize current Animatable with a source Animatable
  77027. * This is useful when using animation weights and when animations are not of the same length
  77028. * @param root defines the root Animatable to synchronize with
  77029. * @returns the current Animatable
  77030. */
  77031. syncWith(root: Animatable): Animatable;
  77032. /**
  77033. * Gets the list of runtime animations
  77034. * @returns an array of RuntimeAnimation
  77035. */
  77036. getAnimations(): RuntimeAnimation[];
  77037. /**
  77038. * Adds more animations to the current animatable
  77039. * @param target defines the target of the animations
  77040. * @param animations defines the new animations to add
  77041. */
  77042. appendAnimations(target: any, animations: Animation[]): void;
  77043. /**
  77044. * Gets the source animation for a specific property
  77045. * @param property defines the propertyu to look for
  77046. * @returns null or the source animation for the given property
  77047. */
  77048. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77049. /**
  77050. * Gets the runtime animation for a specific property
  77051. * @param property defines the propertyu to look for
  77052. * @returns null or the runtime animation for the given property
  77053. */
  77054. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77055. /**
  77056. * Resets the animatable to its original state
  77057. */
  77058. reset(): void;
  77059. /**
  77060. * Allows the animatable to blend with current running animations
  77061. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77062. * @param blendingSpeed defines the blending speed to use
  77063. */
  77064. enableBlending(blendingSpeed: number): void;
  77065. /**
  77066. * Disable animation blending
  77067. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77068. */
  77069. disableBlending(): void;
  77070. /**
  77071. * Jump directly to a given frame
  77072. * @param frame defines the frame to jump to
  77073. */
  77074. goToFrame(frame: number): void;
  77075. /**
  77076. * Pause the animation
  77077. */
  77078. pause(): void;
  77079. /**
  77080. * Restart the animation
  77081. */
  77082. restart(): void;
  77083. private _raiseOnAnimationEnd;
  77084. /**
  77085. * Stop and delete the current animation
  77086. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  77087. * @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)
  77088. */
  77089. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  77090. /**
  77091. * Wait asynchronously for the animation to end
  77092. * @returns a promise which will be fullfilled when the animation ends
  77093. */
  77094. waitAsync(): Promise<Animatable>;
  77095. /** @hidden */
  77096. _animate(delay: number): boolean;
  77097. }
  77098. interface Scene {
  77099. /** @hidden */
  77100. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  77101. /** @hidden */
  77102. _processLateAnimationBindingsForMatrices(holder: {
  77103. totalWeight: number;
  77104. animations: RuntimeAnimation[];
  77105. originalValue: Matrix;
  77106. }): any;
  77107. /** @hidden */
  77108. _processLateAnimationBindingsForQuaternions(holder: {
  77109. totalWeight: number;
  77110. animations: RuntimeAnimation[];
  77111. originalValue: Quaternion;
  77112. }, refQuaternion: Quaternion): Quaternion;
  77113. /** @hidden */
  77114. _processLateAnimationBindings(): void;
  77115. /**
  77116. * Will start the animation sequence of a given target
  77117. * @param target defines the target
  77118. * @param from defines from which frame should animation start
  77119. * @param to defines until which frame should animation run.
  77120. * @param weight defines the weight to apply to the animation (1.0 by default)
  77121. * @param loop defines if the animation loops
  77122. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77123. * @param onAnimationEnd defines the function to be executed when the animation ends
  77124. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77125. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77126. * @param onAnimationLoop defines the callback to call when an animation loops
  77127. * @returns the animatable object created for this animation
  77128. */
  77129. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77130. /**
  77131. * Will start the animation sequence of a given target
  77132. * @param target defines the target
  77133. * @param from defines from which frame should animation start
  77134. * @param to defines until which frame should animation run.
  77135. * @param loop defines if the animation loops
  77136. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77137. * @param onAnimationEnd defines the function to be executed when the animation ends
  77138. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77139. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77140. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  77141. * @param onAnimationLoop defines the callback to call when an animation loops
  77142. * @returns the animatable object created for this animation
  77143. */
  77144. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  77145. /**
  77146. * Will start the animation sequence of a given target and its hierarchy
  77147. * @param target defines the target
  77148. * @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.
  77149. * @param from defines from which frame should animation start
  77150. * @param to defines until which frame should animation run.
  77151. * @param loop defines if the animation loops
  77152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  77153. * @param onAnimationEnd defines the function to be executed when the animation ends
  77154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  77155. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77156. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77157. * @param onAnimationLoop defines the callback to call when an animation loops
  77158. * @returns the list of created animatables
  77159. */
  77160. 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[];
  77161. /**
  77162. * Begin a new animation on a given node
  77163. * @param target defines the target where the animation will take place
  77164. * @param animations defines the list of animations to start
  77165. * @param from defines the initial value
  77166. * @param to defines the final value
  77167. * @param loop defines if you want animation to loop (off by default)
  77168. * @param speedRatio defines the speed ratio to apply to all animations
  77169. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77170. * @param onAnimationLoop defines the callback to call when an animation loops
  77171. * @returns the list of created animatables
  77172. */
  77173. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77174. /**
  77175. * Begin a new animation on a given node and its hierarchy
  77176. * @param target defines the root node where the animation will take place
  77177. * @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.
  77178. * @param animations defines the list of animations to start
  77179. * @param from defines the initial value
  77180. * @param to defines the final value
  77181. * @param loop defines if you want animation to loop (off by default)
  77182. * @param speedRatio defines the speed ratio to apply to all animations
  77183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77184. * @param onAnimationLoop defines the callback to call when an animation loops
  77185. * @returns the list of animatables created for all nodes
  77186. */
  77187. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77188. /**
  77189. * Gets the animatable associated with a specific target
  77190. * @param target defines the target of the animatable
  77191. * @returns the required animatable if found
  77192. */
  77193. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77194. /**
  77195. * Gets all animatables associated with a given target
  77196. * @param target defines the target to look animatables for
  77197. * @returns an array of Animatables
  77198. */
  77199. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77200. /**
  77201. * Stops and removes all animations that have been applied to the scene
  77202. */
  77203. stopAllAnimations(): void;
  77204. }
  77205. interface Bone {
  77206. /**
  77207. * Copy an animation range from another bone
  77208. * @param source defines the source bone
  77209. * @param rangeName defines the range name to copy
  77210. * @param frameOffset defines the frame offset
  77211. * @param rescaleAsRequired defines if rescaling must be applied if required
  77212. * @param skelDimensionsRatio defines the scaling ratio
  77213. * @returns true if operation was successful
  77214. */
  77215. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77216. }
  77217. }
  77218. declare module BABYLON {
  77219. /**
  77220. * Class used to override all child animations of a given target
  77221. */
  77222. export class AnimationPropertiesOverride {
  77223. /**
  77224. * Gets or sets a value indicating if animation blending must be used
  77225. */
  77226. enableBlending: boolean;
  77227. /**
  77228. * Gets or sets the blending speed to use when enableBlending is true
  77229. */
  77230. blendingSpeed: number;
  77231. /**
  77232. * Gets or sets the default loop mode to use
  77233. */
  77234. loopMode: number;
  77235. }
  77236. }
  77237. declare module BABYLON {
  77238. /**
  77239. * Class used to handle skinning animations
  77240. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77241. */
  77242. export class Skeleton implements IAnimatable {
  77243. /** defines the skeleton name */
  77244. name: string;
  77245. /** defines the skeleton Id */
  77246. id: string;
  77247. /**
  77248. * Defines the list of child bones
  77249. */
  77250. bones: Bone[];
  77251. /**
  77252. * Defines an estimate of the dimension of the skeleton at rest
  77253. */
  77254. dimensionsAtRest: Vector3;
  77255. /**
  77256. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77257. */
  77258. needInitialSkinMatrix: boolean;
  77259. /**
  77260. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77261. */
  77262. overrideMesh: Nullable<AbstractMesh>;
  77263. /**
  77264. * Gets the list of animations attached to this skeleton
  77265. */
  77266. animations: Array<Animation>;
  77267. private _scene;
  77268. private _isDirty;
  77269. private _transformMatrices;
  77270. private _transformMatrixTexture;
  77271. private _meshesWithPoseMatrix;
  77272. private _animatables;
  77273. private _identity;
  77274. private _synchronizedWithMesh;
  77275. private _ranges;
  77276. private _lastAbsoluteTransformsUpdateId;
  77277. private _canUseTextureForBones;
  77278. private _uniqueId;
  77279. /** @hidden */
  77280. _numBonesWithLinkedTransformNode: number;
  77281. /** @hidden */
  77282. _hasWaitingData: Nullable<boolean>;
  77283. /**
  77284. * Specifies if the skeleton should be serialized
  77285. */
  77286. doNotSerialize: boolean;
  77287. private _useTextureToStoreBoneMatrices;
  77288. /**
  77289. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77290. * Please note that this option is not available if the hardware does not support it
  77291. */
  77292. useTextureToStoreBoneMatrices: boolean;
  77293. private _animationPropertiesOverride;
  77294. /**
  77295. * Gets or sets the animation properties override
  77296. */
  77297. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77298. /**
  77299. * List of inspectable custom properties (used by the Inspector)
  77300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77301. */
  77302. inspectableCustomProperties: IInspectable[];
  77303. /**
  77304. * An observable triggered before computing the skeleton's matrices
  77305. */
  77306. onBeforeComputeObservable: Observable<Skeleton>;
  77307. /**
  77308. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77309. */
  77310. readonly isUsingTextureForMatrices: boolean;
  77311. /**
  77312. * Gets the unique ID of this skeleton
  77313. */
  77314. readonly uniqueId: number;
  77315. /**
  77316. * Creates a new skeleton
  77317. * @param name defines the skeleton name
  77318. * @param id defines the skeleton Id
  77319. * @param scene defines the hosting scene
  77320. */
  77321. constructor(
  77322. /** defines the skeleton name */
  77323. name: string,
  77324. /** defines the skeleton Id */
  77325. id: string, scene: Scene);
  77326. /**
  77327. * Gets the current object class name.
  77328. * @return the class name
  77329. */
  77330. getClassName(): string;
  77331. /**
  77332. * Returns an array containing the root bones
  77333. * @returns an array containing the root bones
  77334. */
  77335. getChildren(): Array<Bone>;
  77336. /**
  77337. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77338. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77339. * @returns a Float32Array containing matrices data
  77340. */
  77341. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77342. /**
  77343. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77344. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77345. * @returns a raw texture containing the data
  77346. */
  77347. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77348. /**
  77349. * Gets the current hosting scene
  77350. * @returns a scene object
  77351. */
  77352. getScene(): Scene;
  77353. /**
  77354. * Gets a string representing the current skeleton data
  77355. * @param fullDetails defines a boolean indicating if we want a verbose version
  77356. * @returns a string representing the current skeleton data
  77357. */
  77358. toString(fullDetails?: boolean): string;
  77359. /**
  77360. * Get bone's index searching by name
  77361. * @param name defines bone's name to search for
  77362. * @return the indice of the bone. Returns -1 if not found
  77363. */
  77364. getBoneIndexByName(name: string): number;
  77365. /**
  77366. * Creater a new animation range
  77367. * @param name defines the name of the range
  77368. * @param from defines the start key
  77369. * @param to defines the end key
  77370. */
  77371. createAnimationRange(name: string, from: number, to: number): void;
  77372. /**
  77373. * Delete a specific animation range
  77374. * @param name defines the name of the range
  77375. * @param deleteFrames defines if frames must be removed as well
  77376. */
  77377. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77378. /**
  77379. * Gets a specific animation range
  77380. * @param name defines the name of the range to look for
  77381. * @returns the requested animation range or null if not found
  77382. */
  77383. getAnimationRange(name: string): Nullable<AnimationRange>;
  77384. /**
  77385. * Gets the list of all animation ranges defined on this skeleton
  77386. * @returns an array
  77387. */
  77388. getAnimationRanges(): Nullable<AnimationRange>[];
  77389. /**
  77390. * Copy animation range from a source skeleton.
  77391. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77392. * @param source defines the source skeleton
  77393. * @param name defines the name of the range to copy
  77394. * @param rescaleAsRequired defines if rescaling must be applied if required
  77395. * @returns true if operation was successful
  77396. */
  77397. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77398. /**
  77399. * Forces the skeleton to go to rest pose
  77400. */
  77401. returnToRest(): void;
  77402. private _getHighestAnimationFrame;
  77403. /**
  77404. * Begin a specific animation range
  77405. * @param name defines the name of the range to start
  77406. * @param loop defines if looping must be turned on (false by default)
  77407. * @param speedRatio defines the speed ratio to apply (1 by default)
  77408. * @param onAnimationEnd defines a callback which will be called when animation will end
  77409. * @returns a new animatable
  77410. */
  77411. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77412. /** @hidden */
  77413. _markAsDirty(): void;
  77414. /** @hidden */
  77415. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77416. /** @hidden */
  77417. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77418. private _computeTransformMatrices;
  77419. /**
  77420. * Build all resources required to render a skeleton
  77421. */
  77422. prepare(): void;
  77423. /**
  77424. * Gets the list of animatables currently running for this skeleton
  77425. * @returns an array of animatables
  77426. */
  77427. getAnimatables(): IAnimatable[];
  77428. /**
  77429. * Clone the current skeleton
  77430. * @param name defines the name of the new skeleton
  77431. * @param id defines the id of the new skeleton
  77432. * @returns the new skeleton
  77433. */
  77434. clone(name: string, id: string): Skeleton;
  77435. /**
  77436. * Enable animation blending for this skeleton
  77437. * @param blendingSpeed defines the blending speed to apply
  77438. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77439. */
  77440. enableBlending(blendingSpeed?: number): void;
  77441. /**
  77442. * Releases all resources associated with the current skeleton
  77443. */
  77444. dispose(): void;
  77445. /**
  77446. * Serialize the skeleton in a JSON object
  77447. * @returns a JSON object
  77448. */
  77449. serialize(): any;
  77450. /**
  77451. * Creates a new skeleton from serialized data
  77452. * @param parsedSkeleton defines the serialized data
  77453. * @param scene defines the hosting scene
  77454. * @returns a new skeleton
  77455. */
  77456. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77457. /**
  77458. * Compute all node absolute transforms
  77459. * @param forceUpdate defines if computation must be done even if cache is up to date
  77460. */
  77461. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77462. /**
  77463. * Gets the root pose matrix
  77464. * @returns a matrix
  77465. */
  77466. getPoseMatrix(): Nullable<Matrix>;
  77467. /**
  77468. * Sorts bones per internal index
  77469. */
  77470. sortBones(): void;
  77471. private _sortBones;
  77472. }
  77473. }
  77474. declare module BABYLON {
  77475. /**
  77476. * Class used to store bone information
  77477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77478. */
  77479. export class Bone extends Node {
  77480. /**
  77481. * defines the bone name
  77482. */
  77483. name: string;
  77484. private static _tmpVecs;
  77485. private static _tmpQuat;
  77486. private static _tmpMats;
  77487. /**
  77488. * Gets the list of child bones
  77489. */
  77490. children: Bone[];
  77491. /** Gets the animations associated with this bone */
  77492. animations: Animation[];
  77493. /**
  77494. * Gets or sets bone length
  77495. */
  77496. length: number;
  77497. /**
  77498. * @hidden Internal only
  77499. * Set this value to map this bone to a different index in the transform matrices
  77500. * Set this value to -1 to exclude the bone from the transform matrices
  77501. */
  77502. _index: Nullable<number>;
  77503. private _skeleton;
  77504. private _localMatrix;
  77505. private _restPose;
  77506. private _baseMatrix;
  77507. private _absoluteTransform;
  77508. private _invertedAbsoluteTransform;
  77509. private _parent;
  77510. private _scalingDeterminant;
  77511. private _worldTransform;
  77512. private _localScaling;
  77513. private _localRotation;
  77514. private _localPosition;
  77515. private _needToDecompose;
  77516. private _needToCompose;
  77517. /** @hidden */
  77518. _linkedTransformNode: Nullable<TransformNode>;
  77519. /** @hidden */
  77520. _waitingTransformNodeId: Nullable<string>;
  77521. /** @hidden */
  77522. /** @hidden */
  77523. _matrix: Matrix;
  77524. /**
  77525. * Create a new bone
  77526. * @param name defines the bone name
  77527. * @param skeleton defines the parent skeleton
  77528. * @param parentBone defines the parent (can be null if the bone is the root)
  77529. * @param localMatrix defines the local matrix
  77530. * @param restPose defines the rest pose matrix
  77531. * @param baseMatrix defines the base matrix
  77532. * @param index defines index of the bone in the hiearchy
  77533. */
  77534. constructor(
  77535. /**
  77536. * defines the bone name
  77537. */
  77538. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77539. /**
  77540. * Gets the current object class name.
  77541. * @return the class name
  77542. */
  77543. getClassName(): string;
  77544. /**
  77545. * Gets the parent skeleton
  77546. * @returns a skeleton
  77547. */
  77548. getSkeleton(): Skeleton;
  77549. /**
  77550. * Gets parent bone
  77551. * @returns a bone or null if the bone is the root of the bone hierarchy
  77552. */
  77553. getParent(): Nullable<Bone>;
  77554. /**
  77555. * Returns an array containing the root bones
  77556. * @returns an array containing the root bones
  77557. */
  77558. getChildren(): Array<Bone>;
  77559. /**
  77560. * Sets the parent bone
  77561. * @param parent defines the parent (can be null if the bone is the root)
  77562. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77563. */
  77564. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77565. /**
  77566. * Gets the local matrix
  77567. * @returns a matrix
  77568. */
  77569. getLocalMatrix(): Matrix;
  77570. /**
  77571. * Gets the base matrix (initial matrix which remains unchanged)
  77572. * @returns a matrix
  77573. */
  77574. getBaseMatrix(): Matrix;
  77575. /**
  77576. * Gets the rest pose matrix
  77577. * @returns a matrix
  77578. */
  77579. getRestPose(): Matrix;
  77580. /**
  77581. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77582. */
  77583. getWorldMatrix(): Matrix;
  77584. /**
  77585. * Sets the local matrix to rest pose matrix
  77586. */
  77587. returnToRest(): void;
  77588. /**
  77589. * Gets the inverse of the absolute transform matrix.
  77590. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77591. * @returns a matrix
  77592. */
  77593. getInvertedAbsoluteTransform(): Matrix;
  77594. /**
  77595. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77596. * @returns a matrix
  77597. */
  77598. getAbsoluteTransform(): Matrix;
  77599. /**
  77600. * Links with the given transform node.
  77601. * The local matrix of this bone is copied from the transform node every frame.
  77602. * @param transformNode defines the transform node to link to
  77603. */
  77604. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77605. /**
  77606. * Gets the node used to drive the bone's transformation
  77607. * @returns a transform node or null
  77608. */
  77609. getTransformNode(): Nullable<TransformNode>;
  77610. /** Gets or sets current position (in local space) */
  77611. position: Vector3;
  77612. /** Gets or sets current rotation (in local space) */
  77613. rotation: Vector3;
  77614. /** Gets or sets current rotation quaternion (in local space) */
  77615. rotationQuaternion: Quaternion;
  77616. /** Gets or sets current scaling (in local space) */
  77617. scaling: Vector3;
  77618. /**
  77619. * Gets the animation properties override
  77620. */
  77621. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77622. private _decompose;
  77623. private _compose;
  77624. /**
  77625. * Update the base and local matrices
  77626. * @param matrix defines the new base or local matrix
  77627. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77628. * @param updateLocalMatrix defines if the local matrix should be updated
  77629. */
  77630. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77631. /** @hidden */
  77632. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77633. /**
  77634. * Flag the bone as dirty (Forcing it to update everything)
  77635. */
  77636. markAsDirty(): void;
  77637. /** @hidden */
  77638. _markAsDirtyAndCompose(): void;
  77639. private _markAsDirtyAndDecompose;
  77640. /**
  77641. * Translate the bone in local or world space
  77642. * @param vec The amount to translate the bone
  77643. * @param space The space that the translation is in
  77644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77645. */
  77646. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77647. /**
  77648. * Set the postion of the bone in local or world space
  77649. * @param position The position to set the bone
  77650. * @param space The space that the position is in
  77651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77652. */
  77653. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77654. /**
  77655. * Set the absolute position of the bone (world space)
  77656. * @param position The position to set the bone
  77657. * @param mesh The mesh that this bone is attached to
  77658. */
  77659. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77660. /**
  77661. * Scale the bone on the x, y and z axes (in local space)
  77662. * @param x The amount to scale the bone on the x axis
  77663. * @param y The amount to scale the bone on the y axis
  77664. * @param z The amount to scale the bone on the z axis
  77665. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77666. */
  77667. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77668. /**
  77669. * Set the bone scaling in local space
  77670. * @param scale defines the scaling vector
  77671. */
  77672. setScale(scale: Vector3): void;
  77673. /**
  77674. * Gets the current scaling in local space
  77675. * @returns the current scaling vector
  77676. */
  77677. getScale(): Vector3;
  77678. /**
  77679. * Gets the current scaling in local space and stores it in a target vector
  77680. * @param result defines the target vector
  77681. */
  77682. getScaleToRef(result: Vector3): void;
  77683. /**
  77684. * Set the yaw, pitch, and roll of the bone in local or world space
  77685. * @param yaw The rotation of the bone on the y axis
  77686. * @param pitch The rotation of the bone on the x axis
  77687. * @param roll The rotation of the bone on the z axis
  77688. * @param space The space that the axes of rotation are in
  77689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77690. */
  77691. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77692. /**
  77693. * Add a rotation to the bone on an axis in local or world space
  77694. * @param axis The axis to rotate the bone on
  77695. * @param amount The amount to rotate the bone
  77696. * @param space The space that the axis is in
  77697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77698. */
  77699. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77700. /**
  77701. * Set the rotation of the bone to a particular axis angle in local or world space
  77702. * @param axis The axis to rotate the bone on
  77703. * @param angle The angle that the bone should be rotated to
  77704. * @param space The space that the axis is in
  77705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77706. */
  77707. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77708. /**
  77709. * Set the euler rotation of the bone in local of world space
  77710. * @param rotation The euler rotation that the bone should be set to
  77711. * @param space The space that the rotation is in
  77712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77713. */
  77714. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77715. /**
  77716. * Set the quaternion rotation of the bone in local of world space
  77717. * @param quat The quaternion rotation that the bone should be set to
  77718. * @param space The space that the rotation is in
  77719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77720. */
  77721. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77722. /**
  77723. * Set the rotation matrix of the bone in local of world space
  77724. * @param rotMat The rotation matrix that the bone should be set to
  77725. * @param space The space that the rotation is in
  77726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77727. */
  77728. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77729. private _rotateWithMatrix;
  77730. private _getNegativeRotationToRef;
  77731. /**
  77732. * Get the position of the bone in local or world space
  77733. * @param space The space that the returned position is in
  77734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77735. * @returns The position of the bone
  77736. */
  77737. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77738. /**
  77739. * Copy the position of the bone to a vector3 in local or world space
  77740. * @param space The space that the returned position is in
  77741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77742. * @param result The vector3 to copy the position to
  77743. */
  77744. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77745. /**
  77746. * Get the absolute position of the bone (world space)
  77747. * @param mesh The mesh that this bone is attached to
  77748. * @returns The absolute position of the bone
  77749. */
  77750. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77751. /**
  77752. * Copy the absolute position of the bone (world space) to the result param
  77753. * @param mesh The mesh that this bone is attached to
  77754. * @param result The vector3 to copy the absolute position to
  77755. */
  77756. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77757. /**
  77758. * Compute the absolute transforms of this bone and its children
  77759. */
  77760. computeAbsoluteTransforms(): void;
  77761. /**
  77762. * Get the world direction from an axis that is in the local space of the bone
  77763. * @param localAxis The local direction that is used to compute the world direction
  77764. * @param mesh The mesh that this bone is attached to
  77765. * @returns The world direction
  77766. */
  77767. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77768. /**
  77769. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77770. * @param localAxis The local direction that is used to compute the world direction
  77771. * @param mesh The mesh that this bone is attached to
  77772. * @param result The vector3 that the world direction will be copied to
  77773. */
  77774. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77775. /**
  77776. * Get the euler rotation of the bone in local or world space
  77777. * @param space The space that the rotation should be in
  77778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77779. * @returns The euler rotation
  77780. */
  77781. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77782. /**
  77783. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77784. * @param space The space that the rotation should be in
  77785. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77786. * @param result The vector3 that the rotation should be copied to
  77787. */
  77788. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77789. /**
  77790. * Get the quaternion rotation of the bone in either local or world space
  77791. * @param space The space that the rotation should be in
  77792. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77793. * @returns The quaternion rotation
  77794. */
  77795. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77796. /**
  77797. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77798. * @param space The space that the rotation should be in
  77799. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77800. * @param result The quaternion that the rotation should be copied to
  77801. */
  77802. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77803. /**
  77804. * Get the rotation matrix of the bone in local or world space
  77805. * @param space The space that the rotation should be in
  77806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77807. * @returns The rotation matrix
  77808. */
  77809. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77810. /**
  77811. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77812. * @param space The space that the rotation should be in
  77813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77814. * @param result The quaternion that the rotation should be copied to
  77815. */
  77816. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77817. /**
  77818. * Get the world position of a point that is in the local space of the bone
  77819. * @param position The local position
  77820. * @param mesh The mesh that this bone is attached to
  77821. * @returns The world position
  77822. */
  77823. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77824. /**
  77825. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77826. * @param position The local position
  77827. * @param mesh The mesh that this bone is attached to
  77828. * @param result The vector3 that the world position should be copied to
  77829. */
  77830. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77831. /**
  77832. * Get the local position of a point that is in world space
  77833. * @param position The world position
  77834. * @param mesh The mesh that this bone is attached to
  77835. * @returns The local position
  77836. */
  77837. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77838. /**
  77839. * Get the local position of a point that is in world space and copy it to the result param
  77840. * @param position The world position
  77841. * @param mesh The mesh that this bone is attached to
  77842. * @param result The vector3 that the local position should be copied to
  77843. */
  77844. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77845. }
  77846. }
  77847. declare module BABYLON {
  77848. /**
  77849. * 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.
  77850. * @see https://doc.babylonjs.com/how_to/transformnode
  77851. */
  77852. export class TransformNode extends Node {
  77853. /**
  77854. * Object will not rotate to face the camera
  77855. */
  77856. static BILLBOARDMODE_NONE: number;
  77857. /**
  77858. * Object will rotate to face the camera but only on the x axis
  77859. */
  77860. static BILLBOARDMODE_X: number;
  77861. /**
  77862. * Object will rotate to face the camera but only on the y axis
  77863. */
  77864. static BILLBOARDMODE_Y: number;
  77865. /**
  77866. * Object will rotate to face the camera but only on the z axis
  77867. */
  77868. static BILLBOARDMODE_Z: number;
  77869. /**
  77870. * Object will rotate to face the camera
  77871. */
  77872. static BILLBOARDMODE_ALL: number;
  77873. /**
  77874. * Object will rotate to face the camera's position instead of orientation
  77875. */
  77876. static BILLBOARDMODE_USE_POSITION: number;
  77877. private _forward;
  77878. private _forwardInverted;
  77879. private _up;
  77880. private _right;
  77881. private _rightInverted;
  77882. private _position;
  77883. private _rotation;
  77884. private _rotationQuaternion;
  77885. protected _scaling: Vector3;
  77886. protected _isDirty: boolean;
  77887. private _transformToBoneReferal;
  77888. private _isAbsoluteSynced;
  77889. private _billboardMode;
  77890. /**
  77891. * Gets or sets the billboard mode. Default is 0.
  77892. *
  77893. * | Value | Type | Description |
  77894. * | --- | --- | --- |
  77895. * | 0 | BILLBOARDMODE_NONE | |
  77896. * | 1 | BILLBOARDMODE_X | |
  77897. * | 2 | BILLBOARDMODE_Y | |
  77898. * | 4 | BILLBOARDMODE_Z | |
  77899. * | 7 | BILLBOARDMODE_ALL | |
  77900. *
  77901. */
  77902. billboardMode: number;
  77903. private _preserveParentRotationForBillboard;
  77904. /**
  77905. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77906. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77907. */
  77908. preserveParentRotationForBillboard: boolean;
  77909. /**
  77910. * 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
  77911. */
  77912. scalingDeterminant: number;
  77913. private _infiniteDistance;
  77914. /**
  77915. * Gets or sets the distance of the object to max, often used by skybox
  77916. */
  77917. infiniteDistance: boolean;
  77918. /**
  77919. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77920. * By default the system will update normals to compensate
  77921. */
  77922. ignoreNonUniformScaling: boolean;
  77923. /**
  77924. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  77925. */
  77926. reIntegrateRotationIntoRotationQuaternion: boolean;
  77927. /** @hidden */
  77928. _poseMatrix: Nullable<Matrix>;
  77929. /** @hidden */
  77930. _localMatrix: Matrix;
  77931. private _usePivotMatrix;
  77932. private _absolutePosition;
  77933. private _absoluteScaling;
  77934. private _absoluteRotationQuaternion;
  77935. private _pivotMatrix;
  77936. private _pivotMatrixInverse;
  77937. protected _postMultiplyPivotMatrix: boolean;
  77938. protected _isWorldMatrixFrozen: boolean;
  77939. /** @hidden */
  77940. _indexInSceneTransformNodesArray: number;
  77941. /**
  77942. * An event triggered after the world matrix is updated
  77943. */
  77944. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77945. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77946. /**
  77947. * Gets a string identifying the name of the class
  77948. * @returns "TransformNode" string
  77949. */
  77950. getClassName(): string;
  77951. /**
  77952. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77953. */
  77954. position: Vector3;
  77955. /**
  77956. * 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)).
  77957. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77958. */
  77959. rotation: Vector3;
  77960. /**
  77961. * 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)).
  77962. */
  77963. scaling: Vector3;
  77964. /**
  77965. * 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).
  77966. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77967. */
  77968. rotationQuaternion: Nullable<Quaternion>;
  77969. /**
  77970. * The forward direction of that transform in world space.
  77971. */
  77972. readonly forward: Vector3;
  77973. /**
  77974. * The up direction of that transform in world space.
  77975. */
  77976. readonly up: Vector3;
  77977. /**
  77978. * The right direction of that transform in world space.
  77979. */
  77980. readonly right: Vector3;
  77981. /**
  77982. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77983. * @param matrix the matrix to copy the pose from
  77984. * @returns this TransformNode.
  77985. */
  77986. updatePoseMatrix(matrix: Matrix): TransformNode;
  77987. /**
  77988. * Returns the mesh Pose matrix.
  77989. * @returns the pose matrix
  77990. */
  77991. getPoseMatrix(): Matrix;
  77992. /** @hidden */
  77993. _isSynchronized(): boolean;
  77994. /** @hidden */
  77995. _initCache(): void;
  77996. /**
  77997. * Flag the transform node as dirty (Forcing it to update everything)
  77998. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77999. * @returns this transform node
  78000. */
  78001. markAsDirty(property: string): TransformNode;
  78002. /**
  78003. * Returns the current mesh absolute position.
  78004. * Returns a Vector3.
  78005. */
  78006. readonly absolutePosition: Vector3;
  78007. /**
  78008. * Returns the current mesh absolute scaling.
  78009. * Returns a Vector3.
  78010. */
  78011. readonly absoluteScaling: Vector3;
  78012. /**
  78013. * Returns the current mesh absolute rotation.
  78014. * Returns a Quaternion.
  78015. */
  78016. readonly absoluteRotationQuaternion: Quaternion;
  78017. /**
  78018. * Sets a new matrix to apply before all other transformation
  78019. * @param matrix defines the transform matrix
  78020. * @returns the current TransformNode
  78021. */
  78022. setPreTransformMatrix(matrix: Matrix): TransformNode;
  78023. /**
  78024. * Sets a new pivot matrix to the current node
  78025. * @param matrix defines the new pivot matrix to use
  78026. * @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
  78027. * @returns the current TransformNode
  78028. */
  78029. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  78030. /**
  78031. * Returns the mesh pivot matrix.
  78032. * Default : Identity.
  78033. * @returns the matrix
  78034. */
  78035. getPivotMatrix(): Matrix;
  78036. /**
  78037. * Prevents the World matrix to be computed any longer.
  78038. * @returns the TransformNode.
  78039. */
  78040. freezeWorldMatrix(): TransformNode;
  78041. /**
  78042. * Allows back the World matrix computation.
  78043. * @returns the TransformNode.
  78044. */
  78045. unfreezeWorldMatrix(): this;
  78046. /**
  78047. * True if the World matrix has been frozen.
  78048. */
  78049. readonly isWorldMatrixFrozen: boolean;
  78050. /**
  78051. * Retuns the mesh absolute position in the World.
  78052. * @returns a Vector3.
  78053. */
  78054. getAbsolutePosition(): Vector3;
  78055. /**
  78056. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  78057. * @param absolutePosition the absolute position to set
  78058. * @returns the TransformNode.
  78059. */
  78060. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78061. /**
  78062. * Sets the mesh position in its local space.
  78063. * @param vector3 the position to set in localspace
  78064. * @returns the TransformNode.
  78065. */
  78066. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  78067. /**
  78068. * Returns the mesh position in the local space from the current World matrix values.
  78069. * @returns a new Vector3.
  78070. */
  78071. getPositionExpressedInLocalSpace(): Vector3;
  78072. /**
  78073. * Translates the mesh along the passed Vector3 in its local space.
  78074. * @param vector3 the distance to translate in localspace
  78075. * @returns the TransformNode.
  78076. */
  78077. locallyTranslate(vector3: Vector3): TransformNode;
  78078. private static _lookAtVectorCache;
  78079. /**
  78080. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  78081. * @param targetPoint the position (must be in same space as current mesh) to look at
  78082. * @param yawCor optional yaw (y-axis) correction in radians
  78083. * @param pitchCor optional pitch (x-axis) correction in radians
  78084. * @param rollCor optional roll (z-axis) correction in radians
  78085. * @param space the choosen space of the target
  78086. * @returns the TransformNode.
  78087. */
  78088. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  78089. /**
  78090. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78091. * This Vector3 is expressed in the World space.
  78092. * @param localAxis axis to rotate
  78093. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  78094. */
  78095. getDirection(localAxis: Vector3): Vector3;
  78096. /**
  78097. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  78098. * localAxis is expressed in the mesh local space.
  78099. * result is computed in the Wordl space from the mesh World matrix.
  78100. * @param localAxis axis to rotate
  78101. * @param result the resulting transformnode
  78102. * @returns this TransformNode.
  78103. */
  78104. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  78105. /**
  78106. * Sets this transform node rotation to the given local axis.
  78107. * @param localAxis the axis in local space
  78108. * @param yawCor optional yaw (y-axis) correction in radians
  78109. * @param pitchCor optional pitch (x-axis) correction in radians
  78110. * @param rollCor optional roll (z-axis) correction in radians
  78111. * @returns this TransformNode
  78112. */
  78113. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  78114. /**
  78115. * Sets a new pivot point to the current node
  78116. * @param point defines the new pivot point to use
  78117. * @param space defines if the point is in world or local space (local by default)
  78118. * @returns the current TransformNode
  78119. */
  78120. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  78121. /**
  78122. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  78123. * @returns the pivot point
  78124. */
  78125. getPivotPoint(): Vector3;
  78126. /**
  78127. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  78128. * @param result the vector3 to store the result
  78129. * @returns this TransformNode.
  78130. */
  78131. getPivotPointToRef(result: Vector3): TransformNode;
  78132. /**
  78133. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  78134. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  78135. */
  78136. getAbsolutePivotPoint(): Vector3;
  78137. /**
  78138. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  78139. * @param result vector3 to store the result
  78140. * @returns this TransformNode.
  78141. */
  78142. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  78143. /**
  78144. * Defines the passed node as the parent of the current node.
  78145. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  78146. * @see https://doc.babylonjs.com/how_to/parenting
  78147. * @param node the node ot set as the parent
  78148. * @returns this TransformNode.
  78149. */
  78150. setParent(node: Nullable<Node>): TransformNode;
  78151. private _nonUniformScaling;
  78152. /**
  78153. * True if the scaling property of this object is non uniform eg. (1,2,1)
  78154. */
  78155. readonly nonUniformScaling: boolean;
  78156. /** @hidden */
  78157. _updateNonUniformScalingState(value: boolean): boolean;
  78158. /**
  78159. * Attach the current TransformNode to another TransformNode associated with a bone
  78160. * @param bone Bone affecting the TransformNode
  78161. * @param affectedTransformNode TransformNode associated with the bone
  78162. * @returns this object
  78163. */
  78164. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  78165. /**
  78166. * Detach the transform node if its associated with a bone
  78167. * @returns this object
  78168. */
  78169. detachFromBone(): TransformNode;
  78170. private static _rotationAxisCache;
  78171. /**
  78172. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  78173. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78174. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78175. * The passed axis is also normalized.
  78176. * @param axis the axis to rotate around
  78177. * @param amount the amount to rotate in radians
  78178. * @param space Space to rotate in (Default: local)
  78179. * @returns the TransformNode.
  78180. */
  78181. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78182. /**
  78183. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  78184. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  78185. * The passed axis is also normalized. .
  78186. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  78187. * @param point the point to rotate around
  78188. * @param axis the axis to rotate around
  78189. * @param amount the amount to rotate in radians
  78190. * @returns the TransformNode
  78191. */
  78192. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  78193. /**
  78194. * Translates the mesh along the axis vector for the passed distance in the given space.
  78195. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  78196. * @param axis the axis to translate in
  78197. * @param distance the distance to translate
  78198. * @param space Space to rotate in (Default: local)
  78199. * @returns the TransformNode.
  78200. */
  78201. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78202. /**
  78203. * Adds a rotation step to the mesh current rotation.
  78204. * x, y, z are Euler angles expressed in radians.
  78205. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  78206. * This means this rotation is made in the mesh local space only.
  78207. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  78208. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  78209. * ```javascript
  78210. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  78211. * ```
  78212. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  78213. * 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.
  78214. * @param x Rotation to add
  78215. * @param y Rotation to add
  78216. * @param z Rotation to add
  78217. * @returns the TransformNode.
  78218. */
  78219. addRotation(x: number, y: number, z: number): TransformNode;
  78220. /**
  78221. * @hidden
  78222. */
  78223. protected _getEffectiveParent(): Nullable<Node>;
  78224. /**
  78225. * Computes the world matrix of the node
  78226. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78227. * @returns the world matrix
  78228. */
  78229. computeWorldMatrix(force?: boolean): Matrix;
  78230. protected _afterComputeWorldMatrix(): void;
  78231. /**
  78232. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  78233. * @param func callback function to add
  78234. *
  78235. * @returns the TransformNode.
  78236. */
  78237. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78238. /**
  78239. * Removes a registered callback function.
  78240. * @param func callback function to remove
  78241. * @returns the TransformNode.
  78242. */
  78243. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  78244. /**
  78245. * Gets the position of the current mesh in camera space
  78246. * @param camera defines the camera to use
  78247. * @returns a position
  78248. */
  78249. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  78250. /**
  78251. * Returns the distance from the mesh to the active camera
  78252. * @param camera defines the camera to use
  78253. * @returns the distance
  78254. */
  78255. getDistanceToCamera(camera?: Nullable<Camera>): number;
  78256. /**
  78257. * Clone the current transform node
  78258. * @param name Name of the new clone
  78259. * @param newParent New parent for the clone
  78260. * @param doNotCloneChildren Do not clone children hierarchy
  78261. * @returns the new transform node
  78262. */
  78263. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  78264. /**
  78265. * Serializes the objects information.
  78266. * @param currentSerializationObject defines the object to serialize in
  78267. * @returns the serialized object
  78268. */
  78269. serialize(currentSerializationObject?: any): any;
  78270. /**
  78271. * Returns a new TransformNode object parsed from the source provided.
  78272. * @param parsedTransformNode is the source.
  78273. * @param scene the scne the object belongs to
  78274. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  78275. * @returns a new TransformNode object parsed from the source provided.
  78276. */
  78277. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  78278. /**
  78279. * Get all child-transformNodes of this node
  78280. * @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
  78281. * @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
  78282. * @returns an array of TransformNode
  78283. */
  78284. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  78285. /**
  78286. * Releases resources associated with this transform node.
  78287. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78288. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78289. */
  78290. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78291. /**
  78292. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  78293. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  78294. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  78295. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  78296. * @returns the current mesh
  78297. */
  78298. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  78299. private _syncAbsoluteScalingAndRotation;
  78300. }
  78301. }
  78302. declare module BABYLON {
  78303. /**
  78304. * Defines the types of pose enabled controllers that are supported
  78305. */
  78306. export enum PoseEnabledControllerType {
  78307. /**
  78308. * HTC Vive
  78309. */
  78310. VIVE = 0,
  78311. /**
  78312. * Oculus Rift
  78313. */
  78314. OCULUS = 1,
  78315. /**
  78316. * Windows mixed reality
  78317. */
  78318. WINDOWS = 2,
  78319. /**
  78320. * Samsung gear VR
  78321. */
  78322. GEAR_VR = 3,
  78323. /**
  78324. * Google Daydream
  78325. */
  78326. DAYDREAM = 4,
  78327. /**
  78328. * Generic
  78329. */
  78330. GENERIC = 5
  78331. }
  78332. /**
  78333. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78334. */
  78335. export interface MutableGamepadButton {
  78336. /**
  78337. * Value of the button/trigger
  78338. */
  78339. value: number;
  78340. /**
  78341. * If the button/trigger is currently touched
  78342. */
  78343. touched: boolean;
  78344. /**
  78345. * If the button/trigger is currently pressed
  78346. */
  78347. pressed: boolean;
  78348. }
  78349. /**
  78350. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78351. * @hidden
  78352. */
  78353. export interface ExtendedGamepadButton extends GamepadButton {
  78354. /**
  78355. * If the button/trigger is currently pressed
  78356. */
  78357. readonly pressed: boolean;
  78358. /**
  78359. * If the button/trigger is currently touched
  78360. */
  78361. readonly touched: boolean;
  78362. /**
  78363. * Value of the button/trigger
  78364. */
  78365. readonly value: number;
  78366. }
  78367. /** @hidden */
  78368. export interface _GamePadFactory {
  78369. /**
  78370. * Returns wether or not the current gamepad can be created for this type of controller.
  78371. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78372. * @returns true if it can be created, otherwise false
  78373. */
  78374. canCreate(gamepadInfo: any): boolean;
  78375. /**
  78376. * Creates a new instance of the Gamepad.
  78377. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78378. * @returns the new gamepad instance
  78379. */
  78380. create(gamepadInfo: any): Gamepad;
  78381. }
  78382. /**
  78383. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78384. */
  78385. export class PoseEnabledControllerHelper {
  78386. /** @hidden */
  78387. static _ControllerFactories: _GamePadFactory[];
  78388. /** @hidden */
  78389. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78390. /**
  78391. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78392. * @param vrGamepad the gamepad to initialized
  78393. * @returns a vr controller of the type the gamepad identified as
  78394. */
  78395. static InitiateController(vrGamepad: any): Gamepad;
  78396. }
  78397. /**
  78398. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78399. */
  78400. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78401. /**
  78402. * If the controller is used in a webXR session
  78403. */
  78404. isXR: boolean;
  78405. private _deviceRoomPosition;
  78406. private _deviceRoomRotationQuaternion;
  78407. /**
  78408. * The device position in babylon space
  78409. */
  78410. devicePosition: Vector3;
  78411. /**
  78412. * The device rotation in babylon space
  78413. */
  78414. deviceRotationQuaternion: Quaternion;
  78415. /**
  78416. * The scale factor of the device in babylon space
  78417. */
  78418. deviceScaleFactor: number;
  78419. /**
  78420. * (Likely devicePosition should be used instead) The device position in its room space
  78421. */
  78422. position: Vector3;
  78423. /**
  78424. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78425. */
  78426. rotationQuaternion: Quaternion;
  78427. /**
  78428. * The type of controller (Eg. Windows mixed reality)
  78429. */
  78430. controllerType: PoseEnabledControllerType;
  78431. protected _calculatedPosition: Vector3;
  78432. private _calculatedRotation;
  78433. /**
  78434. * The raw pose from the device
  78435. */
  78436. rawPose: DevicePose;
  78437. private _trackPosition;
  78438. private _maxRotationDistFromHeadset;
  78439. private _draggedRoomRotation;
  78440. /**
  78441. * @hidden
  78442. */
  78443. _disableTrackPosition(fixedPosition: Vector3): void;
  78444. /**
  78445. * Internal, the mesh attached to the controller
  78446. * @hidden
  78447. */
  78448. _mesh: Nullable<AbstractMesh>;
  78449. private _poseControlledCamera;
  78450. private _leftHandSystemQuaternion;
  78451. /**
  78452. * Internal, matrix used to convert room space to babylon space
  78453. * @hidden
  78454. */
  78455. _deviceToWorld: Matrix;
  78456. /**
  78457. * Node to be used when casting a ray from the controller
  78458. * @hidden
  78459. */
  78460. _pointingPoseNode: Nullable<TransformNode>;
  78461. /**
  78462. * Name of the child mesh that can be used to cast a ray from the controller
  78463. */
  78464. static readonly POINTING_POSE: string;
  78465. /**
  78466. * Creates a new PoseEnabledController from a gamepad
  78467. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78468. */
  78469. constructor(browserGamepad: any);
  78470. private _workingMatrix;
  78471. /**
  78472. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78473. */
  78474. update(): void;
  78475. /**
  78476. * Updates only the pose device and mesh without doing any button event checking
  78477. */
  78478. protected _updatePoseAndMesh(): void;
  78479. /**
  78480. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78481. * @param poseData raw pose fromthe device
  78482. */
  78483. updateFromDevice(poseData: DevicePose): void;
  78484. /**
  78485. * @hidden
  78486. */
  78487. _meshAttachedObservable: Observable<AbstractMesh>;
  78488. /**
  78489. * Attaches a mesh to the controller
  78490. * @param mesh the mesh to be attached
  78491. */
  78492. attachToMesh(mesh: AbstractMesh): void;
  78493. /**
  78494. * Attaches the controllers mesh to a camera
  78495. * @param camera the camera the mesh should be attached to
  78496. */
  78497. attachToPoseControlledCamera(camera: TargetCamera): void;
  78498. /**
  78499. * Disposes of the controller
  78500. */
  78501. dispose(): void;
  78502. /**
  78503. * The mesh that is attached to the controller
  78504. */
  78505. readonly mesh: Nullable<AbstractMesh>;
  78506. /**
  78507. * Gets the ray of the controller in the direction the controller is pointing
  78508. * @param length the length the resulting ray should be
  78509. * @returns a ray in the direction the controller is pointing
  78510. */
  78511. getForwardRay(length?: number): Ray;
  78512. }
  78513. }
  78514. declare module BABYLON {
  78515. /**
  78516. * Defines the WebVRController object that represents controllers tracked in 3D space
  78517. */
  78518. export abstract class WebVRController extends PoseEnabledController {
  78519. /**
  78520. * Internal, the default controller model for the controller
  78521. */
  78522. protected _defaultModel: AbstractMesh;
  78523. /**
  78524. * Fired when the trigger state has changed
  78525. */
  78526. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78527. /**
  78528. * Fired when the main button state has changed
  78529. */
  78530. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78531. /**
  78532. * Fired when the secondary button state has changed
  78533. */
  78534. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78535. /**
  78536. * Fired when the pad state has changed
  78537. */
  78538. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78539. /**
  78540. * Fired when controllers stick values have changed
  78541. */
  78542. onPadValuesChangedObservable: Observable<StickValues>;
  78543. /**
  78544. * Array of button availible on the controller
  78545. */
  78546. protected _buttons: Array<MutableGamepadButton>;
  78547. private _onButtonStateChange;
  78548. /**
  78549. * Fired when a controller button's state has changed
  78550. * @param callback the callback containing the button that was modified
  78551. */
  78552. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78553. /**
  78554. * X and Y axis corresponding to the controllers joystick
  78555. */
  78556. pad: StickValues;
  78557. /**
  78558. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78559. */
  78560. hand: string;
  78561. /**
  78562. * The default controller model for the controller
  78563. */
  78564. readonly defaultModel: AbstractMesh;
  78565. /**
  78566. * Creates a new WebVRController from a gamepad
  78567. * @param vrGamepad the gamepad that the WebVRController should be created from
  78568. */
  78569. constructor(vrGamepad: any);
  78570. /**
  78571. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78572. */
  78573. update(): void;
  78574. /**
  78575. * Function to be called when a button is modified
  78576. */
  78577. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78578. /**
  78579. * Loads a mesh and attaches it to the controller
  78580. * @param scene the scene the mesh should be added to
  78581. * @param meshLoaded callback for when the mesh has been loaded
  78582. */
  78583. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78584. private _setButtonValue;
  78585. private _changes;
  78586. private _checkChanges;
  78587. /**
  78588. * Disposes of th webVRCOntroller
  78589. */
  78590. dispose(): void;
  78591. }
  78592. }
  78593. declare module BABYLON {
  78594. /**
  78595. * The HemisphericLight simulates the ambient environment light,
  78596. * so the passed direction is the light reflection direction, not the incoming direction.
  78597. */
  78598. export class HemisphericLight extends Light {
  78599. /**
  78600. * The groundColor is the light in the opposite direction to the one specified during creation.
  78601. * 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.
  78602. */
  78603. groundColor: Color3;
  78604. /**
  78605. * The light reflection direction, not the incoming direction.
  78606. */
  78607. direction: Vector3;
  78608. /**
  78609. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78610. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78611. * The HemisphericLight can't cast shadows.
  78612. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78613. * @param name The friendly name of the light
  78614. * @param direction The direction of the light reflection
  78615. * @param scene The scene the light belongs to
  78616. */
  78617. constructor(name: string, direction: Vector3, scene: Scene);
  78618. protected _buildUniformLayout(): void;
  78619. /**
  78620. * Returns the string "HemisphericLight".
  78621. * @return The class name
  78622. */
  78623. getClassName(): string;
  78624. /**
  78625. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78626. * Returns the updated direction.
  78627. * @param target The target the direction should point to
  78628. * @return The computed direction
  78629. */
  78630. setDirectionToTarget(target: Vector3): Vector3;
  78631. /**
  78632. * Returns the shadow generator associated to the light.
  78633. * @returns Always null for hemispheric lights because it does not support shadows.
  78634. */
  78635. getShadowGenerator(): Nullable<IShadowGenerator>;
  78636. /**
  78637. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78638. * @param effect The effect to update
  78639. * @param lightIndex The index of the light in the effect to update
  78640. * @returns The hemispheric light
  78641. */
  78642. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78643. /**
  78644. * Computes the world matrix of the node
  78645. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78646. * @param useWasUpdatedFlag defines a reserved property
  78647. * @returns the world matrix
  78648. */
  78649. computeWorldMatrix(): Matrix;
  78650. /**
  78651. * Returns the integer 3.
  78652. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78653. */
  78654. getTypeID(): number;
  78655. /**
  78656. * Prepares the list of defines specific to the light type.
  78657. * @param defines the list of defines
  78658. * @param lightIndex defines the index of the light for the effect
  78659. */
  78660. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78661. }
  78662. }
  78663. declare module BABYLON {
  78664. /** @hidden */
  78665. export var vrMultiviewToSingleviewPixelShader: {
  78666. name: string;
  78667. shader: string;
  78668. };
  78669. }
  78670. declare module BABYLON {
  78671. /**
  78672. * Renders to multiple views with a single draw call
  78673. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78674. */
  78675. export class MultiviewRenderTarget extends RenderTargetTexture {
  78676. /**
  78677. * Creates a multiview render target
  78678. * @param scene scene used with the render target
  78679. * @param size the size of the render target (used for each view)
  78680. */
  78681. constructor(scene: Scene, size?: number | {
  78682. width: number;
  78683. height: number;
  78684. } | {
  78685. ratio: number;
  78686. });
  78687. /**
  78688. * @hidden
  78689. * @param faceIndex the face index, if its a cube texture
  78690. */
  78691. _bindFrameBuffer(faceIndex?: number): void;
  78692. /**
  78693. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78694. * @returns the view count
  78695. */
  78696. getViewCount(): number;
  78697. }
  78698. }
  78699. declare module BABYLON {
  78700. /**
  78701. * Reprasents a camera frustum
  78702. */
  78703. export class Frustum {
  78704. /**
  78705. * Gets the planes representing the frustum
  78706. * @param transform matrix to be applied to the returned planes
  78707. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78708. */
  78709. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78710. /**
  78711. * Gets the near frustum plane transformed by the transform matrix
  78712. * @param transform transformation matrix to be applied to the resulting frustum plane
  78713. * @param frustumPlane the resuling frustum plane
  78714. */
  78715. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78716. /**
  78717. * Gets the far frustum plane transformed by the transform matrix
  78718. * @param transform transformation matrix to be applied to the resulting frustum plane
  78719. * @param frustumPlane the resuling frustum plane
  78720. */
  78721. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78722. /**
  78723. * Gets the left frustum plane transformed by the transform matrix
  78724. * @param transform transformation matrix to be applied to the resulting frustum plane
  78725. * @param frustumPlane the resuling frustum plane
  78726. */
  78727. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78728. /**
  78729. * Gets the right frustum plane transformed by the transform matrix
  78730. * @param transform transformation matrix to be applied to the resulting frustum plane
  78731. * @param frustumPlane the resuling frustum plane
  78732. */
  78733. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78734. /**
  78735. * Gets the top frustum plane transformed by the transform matrix
  78736. * @param transform transformation matrix to be applied to the resulting frustum plane
  78737. * @param frustumPlane the resuling frustum plane
  78738. */
  78739. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78740. /**
  78741. * Gets the bottom frustum plane transformed by the transform matrix
  78742. * @param transform transformation matrix to be applied to the resulting frustum plane
  78743. * @param frustumPlane the resuling frustum plane
  78744. */
  78745. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78746. /**
  78747. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78748. * @param transform transformation matrix to be applied to the resulting frustum planes
  78749. * @param frustumPlanes the resuling frustum planes
  78750. */
  78751. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78752. }
  78753. }
  78754. declare module BABYLON {
  78755. interface Engine {
  78756. /**
  78757. * Creates a new multiview render target
  78758. * @param width defines the width of the texture
  78759. * @param height defines the height of the texture
  78760. * @returns the created multiview texture
  78761. */
  78762. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78763. /**
  78764. * Binds a multiview framebuffer to be drawn to
  78765. * @param multiviewTexture texture to bind
  78766. */
  78767. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78768. }
  78769. interface Camera {
  78770. /**
  78771. * @hidden
  78772. * 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)
  78773. */
  78774. _useMultiviewToSingleView: boolean;
  78775. /**
  78776. * @hidden
  78777. * 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)
  78778. */
  78779. _multiviewTexture: Nullable<RenderTargetTexture>;
  78780. /**
  78781. * @hidden
  78782. * ensures the multiview texture of the camera exists and has the specified width/height
  78783. * @param width height to set on the multiview texture
  78784. * @param height width to set on the multiview texture
  78785. */
  78786. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78787. }
  78788. interface Scene {
  78789. /** @hidden */
  78790. _transformMatrixR: Matrix;
  78791. /** @hidden */
  78792. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78793. /** @hidden */
  78794. _createMultiviewUbo(): void;
  78795. /** @hidden */
  78796. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78797. /** @hidden */
  78798. _renderMultiviewToSingleView(camera: Camera): void;
  78799. }
  78800. }
  78801. declare module BABYLON {
  78802. /**
  78803. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78804. * This will not be used for webXR as it supports displaying texture arrays directly
  78805. */
  78806. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78807. /**
  78808. * Initializes a VRMultiviewToSingleview
  78809. * @param name name of the post process
  78810. * @param camera camera to be applied to
  78811. * @param scaleFactor scaling factor to the size of the output texture
  78812. */
  78813. constructor(name: string, camera: Camera, scaleFactor: number);
  78814. }
  78815. }
  78816. declare module BABYLON {
  78817. interface Engine {
  78818. /** @hidden */
  78819. _vrDisplay: any;
  78820. /** @hidden */
  78821. _vrSupported: boolean;
  78822. /** @hidden */
  78823. _oldSize: Size;
  78824. /** @hidden */
  78825. _oldHardwareScaleFactor: number;
  78826. /** @hidden */
  78827. _vrExclusivePointerMode: boolean;
  78828. /** @hidden */
  78829. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78830. /** @hidden */
  78831. _onVRDisplayPointerRestricted: () => void;
  78832. /** @hidden */
  78833. _onVRDisplayPointerUnrestricted: () => void;
  78834. /** @hidden */
  78835. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78836. /** @hidden */
  78837. _onVrDisplayDisconnect: Nullable<() => void>;
  78838. /** @hidden */
  78839. _onVrDisplayPresentChange: Nullable<() => void>;
  78840. /**
  78841. * Observable signaled when VR display mode changes
  78842. */
  78843. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78844. /**
  78845. * Observable signaled when VR request present is complete
  78846. */
  78847. onVRRequestPresentComplete: Observable<boolean>;
  78848. /**
  78849. * Observable signaled when VR request present starts
  78850. */
  78851. onVRRequestPresentStart: Observable<Engine>;
  78852. /**
  78853. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78854. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78855. */
  78856. isInVRExclusivePointerMode: boolean;
  78857. /**
  78858. * Gets a boolean indicating if a webVR device was detected
  78859. * @returns true if a webVR device was detected
  78860. */
  78861. isVRDevicePresent(): boolean;
  78862. /**
  78863. * Gets the current webVR device
  78864. * @returns the current webVR device (or null)
  78865. */
  78866. getVRDevice(): any;
  78867. /**
  78868. * Initializes a webVR display and starts listening to display change events
  78869. * The onVRDisplayChangedObservable will be notified upon these changes
  78870. * @returns A promise containing a VRDisplay and if vr is supported
  78871. */
  78872. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78873. /** @hidden */
  78874. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78875. /**
  78876. * Call this function to switch to webVR mode
  78877. * Will do nothing if webVR is not supported or if there is no webVR device
  78878. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78879. */
  78880. enableVR(): void;
  78881. /** @hidden */
  78882. _onVRFullScreenTriggered(): void;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /**
  78887. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78888. * IMPORTANT!! The data is right-hand data.
  78889. * @export
  78890. * @interface DevicePose
  78891. */
  78892. export interface DevicePose {
  78893. /**
  78894. * The position of the device, values in array are [x,y,z].
  78895. */
  78896. readonly position: Nullable<Float32Array>;
  78897. /**
  78898. * The linearVelocity of the device, values in array are [x,y,z].
  78899. */
  78900. readonly linearVelocity: Nullable<Float32Array>;
  78901. /**
  78902. * The linearAcceleration of the device, values in array are [x,y,z].
  78903. */
  78904. readonly linearAcceleration: Nullable<Float32Array>;
  78905. /**
  78906. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78907. */
  78908. readonly orientation: Nullable<Float32Array>;
  78909. /**
  78910. * The angularVelocity of the device, values in array are [x,y,z].
  78911. */
  78912. readonly angularVelocity: Nullable<Float32Array>;
  78913. /**
  78914. * The angularAcceleration of the device, values in array are [x,y,z].
  78915. */
  78916. readonly angularAcceleration: Nullable<Float32Array>;
  78917. }
  78918. /**
  78919. * Interface representing a pose controlled object in Babylon.
  78920. * A pose controlled object has both regular pose values as well as pose values
  78921. * from an external device such as a VR head mounted display
  78922. */
  78923. export interface PoseControlled {
  78924. /**
  78925. * The position of the object in babylon space.
  78926. */
  78927. position: Vector3;
  78928. /**
  78929. * The rotation quaternion of the object in babylon space.
  78930. */
  78931. rotationQuaternion: Quaternion;
  78932. /**
  78933. * The position of the device in babylon space.
  78934. */
  78935. devicePosition?: Vector3;
  78936. /**
  78937. * The rotation quaternion of the device in babylon space.
  78938. */
  78939. deviceRotationQuaternion: Quaternion;
  78940. /**
  78941. * The raw pose coming from the device.
  78942. */
  78943. rawPose: Nullable<DevicePose>;
  78944. /**
  78945. * The scale of the device to be used when translating from device space to babylon space.
  78946. */
  78947. deviceScaleFactor: number;
  78948. /**
  78949. * Updates the poseControlled values based on the input device pose.
  78950. * @param poseData the pose data to update the object with
  78951. */
  78952. updateFromDevice(poseData: DevicePose): void;
  78953. }
  78954. /**
  78955. * Set of options to customize the webVRCamera
  78956. */
  78957. export interface WebVROptions {
  78958. /**
  78959. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78960. */
  78961. trackPosition?: boolean;
  78962. /**
  78963. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78964. */
  78965. positionScale?: number;
  78966. /**
  78967. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78968. */
  78969. displayName?: string;
  78970. /**
  78971. * Should the native controller meshes be initialized. (default: true)
  78972. */
  78973. controllerMeshes?: boolean;
  78974. /**
  78975. * Creating a default HemiLight only on controllers. (default: true)
  78976. */
  78977. defaultLightingOnControllers?: boolean;
  78978. /**
  78979. * If you don't want to use the default VR button of the helper. (default: false)
  78980. */
  78981. useCustomVRButton?: boolean;
  78982. /**
  78983. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78984. */
  78985. customVRButton?: HTMLButtonElement;
  78986. /**
  78987. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78988. */
  78989. rayLength?: number;
  78990. /**
  78991. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78992. */
  78993. defaultHeight?: number;
  78994. /**
  78995. * If multiview should be used if availible (default: false)
  78996. */
  78997. useMultiview?: boolean;
  78998. }
  78999. /**
  79000. * This represents a WebVR camera.
  79001. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  79002. * @example http://doc.babylonjs.com/how_to/webvr_camera
  79003. */
  79004. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  79005. private webVROptions;
  79006. /**
  79007. * @hidden
  79008. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  79009. */
  79010. _vrDevice: any;
  79011. /**
  79012. * The rawPose of the vrDevice.
  79013. */
  79014. rawPose: Nullable<DevicePose>;
  79015. private _onVREnabled;
  79016. private _specsVersion;
  79017. private _attached;
  79018. private _frameData;
  79019. protected _descendants: Array<Node>;
  79020. private _deviceRoomPosition;
  79021. /** @hidden */
  79022. _deviceRoomRotationQuaternion: Quaternion;
  79023. private _standingMatrix;
  79024. /**
  79025. * Represents device position in babylon space.
  79026. */
  79027. devicePosition: Vector3;
  79028. /**
  79029. * Represents device rotation in babylon space.
  79030. */
  79031. deviceRotationQuaternion: Quaternion;
  79032. /**
  79033. * The scale of the device to be used when translating from device space to babylon space.
  79034. */
  79035. deviceScaleFactor: number;
  79036. private _deviceToWorld;
  79037. private _worldToDevice;
  79038. /**
  79039. * References to the webVR controllers for the vrDevice.
  79040. */
  79041. controllers: Array<WebVRController>;
  79042. /**
  79043. * Emits an event when a controller is attached.
  79044. */
  79045. onControllersAttachedObservable: Observable<WebVRController[]>;
  79046. /**
  79047. * Emits an event when a controller's mesh has been loaded;
  79048. */
  79049. onControllerMeshLoadedObservable: Observable<WebVRController>;
  79050. /**
  79051. * Emits an event when the HMD's pose has been updated.
  79052. */
  79053. onPoseUpdatedFromDeviceObservable: Observable<any>;
  79054. private _poseSet;
  79055. /**
  79056. * If the rig cameras be used as parent instead of this camera.
  79057. */
  79058. rigParenting: boolean;
  79059. private _lightOnControllers;
  79060. private _defaultHeight?;
  79061. /**
  79062. * Instantiates a WebVRFreeCamera.
  79063. * @param name The name of the WebVRFreeCamera
  79064. * @param position The starting anchor position for the camera
  79065. * @param scene The scene the camera belongs to
  79066. * @param webVROptions a set of customizable options for the webVRCamera
  79067. */
  79068. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  79069. /**
  79070. * Gets the device distance from the ground in meters.
  79071. * @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.
  79072. */
  79073. deviceDistanceToRoomGround(): number;
  79074. /**
  79075. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79076. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  79077. */
  79078. useStandingMatrix(callback?: (bool: boolean) => void): void;
  79079. /**
  79080. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  79081. * @returns A promise with a boolean set to if the standing matrix is supported.
  79082. */
  79083. useStandingMatrixAsync(): Promise<boolean>;
  79084. /**
  79085. * Disposes the camera
  79086. */
  79087. dispose(): void;
  79088. /**
  79089. * Gets a vrController by name.
  79090. * @param name The name of the controller to retreive
  79091. * @returns the controller matching the name specified or null if not found
  79092. */
  79093. getControllerByName(name: string): Nullable<WebVRController>;
  79094. private _leftController;
  79095. /**
  79096. * The controller corresponding to the users left hand.
  79097. */
  79098. readonly leftController: Nullable<WebVRController>;
  79099. private _rightController;
  79100. /**
  79101. * The controller corresponding to the users right hand.
  79102. */
  79103. readonly rightController: Nullable<WebVRController>;
  79104. /**
  79105. * Casts a ray forward from the vrCamera's gaze.
  79106. * @param length Length of the ray (default: 100)
  79107. * @returns the ray corresponding to the gaze
  79108. */
  79109. getForwardRay(length?: number): Ray;
  79110. /**
  79111. * @hidden
  79112. * Updates the camera based on device's frame data
  79113. */
  79114. _checkInputs(): void;
  79115. /**
  79116. * Updates the poseControlled values based on the input device pose.
  79117. * @param poseData Pose coming from the device
  79118. */
  79119. updateFromDevice(poseData: DevicePose): void;
  79120. private _htmlElementAttached;
  79121. private _detachIfAttached;
  79122. /**
  79123. * WebVR's attach control will start broadcasting frames to the device.
  79124. * Note that in certain browsers (chrome for example) this function must be called
  79125. * within a user-interaction callback. Example:
  79126. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  79127. *
  79128. * @param element html element to attach the vrDevice to
  79129. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  79130. */
  79131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79132. /**
  79133. * Detaches the camera from the html element and disables VR
  79134. *
  79135. * @param element html element to detach from
  79136. */
  79137. detachControl(element: HTMLElement): void;
  79138. /**
  79139. * @returns the name of this class
  79140. */
  79141. getClassName(): string;
  79142. /**
  79143. * Calls resetPose on the vrDisplay
  79144. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  79145. */
  79146. resetToCurrentRotation(): void;
  79147. /**
  79148. * @hidden
  79149. * Updates the rig cameras (left and right eye)
  79150. */
  79151. _updateRigCameras(): void;
  79152. private _workingVector;
  79153. private _oneVector;
  79154. private _workingMatrix;
  79155. private updateCacheCalled;
  79156. private _correctPositionIfNotTrackPosition;
  79157. /**
  79158. * @hidden
  79159. * Updates the cached values of the camera
  79160. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  79161. */
  79162. _updateCache(ignoreParentClass?: boolean): void;
  79163. /**
  79164. * @hidden
  79165. * Get current device position in babylon world
  79166. */
  79167. _computeDevicePosition(): void;
  79168. /**
  79169. * Updates the current device position and rotation in the babylon world
  79170. */
  79171. update(): void;
  79172. /**
  79173. * @hidden
  79174. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  79175. * @returns an identity matrix
  79176. */
  79177. _getViewMatrix(): Matrix;
  79178. private _tmpMatrix;
  79179. /**
  79180. * This function is called by the two RIG cameras.
  79181. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  79182. * @hidden
  79183. */
  79184. _getWebVRViewMatrix(): Matrix;
  79185. /** @hidden */
  79186. _getWebVRProjectionMatrix(): Matrix;
  79187. private _onGamepadConnectedObserver;
  79188. private _onGamepadDisconnectedObserver;
  79189. private _updateCacheWhenTrackingDisabledObserver;
  79190. /**
  79191. * Initializes the controllers and their meshes
  79192. */
  79193. initControllers(): void;
  79194. }
  79195. }
  79196. declare module BABYLON {
  79197. /**
  79198. * Size options for a post process
  79199. */
  79200. export type PostProcessOptions = {
  79201. width: number;
  79202. height: number;
  79203. };
  79204. /**
  79205. * PostProcess can be used to apply a shader to a texture after it has been rendered
  79206. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79207. */
  79208. export class PostProcess {
  79209. /** Name of the PostProcess. */
  79210. name: string;
  79211. /**
  79212. * Gets or sets the unique id of the post process
  79213. */
  79214. uniqueId: number;
  79215. /**
  79216. * Width of the texture to apply the post process on
  79217. */
  79218. width: number;
  79219. /**
  79220. * Height of the texture to apply the post process on
  79221. */
  79222. height: number;
  79223. /**
  79224. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  79225. * @hidden
  79226. */
  79227. _outputTexture: Nullable<InternalTexture>;
  79228. /**
  79229. * Sampling mode used by the shader
  79230. * See https://doc.babylonjs.com/classes/3.1/texture
  79231. */
  79232. renderTargetSamplingMode: number;
  79233. /**
  79234. * Clear color to use when screen clearing
  79235. */
  79236. clearColor: Color4;
  79237. /**
  79238. * If the buffer needs to be cleared before applying the post process. (default: true)
  79239. * Should be set to false if shader will overwrite all previous pixels.
  79240. */
  79241. autoClear: boolean;
  79242. /**
  79243. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  79244. */
  79245. alphaMode: number;
  79246. /**
  79247. * Sets the setAlphaBlendConstants of the babylon engine
  79248. */
  79249. alphaConstants: Color4;
  79250. /**
  79251. * Animations to be used for the post processing
  79252. */
  79253. animations: Animation[];
  79254. /**
  79255. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  79256. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  79257. */
  79258. enablePixelPerfectMode: boolean;
  79259. /**
  79260. * Force the postprocess to be applied without taking in account viewport
  79261. */
  79262. forceFullscreenViewport: boolean;
  79263. /**
  79264. * List of inspectable custom properties (used by the Inspector)
  79265. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79266. */
  79267. inspectableCustomProperties: IInspectable[];
  79268. /**
  79269. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  79270. *
  79271. * | Value | Type | Description |
  79272. * | ----- | ----------------------------------- | ----------- |
  79273. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  79274. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  79275. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  79276. *
  79277. */
  79278. scaleMode: number;
  79279. /**
  79280. * Force textures to be a power of two (default: false)
  79281. */
  79282. alwaysForcePOT: boolean;
  79283. private _samples;
  79284. /**
  79285. * Number of sample textures (default: 1)
  79286. */
  79287. samples: number;
  79288. /**
  79289. * Modify the scale of the post process to be the same as the viewport (default: false)
  79290. */
  79291. adaptScaleToCurrentViewport: boolean;
  79292. private _camera;
  79293. private _scene;
  79294. private _engine;
  79295. private _options;
  79296. private _reusable;
  79297. private _textureType;
  79298. /**
  79299. * Smart array of input and output textures for the post process.
  79300. * @hidden
  79301. */
  79302. _textures: SmartArray<InternalTexture>;
  79303. /**
  79304. * The index in _textures that corresponds to the output texture.
  79305. * @hidden
  79306. */
  79307. _currentRenderTextureInd: number;
  79308. private _effect;
  79309. private _samplers;
  79310. private _fragmentUrl;
  79311. private _vertexUrl;
  79312. private _parameters;
  79313. private _scaleRatio;
  79314. protected _indexParameters: any;
  79315. private _shareOutputWithPostProcess;
  79316. private _texelSize;
  79317. private _forcedOutputTexture;
  79318. /**
  79319. * Returns the fragment url or shader name used in the post process.
  79320. * @returns the fragment url or name in the shader store.
  79321. */
  79322. getEffectName(): string;
  79323. /**
  79324. * An event triggered when the postprocess is activated.
  79325. */
  79326. onActivateObservable: Observable<Camera>;
  79327. private _onActivateObserver;
  79328. /**
  79329. * A function that is added to the onActivateObservable
  79330. */
  79331. onActivate: Nullable<(camera: Camera) => void>;
  79332. /**
  79333. * An event triggered when the postprocess changes its size.
  79334. */
  79335. onSizeChangedObservable: Observable<PostProcess>;
  79336. private _onSizeChangedObserver;
  79337. /**
  79338. * A function that is added to the onSizeChangedObservable
  79339. */
  79340. onSizeChanged: (postProcess: PostProcess) => void;
  79341. /**
  79342. * An event triggered when the postprocess applies its effect.
  79343. */
  79344. onApplyObservable: Observable<Effect>;
  79345. private _onApplyObserver;
  79346. /**
  79347. * A function that is added to the onApplyObservable
  79348. */
  79349. onApply: (effect: Effect) => void;
  79350. /**
  79351. * An event triggered before rendering the postprocess
  79352. */
  79353. onBeforeRenderObservable: Observable<Effect>;
  79354. private _onBeforeRenderObserver;
  79355. /**
  79356. * A function that is added to the onBeforeRenderObservable
  79357. */
  79358. onBeforeRender: (effect: Effect) => void;
  79359. /**
  79360. * An event triggered after rendering the postprocess
  79361. */
  79362. onAfterRenderObservable: Observable<Effect>;
  79363. private _onAfterRenderObserver;
  79364. /**
  79365. * A function that is added to the onAfterRenderObservable
  79366. */
  79367. onAfterRender: (efect: Effect) => void;
  79368. /**
  79369. * 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
  79370. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79371. */
  79372. inputTexture: InternalTexture;
  79373. /**
  79374. * Gets the camera which post process is applied to.
  79375. * @returns The camera the post process is applied to.
  79376. */
  79377. getCamera(): Camera;
  79378. /**
  79379. * Gets the texel size of the postprocess.
  79380. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79381. */
  79382. readonly texelSize: Vector2;
  79383. /**
  79384. * Creates a new instance PostProcess
  79385. * @param name The name of the PostProcess.
  79386. * @param fragmentUrl The url of the fragment shader to be used.
  79387. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79388. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79389. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79390. * @param camera The camera to apply the render pass to.
  79391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79392. * @param engine The engine which the post process will be applied. (default: current engine)
  79393. * @param reusable If the post process can be reused on the same frame. (default: false)
  79394. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79395. * @param textureType Type of textures used when performing the post process. (default: 0)
  79396. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79397. * @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
  79398. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79399. */
  79400. constructor(
  79401. /** Name of the PostProcess. */
  79402. 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);
  79403. /**
  79404. * Gets a string idenfifying the name of the class
  79405. * @returns "PostProcess" string
  79406. */
  79407. getClassName(): string;
  79408. /**
  79409. * Gets the engine which this post process belongs to.
  79410. * @returns The engine the post process was enabled with.
  79411. */
  79412. getEngine(): Engine;
  79413. /**
  79414. * The effect that is created when initializing the post process.
  79415. * @returns The created effect corresponding the the postprocess.
  79416. */
  79417. getEffect(): Effect;
  79418. /**
  79419. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79420. * @param postProcess The post process to share the output with.
  79421. * @returns This post process.
  79422. */
  79423. shareOutputWith(postProcess: PostProcess): PostProcess;
  79424. /**
  79425. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79426. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79427. */
  79428. useOwnOutput(): void;
  79429. /**
  79430. * Updates the effect with the current post process compile time values and recompiles the shader.
  79431. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79432. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79433. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79434. * @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
  79435. * @param onCompiled Called when the shader has been compiled.
  79436. * @param onError Called if there is an error when compiling a shader.
  79437. */
  79438. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79439. /**
  79440. * The post process is reusable if it can be used multiple times within one frame.
  79441. * @returns If the post process is reusable
  79442. */
  79443. isReusable(): boolean;
  79444. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79445. markTextureDirty(): void;
  79446. /**
  79447. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79448. * 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.
  79449. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79450. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79451. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79452. * @returns The target texture that was bound to be written to.
  79453. */
  79454. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79455. /**
  79456. * If the post process is supported.
  79457. */
  79458. readonly isSupported: boolean;
  79459. /**
  79460. * The aspect ratio of the output texture.
  79461. */
  79462. readonly aspectRatio: number;
  79463. /**
  79464. * Get a value indicating if the post-process is ready to be used
  79465. * @returns true if the post-process is ready (shader is compiled)
  79466. */
  79467. isReady(): boolean;
  79468. /**
  79469. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79470. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79471. */
  79472. apply(): Nullable<Effect>;
  79473. private _disposeTextures;
  79474. /**
  79475. * Disposes the post process.
  79476. * @param camera The camera to dispose the post process on.
  79477. */
  79478. dispose(camera?: Camera): void;
  79479. }
  79480. }
  79481. declare module BABYLON {
  79482. /** @hidden */
  79483. export var kernelBlurVaryingDeclaration: {
  79484. name: string;
  79485. shader: string;
  79486. };
  79487. }
  79488. declare module BABYLON {
  79489. /** @hidden */
  79490. export var kernelBlurFragment: {
  79491. name: string;
  79492. shader: string;
  79493. };
  79494. }
  79495. declare module BABYLON {
  79496. /** @hidden */
  79497. export var kernelBlurFragment2: {
  79498. name: string;
  79499. shader: string;
  79500. };
  79501. }
  79502. declare module BABYLON {
  79503. /** @hidden */
  79504. export var kernelBlurPixelShader: {
  79505. name: string;
  79506. shader: string;
  79507. };
  79508. }
  79509. declare module BABYLON {
  79510. /** @hidden */
  79511. export var kernelBlurVertex: {
  79512. name: string;
  79513. shader: string;
  79514. };
  79515. }
  79516. declare module BABYLON {
  79517. /** @hidden */
  79518. export var kernelBlurVertexShader: {
  79519. name: string;
  79520. shader: string;
  79521. };
  79522. }
  79523. declare module BABYLON {
  79524. /**
  79525. * The Blur Post Process which blurs an image based on a kernel and direction.
  79526. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79527. */
  79528. export class BlurPostProcess extends PostProcess {
  79529. /** The direction in which to blur the image. */
  79530. direction: Vector2;
  79531. private blockCompilation;
  79532. protected _kernel: number;
  79533. protected _idealKernel: number;
  79534. protected _packedFloat: boolean;
  79535. private _staticDefines;
  79536. /**
  79537. * Sets the length in pixels of the blur sample region
  79538. */
  79539. /**
  79540. * Gets the length in pixels of the blur sample region
  79541. */
  79542. kernel: number;
  79543. /**
  79544. * Sets wether or not the blur needs to unpack/repack floats
  79545. */
  79546. /**
  79547. * Gets wether or not the blur is unpacking/repacking floats
  79548. */
  79549. packedFloat: boolean;
  79550. /**
  79551. * Creates a new instance BlurPostProcess
  79552. * @param name The name of the effect.
  79553. * @param direction The direction in which to blur the image.
  79554. * @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.
  79555. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79556. * @param camera The camera to apply the render pass to.
  79557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79558. * @param engine The engine which the post process will be applied. (default: current engine)
  79559. * @param reusable If the post process can be reused on the same frame. (default: false)
  79560. * @param textureType Type of textures used when performing the post process. (default: 0)
  79561. * @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)
  79562. */
  79563. constructor(name: string,
  79564. /** The direction in which to blur the image. */
  79565. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79566. /**
  79567. * Updates the effect with the current post process compile time values and recompiles the shader.
  79568. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79569. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79570. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79571. * @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
  79572. * @param onCompiled Called when the shader has been compiled.
  79573. * @param onError Called if there is an error when compiling a shader.
  79574. */
  79575. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79576. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79577. /**
  79578. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79579. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79580. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79581. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79582. * The gaps between physical kernels are compensated for in the weighting of the samples
  79583. * @param idealKernel Ideal blur kernel.
  79584. * @return Nearest best kernel.
  79585. */
  79586. protected _nearestBestKernel(idealKernel: number): number;
  79587. /**
  79588. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79589. * @param x The point on the Gaussian distribution to sample.
  79590. * @return the value of the Gaussian function at x.
  79591. */
  79592. protected _gaussianWeight(x: number): number;
  79593. /**
  79594. * Generates a string that can be used as a floating point number in GLSL.
  79595. * @param x Value to print.
  79596. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79597. * @return GLSL float string.
  79598. */
  79599. protected _glslFloat(x: number, decimalFigures?: number): string;
  79600. }
  79601. }
  79602. declare module BABYLON {
  79603. /**
  79604. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79605. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79606. * You can then easily use it as a reflectionTexture on a flat surface.
  79607. * In case the surface is not a plane, please consider relying on reflection probes.
  79608. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79609. */
  79610. export class MirrorTexture extends RenderTargetTexture {
  79611. private scene;
  79612. /**
  79613. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79614. * 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.
  79615. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79616. */
  79617. mirrorPlane: Plane;
  79618. /**
  79619. * Define the blur ratio used to blur the reflection if needed.
  79620. */
  79621. blurRatio: number;
  79622. /**
  79623. * Define the adaptive blur kernel used to blur the reflection if needed.
  79624. * This will autocompute the closest best match for the `blurKernel`
  79625. */
  79626. adaptiveBlurKernel: number;
  79627. /**
  79628. * Define the blur kernel used to blur the reflection if needed.
  79629. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79630. */
  79631. blurKernel: number;
  79632. /**
  79633. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79634. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79635. */
  79636. blurKernelX: number;
  79637. /**
  79638. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79639. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79640. */
  79641. blurKernelY: number;
  79642. private _autoComputeBlurKernel;
  79643. protected _onRatioRescale(): void;
  79644. private _updateGammaSpace;
  79645. private _imageProcessingConfigChangeObserver;
  79646. private _transformMatrix;
  79647. private _mirrorMatrix;
  79648. private _savedViewMatrix;
  79649. private _blurX;
  79650. private _blurY;
  79651. private _adaptiveBlurKernel;
  79652. private _blurKernelX;
  79653. private _blurKernelY;
  79654. private _blurRatio;
  79655. /**
  79656. * Instantiates a Mirror Texture.
  79657. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79658. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79659. * You can then easily use it as a reflectionTexture on a flat surface.
  79660. * In case the surface is not a plane, please consider relying on reflection probes.
  79661. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79662. * @param name
  79663. * @param size
  79664. * @param scene
  79665. * @param generateMipMaps
  79666. * @param type
  79667. * @param samplingMode
  79668. * @param generateDepthBuffer
  79669. */
  79670. constructor(name: string, size: number | {
  79671. width: number;
  79672. height: number;
  79673. } | {
  79674. ratio: number;
  79675. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79676. private _preparePostProcesses;
  79677. /**
  79678. * Clone the mirror texture.
  79679. * @returns the cloned texture
  79680. */
  79681. clone(): MirrorTexture;
  79682. /**
  79683. * Serialize the texture to a JSON representation you could use in Parse later on
  79684. * @returns the serialized JSON representation
  79685. */
  79686. serialize(): any;
  79687. /**
  79688. * Dispose the texture and release its associated resources.
  79689. */
  79690. dispose(): void;
  79691. }
  79692. }
  79693. declare module BABYLON {
  79694. /**
  79695. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79696. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79697. */
  79698. export class Texture extends BaseTexture {
  79699. /** @hidden */
  79700. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79701. /** @hidden */
  79702. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79703. /** @hidden */
  79704. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79705. /** nearest is mag = nearest and min = nearest and mip = linear */
  79706. static readonly NEAREST_SAMPLINGMODE: number;
  79707. /** nearest is mag = nearest and min = nearest and mip = linear */
  79708. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79709. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79710. static readonly BILINEAR_SAMPLINGMODE: number;
  79711. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79712. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79713. /** Trilinear is mag = linear and min = linear and mip = linear */
  79714. static readonly TRILINEAR_SAMPLINGMODE: number;
  79715. /** Trilinear is mag = linear and min = linear and mip = linear */
  79716. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79717. /** mag = nearest and min = nearest and mip = nearest */
  79718. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79719. /** mag = nearest and min = linear and mip = nearest */
  79720. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79721. /** mag = nearest and min = linear and mip = linear */
  79722. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79723. /** mag = nearest and min = linear and mip = none */
  79724. static readonly NEAREST_LINEAR: number;
  79725. /** mag = nearest and min = nearest and mip = none */
  79726. static readonly NEAREST_NEAREST: number;
  79727. /** mag = linear and min = nearest and mip = nearest */
  79728. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79729. /** mag = linear and min = nearest and mip = linear */
  79730. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79731. /** mag = linear and min = linear and mip = none */
  79732. static readonly LINEAR_LINEAR: number;
  79733. /** mag = linear and min = nearest and mip = none */
  79734. static readonly LINEAR_NEAREST: number;
  79735. /** Explicit coordinates mode */
  79736. static readonly EXPLICIT_MODE: number;
  79737. /** Spherical coordinates mode */
  79738. static readonly SPHERICAL_MODE: number;
  79739. /** Planar coordinates mode */
  79740. static readonly PLANAR_MODE: number;
  79741. /** Cubic coordinates mode */
  79742. static readonly CUBIC_MODE: number;
  79743. /** Projection coordinates mode */
  79744. static readonly PROJECTION_MODE: number;
  79745. /** Inverse Cubic coordinates mode */
  79746. static readonly SKYBOX_MODE: number;
  79747. /** Inverse Cubic coordinates mode */
  79748. static readonly INVCUBIC_MODE: number;
  79749. /** Equirectangular coordinates mode */
  79750. static readonly EQUIRECTANGULAR_MODE: number;
  79751. /** Equirectangular Fixed coordinates mode */
  79752. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79753. /** Equirectangular Fixed Mirrored coordinates mode */
  79754. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79755. /** Texture is not repeating outside of 0..1 UVs */
  79756. static readonly CLAMP_ADDRESSMODE: number;
  79757. /** Texture is repeating outside of 0..1 UVs */
  79758. static readonly WRAP_ADDRESSMODE: number;
  79759. /** Texture is repeating and mirrored */
  79760. static readonly MIRROR_ADDRESSMODE: number;
  79761. /**
  79762. * 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
  79763. */
  79764. static UseSerializedUrlIfAny: boolean;
  79765. /**
  79766. * Define the url of the texture.
  79767. */
  79768. url: Nullable<string>;
  79769. /**
  79770. * Define an offset on the texture to offset the u coordinates of the UVs
  79771. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79772. */
  79773. uOffset: number;
  79774. /**
  79775. * Define an offset on the texture to offset the v coordinates of the UVs
  79776. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79777. */
  79778. vOffset: number;
  79779. /**
  79780. * Define an offset on the texture to scale the u coordinates of the UVs
  79781. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79782. */
  79783. uScale: number;
  79784. /**
  79785. * Define an offset on the texture to scale the v coordinates of the UVs
  79786. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79787. */
  79788. vScale: number;
  79789. /**
  79790. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79791. * @see http://doc.babylonjs.com/how_to/more_materials
  79792. */
  79793. uAng: number;
  79794. /**
  79795. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79796. * @see http://doc.babylonjs.com/how_to/more_materials
  79797. */
  79798. vAng: number;
  79799. /**
  79800. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79801. * @see http://doc.babylonjs.com/how_to/more_materials
  79802. */
  79803. wAng: number;
  79804. /**
  79805. * Defines the center of rotation (U)
  79806. */
  79807. uRotationCenter: number;
  79808. /**
  79809. * Defines the center of rotation (V)
  79810. */
  79811. vRotationCenter: number;
  79812. /**
  79813. * Defines the center of rotation (W)
  79814. */
  79815. wRotationCenter: number;
  79816. /**
  79817. * Are mip maps generated for this texture or not.
  79818. */
  79819. readonly noMipmap: boolean;
  79820. /**
  79821. * List of inspectable custom properties (used by the Inspector)
  79822. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79823. */
  79824. inspectableCustomProperties: Nullable<IInspectable[]>;
  79825. private _noMipmap;
  79826. /** @hidden */
  79827. _invertY: boolean;
  79828. private _rowGenerationMatrix;
  79829. private _cachedTextureMatrix;
  79830. private _projectionModeMatrix;
  79831. private _t0;
  79832. private _t1;
  79833. private _t2;
  79834. private _cachedUOffset;
  79835. private _cachedVOffset;
  79836. private _cachedUScale;
  79837. private _cachedVScale;
  79838. private _cachedUAng;
  79839. private _cachedVAng;
  79840. private _cachedWAng;
  79841. private _cachedProjectionMatrixId;
  79842. private _cachedCoordinatesMode;
  79843. /** @hidden */
  79844. protected _initialSamplingMode: number;
  79845. /** @hidden */
  79846. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79847. private _deleteBuffer;
  79848. protected _format: Nullable<number>;
  79849. private _delayedOnLoad;
  79850. private _delayedOnError;
  79851. /**
  79852. * Observable triggered once the texture has been loaded.
  79853. */
  79854. onLoadObservable: Observable<Texture>;
  79855. protected _isBlocking: boolean;
  79856. /**
  79857. * Is the texture preventing material to render while loading.
  79858. * If false, a default texture will be used instead of the loading one during the preparation step.
  79859. */
  79860. isBlocking: boolean;
  79861. /**
  79862. * Get the current sampling mode associated with the texture.
  79863. */
  79864. readonly samplingMode: number;
  79865. /**
  79866. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79867. */
  79868. readonly invertY: boolean;
  79869. /**
  79870. * Instantiates a new texture.
  79871. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79872. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79873. * @param url define the url of the picture to load as a texture
  79874. * @param scene define the scene or engine the texture will belong to
  79875. * @param noMipmap define if the texture will require mip maps or not
  79876. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79877. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79878. * @param onLoad define a callback triggered when the texture has been loaded
  79879. * @param onError define a callback triggered when an error occurred during the loading session
  79880. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79881. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79882. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79883. */
  79884. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, 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);
  79885. /**
  79886. * Update the url (and optional buffer) of this texture if url was null during construction.
  79887. * @param url the url of the texture
  79888. * @param buffer the buffer of the texture (defaults to null)
  79889. * @param onLoad callback called when the texture is loaded (defaults to null)
  79890. */
  79891. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79892. /**
  79893. * Finish the loading sequence of a texture flagged as delayed load.
  79894. * @hidden
  79895. */
  79896. delayLoad(): void;
  79897. private _prepareRowForTextureGeneration;
  79898. /**
  79899. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79900. * @returns the transform matrix of the texture.
  79901. */
  79902. getTextureMatrix(): Matrix;
  79903. /**
  79904. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79905. * @returns The reflection texture transform
  79906. */
  79907. getReflectionTextureMatrix(): Matrix;
  79908. /**
  79909. * Clones the texture.
  79910. * @returns the cloned texture
  79911. */
  79912. clone(): Texture;
  79913. /**
  79914. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79915. * @returns The JSON representation of the texture
  79916. */
  79917. serialize(): any;
  79918. /**
  79919. * Get the current class name of the texture useful for serialization or dynamic coding.
  79920. * @returns "Texture"
  79921. */
  79922. getClassName(): string;
  79923. /**
  79924. * Dispose the texture and release its associated resources.
  79925. */
  79926. dispose(): void;
  79927. /**
  79928. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79929. * @param parsedTexture Define the JSON representation of the texture
  79930. * @param scene Define the scene the parsed texture should be instantiated in
  79931. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79932. * @returns The parsed texture if successful
  79933. */
  79934. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79935. /**
  79936. * Creates a texture from its base 64 representation.
  79937. * @param data Define the base64 payload without the data: prefix
  79938. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79939. * @param scene Define the scene the texture should belong to
  79940. * @param noMipmap Forces the texture to not create mip map information if true
  79941. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79942. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79943. * @param onLoad define a callback triggered when the texture has been loaded
  79944. * @param onError define a callback triggered when an error occurred during the loading session
  79945. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79946. * @returns the created texture
  79947. */
  79948. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79949. /**
  79950. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79951. * @param data Define the base64 payload without the data: prefix
  79952. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79953. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79954. * @param scene Define the scene the texture should belong to
  79955. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79956. * @param noMipmap Forces the texture to not create mip map information if true
  79957. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79958. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79959. * @param onLoad define a callback triggered when the texture has been loaded
  79960. * @param onError define a callback triggered when an error occurred during the loading session
  79961. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79962. * @returns the created texture
  79963. */
  79964. 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;
  79965. }
  79966. }
  79967. declare module BABYLON {
  79968. /**
  79969. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79970. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79971. */
  79972. export class PostProcessManager {
  79973. private _scene;
  79974. private _indexBuffer;
  79975. private _vertexBuffers;
  79976. /**
  79977. * Creates a new instance PostProcess
  79978. * @param scene The scene that the post process is associated with.
  79979. */
  79980. constructor(scene: Scene);
  79981. private _prepareBuffers;
  79982. private _buildIndexBuffer;
  79983. /**
  79984. * Rebuilds the vertex buffers of the manager.
  79985. * @hidden
  79986. */
  79987. _rebuild(): void;
  79988. /**
  79989. * Prepares a frame to be run through a post process.
  79990. * @param sourceTexture The input texture to the post procesess. (default: null)
  79991. * @param postProcesses An array of post processes to be run. (default: null)
  79992. * @returns True if the post processes were able to be run.
  79993. * @hidden
  79994. */
  79995. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79996. /**
  79997. * Manually render a set of post processes to a texture.
  79998. * @param postProcesses An array of post processes to be run.
  79999. * @param targetTexture The target texture to render to.
  80000. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  80001. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  80002. * @param lodLevel defines which lod of the texture to render to
  80003. */
  80004. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  80005. /**
  80006. * Finalize the result of the output of the postprocesses.
  80007. * @param doNotPresent If true the result will not be displayed to the screen.
  80008. * @param targetTexture The target texture to render to.
  80009. * @param faceIndex The index of the face to bind the target texture to.
  80010. * @param postProcesses The array of post processes to render.
  80011. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  80012. * @hidden
  80013. */
  80014. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  80015. /**
  80016. * Disposes of the post process manager.
  80017. */
  80018. dispose(): void;
  80019. }
  80020. }
  80021. declare module BABYLON {
  80022. /** Interface used by value gradients (color, factor, ...) */
  80023. export interface IValueGradient {
  80024. /**
  80025. * Gets or sets the gradient value (between 0 and 1)
  80026. */
  80027. gradient: number;
  80028. }
  80029. /** Class used to store color4 gradient */
  80030. export class ColorGradient implements IValueGradient {
  80031. /**
  80032. * Gets or sets the gradient value (between 0 and 1)
  80033. */
  80034. gradient: number;
  80035. /**
  80036. * Gets or sets first associated color
  80037. */
  80038. color1: Color4;
  80039. /**
  80040. * Gets or sets second associated color
  80041. */
  80042. color2?: Color4;
  80043. /**
  80044. * Will get a color picked randomly between color1 and color2.
  80045. * If color2 is undefined then color1 will be used
  80046. * @param result defines the target Color4 to store the result in
  80047. */
  80048. getColorToRef(result: Color4): void;
  80049. }
  80050. /** Class used to store color 3 gradient */
  80051. export class Color3Gradient implements IValueGradient {
  80052. /**
  80053. * Gets or sets the gradient value (between 0 and 1)
  80054. */
  80055. gradient: number;
  80056. /**
  80057. * Gets or sets the associated color
  80058. */
  80059. color: Color3;
  80060. }
  80061. /** Class used to store factor gradient */
  80062. export class FactorGradient implements IValueGradient {
  80063. /**
  80064. * Gets or sets the gradient value (between 0 and 1)
  80065. */
  80066. gradient: number;
  80067. /**
  80068. * Gets or sets first associated factor
  80069. */
  80070. factor1: number;
  80071. /**
  80072. * Gets or sets second associated factor
  80073. */
  80074. factor2?: number;
  80075. /**
  80076. * Will get a number picked randomly between factor1 and factor2.
  80077. * If factor2 is undefined then factor1 will be used
  80078. * @returns the picked number
  80079. */
  80080. getFactor(): number;
  80081. }
  80082. /**
  80083. * Helper used to simplify some generic gradient tasks
  80084. */
  80085. export class GradientHelper {
  80086. /**
  80087. * Gets the current gradient from an array of IValueGradient
  80088. * @param ratio defines the current ratio to get
  80089. * @param gradients defines the array of IValueGradient
  80090. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  80091. */
  80092. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  80093. }
  80094. }
  80095. declare module BABYLON {
  80096. interface AbstractScene {
  80097. /**
  80098. * The list of procedural textures added to the scene
  80099. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80100. */
  80101. proceduralTextures: Array<ProceduralTexture>;
  80102. }
  80103. /**
  80104. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  80105. * in a given scene.
  80106. */
  80107. export class ProceduralTextureSceneComponent implements ISceneComponent {
  80108. /**
  80109. * The component name helpfull to identify the component in the list of scene components.
  80110. */
  80111. readonly name: string;
  80112. /**
  80113. * The scene the component belongs to.
  80114. */
  80115. scene: Scene;
  80116. /**
  80117. * Creates a new instance of the component for the given scene
  80118. * @param scene Defines the scene to register the component in
  80119. */
  80120. constructor(scene: Scene);
  80121. /**
  80122. * Registers the component in a given scene
  80123. */
  80124. register(): void;
  80125. /**
  80126. * Rebuilds the elements related to this component in case of
  80127. * context lost for instance.
  80128. */
  80129. rebuild(): void;
  80130. /**
  80131. * Disposes the component and the associated ressources.
  80132. */
  80133. dispose(): void;
  80134. private _beforeClear;
  80135. }
  80136. }
  80137. declare module BABYLON {
  80138. interface Engine {
  80139. /**
  80140. * Creates a new render target cube texture
  80141. * @param size defines the size of the texture
  80142. * @param options defines the options used to create the texture
  80143. * @returns a new render target cube texture stored in an InternalTexture
  80144. */
  80145. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  80146. }
  80147. }
  80148. declare module BABYLON {
  80149. /** @hidden */
  80150. export var proceduralVertexShader: {
  80151. name: string;
  80152. shader: string;
  80153. };
  80154. }
  80155. declare module BABYLON {
  80156. /**
  80157. * 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.
  80158. * This is the base class of any Procedural texture and contains most of the shareable code.
  80159. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80160. */
  80161. export class ProceduralTexture extends Texture {
  80162. isCube: boolean;
  80163. /**
  80164. * Define if the texture is enabled or not (disabled texture will not render)
  80165. */
  80166. isEnabled: boolean;
  80167. /**
  80168. * Define if the texture must be cleared before rendering (default is true)
  80169. */
  80170. autoClear: boolean;
  80171. /**
  80172. * Callback called when the texture is generated
  80173. */
  80174. onGenerated: () => void;
  80175. /**
  80176. * Event raised when the texture is generated
  80177. */
  80178. onGeneratedObservable: Observable<ProceduralTexture>;
  80179. /** @hidden */
  80180. _generateMipMaps: boolean;
  80181. /** @hidden **/
  80182. _effect: Effect;
  80183. /** @hidden */
  80184. _textures: {
  80185. [key: string]: Texture;
  80186. };
  80187. private _size;
  80188. private _currentRefreshId;
  80189. private _refreshRate;
  80190. private _vertexBuffers;
  80191. private _indexBuffer;
  80192. private _uniforms;
  80193. private _samplers;
  80194. private _fragment;
  80195. private _floats;
  80196. private _ints;
  80197. private _floatsArrays;
  80198. private _colors3;
  80199. private _colors4;
  80200. private _vectors2;
  80201. private _vectors3;
  80202. private _matrices;
  80203. private _fallbackTexture;
  80204. private _fallbackTextureUsed;
  80205. private _engine;
  80206. private _cachedDefines;
  80207. private _contentUpdateId;
  80208. private _contentData;
  80209. /**
  80210. * Instantiates a new procedural texture.
  80211. * 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.
  80212. * This is the base class of any Procedural texture and contains most of the shareable code.
  80213. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  80214. * @param name Define the name of the texture
  80215. * @param size Define the size of the texture to create
  80216. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  80217. * @param scene Define the scene the texture belongs to
  80218. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  80219. * @param generateMipMaps Define if the texture should creates mip maps or not
  80220. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  80221. */
  80222. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  80223. /**
  80224. * The effect that is created when initializing the post process.
  80225. * @returns The created effect corresponding the the postprocess.
  80226. */
  80227. getEffect(): Effect;
  80228. /**
  80229. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  80230. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  80231. */
  80232. getContent(): Nullable<ArrayBufferView>;
  80233. private _createIndexBuffer;
  80234. /** @hidden */
  80235. _rebuild(): void;
  80236. /**
  80237. * Resets the texture in order to recreate its associated resources.
  80238. * This can be called in case of context loss
  80239. */
  80240. reset(): void;
  80241. protected _getDefines(): string;
  80242. /**
  80243. * Is the texture ready to be used ? (rendered at least once)
  80244. * @returns true if ready, otherwise, false.
  80245. */
  80246. isReady(): boolean;
  80247. /**
  80248. * Resets the refresh counter of the texture and start bak from scratch.
  80249. * Could be useful to regenerate the texture if it is setup to render only once.
  80250. */
  80251. resetRefreshCounter(): void;
  80252. /**
  80253. * Set the fragment shader to use in order to render the texture.
  80254. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  80255. */
  80256. setFragment(fragment: any): void;
  80257. /**
  80258. * Define the refresh rate of the texture or the rendering frequency.
  80259. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80260. */
  80261. refreshRate: number;
  80262. /** @hidden */
  80263. _shouldRender(): boolean;
  80264. /**
  80265. * Get the size the texture is rendering at.
  80266. * @returns the size (texture is always squared)
  80267. */
  80268. getRenderSize(): number;
  80269. /**
  80270. * Resize the texture to new value.
  80271. * @param size Define the new size the texture should have
  80272. * @param generateMipMaps Define whether the new texture should create mip maps
  80273. */
  80274. resize(size: number, generateMipMaps: boolean): void;
  80275. private _checkUniform;
  80276. /**
  80277. * Set a texture in the shader program used to render.
  80278. * @param name Define the name of the uniform samplers as defined in the shader
  80279. * @param texture Define the texture to bind to this sampler
  80280. * @return the texture itself allowing "fluent" like uniform updates
  80281. */
  80282. setTexture(name: string, texture: Texture): ProceduralTexture;
  80283. /**
  80284. * Set a float in the shader.
  80285. * @param name Define the name of the uniform as defined in the shader
  80286. * @param value Define the value to give to the uniform
  80287. * @return the texture itself allowing "fluent" like uniform updates
  80288. */
  80289. setFloat(name: string, value: number): ProceduralTexture;
  80290. /**
  80291. * Set a int in the shader.
  80292. * @param name Define the name of the uniform as defined in the shader
  80293. * @param value Define the value to give to the uniform
  80294. * @return the texture itself allowing "fluent" like uniform updates
  80295. */
  80296. setInt(name: string, value: number): ProceduralTexture;
  80297. /**
  80298. * Set an array of floats in the shader.
  80299. * @param name Define the name of the uniform as defined in the shader
  80300. * @param value Define the value to give to the uniform
  80301. * @return the texture itself allowing "fluent" like uniform updates
  80302. */
  80303. setFloats(name: string, value: number[]): ProceduralTexture;
  80304. /**
  80305. * Set a vec3 in the shader from a Color3.
  80306. * @param name Define the name of the uniform as defined in the shader
  80307. * @param value Define the value to give to the uniform
  80308. * @return the texture itself allowing "fluent" like uniform updates
  80309. */
  80310. setColor3(name: string, value: Color3): ProceduralTexture;
  80311. /**
  80312. * Set a vec4 in the shader from a Color4.
  80313. * @param name Define the name of the uniform as defined in the shader
  80314. * @param value Define the value to give to the uniform
  80315. * @return the texture itself allowing "fluent" like uniform updates
  80316. */
  80317. setColor4(name: string, value: Color4): ProceduralTexture;
  80318. /**
  80319. * Set a vec2 in the shader from a Vector2.
  80320. * @param name Define the name of the uniform as defined in the shader
  80321. * @param value Define the value to give to the uniform
  80322. * @return the texture itself allowing "fluent" like uniform updates
  80323. */
  80324. setVector2(name: string, value: Vector2): ProceduralTexture;
  80325. /**
  80326. * Set a vec3 in the shader from a Vector3.
  80327. * @param name Define the name of the uniform as defined in the shader
  80328. * @param value Define the value to give to the uniform
  80329. * @return the texture itself allowing "fluent" like uniform updates
  80330. */
  80331. setVector3(name: string, value: Vector3): ProceduralTexture;
  80332. /**
  80333. * Set a mat4 in the shader from a MAtrix.
  80334. * @param name Define the name of the uniform as defined in the shader
  80335. * @param value Define the value to give to the uniform
  80336. * @return the texture itself allowing "fluent" like uniform updates
  80337. */
  80338. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80339. /**
  80340. * Render the texture to its associated render target.
  80341. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80342. */
  80343. render(useCameraPostProcess?: boolean): void;
  80344. /**
  80345. * Clone the texture.
  80346. * @returns the cloned texture
  80347. */
  80348. clone(): ProceduralTexture;
  80349. /**
  80350. * Dispose the texture and release its asoociated resources.
  80351. */
  80352. dispose(): void;
  80353. }
  80354. }
  80355. declare module BABYLON {
  80356. /**
  80357. * This represents the base class for particle system in Babylon.
  80358. * 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.
  80359. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80360. * @example https://doc.babylonjs.com/babylon101/particles
  80361. */
  80362. export class BaseParticleSystem {
  80363. /**
  80364. * Source color is added to the destination color without alpha affecting the result
  80365. */
  80366. static BLENDMODE_ONEONE: number;
  80367. /**
  80368. * Blend current color and particle color using particle’s alpha
  80369. */
  80370. static BLENDMODE_STANDARD: number;
  80371. /**
  80372. * Add current color and particle color multiplied by particle’s alpha
  80373. */
  80374. static BLENDMODE_ADD: number;
  80375. /**
  80376. * Multiply current color with particle color
  80377. */
  80378. static BLENDMODE_MULTIPLY: number;
  80379. /**
  80380. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80381. */
  80382. static BLENDMODE_MULTIPLYADD: number;
  80383. /**
  80384. * List of animations used by the particle system.
  80385. */
  80386. animations: Animation[];
  80387. /**
  80388. * The id of the Particle system.
  80389. */
  80390. id: string;
  80391. /**
  80392. * The friendly name of the Particle system.
  80393. */
  80394. name: string;
  80395. /**
  80396. * The rendering group used by the Particle system to chose when to render.
  80397. */
  80398. renderingGroupId: number;
  80399. /**
  80400. * The emitter represents the Mesh or position we are attaching the particle system to.
  80401. */
  80402. emitter: Nullable<AbstractMesh | Vector3>;
  80403. /**
  80404. * The maximum number of particles to emit per frame
  80405. */
  80406. emitRate: number;
  80407. /**
  80408. * If you want to launch only a few particles at once, that can be done, as well.
  80409. */
  80410. manualEmitCount: number;
  80411. /**
  80412. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80413. */
  80414. updateSpeed: number;
  80415. /**
  80416. * The amount of time the particle system is running (depends of the overall update speed).
  80417. */
  80418. targetStopDuration: number;
  80419. /**
  80420. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80421. */
  80422. disposeOnStop: boolean;
  80423. /**
  80424. * Minimum power of emitting particles.
  80425. */
  80426. minEmitPower: number;
  80427. /**
  80428. * Maximum power of emitting particles.
  80429. */
  80430. maxEmitPower: number;
  80431. /**
  80432. * Minimum life time of emitting particles.
  80433. */
  80434. minLifeTime: number;
  80435. /**
  80436. * Maximum life time of emitting particles.
  80437. */
  80438. maxLifeTime: number;
  80439. /**
  80440. * Minimum Size of emitting particles.
  80441. */
  80442. minSize: number;
  80443. /**
  80444. * Maximum Size of emitting particles.
  80445. */
  80446. maxSize: number;
  80447. /**
  80448. * Minimum scale of emitting particles on X axis.
  80449. */
  80450. minScaleX: number;
  80451. /**
  80452. * Maximum scale of emitting particles on X axis.
  80453. */
  80454. maxScaleX: number;
  80455. /**
  80456. * Minimum scale of emitting particles on Y axis.
  80457. */
  80458. minScaleY: number;
  80459. /**
  80460. * Maximum scale of emitting particles on Y axis.
  80461. */
  80462. maxScaleY: number;
  80463. /**
  80464. * Gets or sets the minimal initial rotation in radians.
  80465. */
  80466. minInitialRotation: number;
  80467. /**
  80468. * Gets or sets the maximal initial rotation in radians.
  80469. */
  80470. maxInitialRotation: number;
  80471. /**
  80472. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80473. */
  80474. minAngularSpeed: number;
  80475. /**
  80476. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80477. */
  80478. maxAngularSpeed: number;
  80479. /**
  80480. * The texture used to render each particle. (this can be a spritesheet)
  80481. */
  80482. particleTexture: Nullable<Texture>;
  80483. /**
  80484. * The layer mask we are rendering the particles through.
  80485. */
  80486. layerMask: number;
  80487. /**
  80488. * This can help using your own shader to render the particle system.
  80489. * The according effect will be created
  80490. */
  80491. customShader: any;
  80492. /**
  80493. * By default particle system starts as soon as they are created. This prevents the
  80494. * automatic start to happen and let you decide when to start emitting particles.
  80495. */
  80496. preventAutoStart: boolean;
  80497. private _noiseTexture;
  80498. /**
  80499. * Gets or sets a texture used to add random noise to particle positions
  80500. */
  80501. noiseTexture: Nullable<ProceduralTexture>;
  80502. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80503. noiseStrength: Vector3;
  80504. /**
  80505. * Callback triggered when the particle animation is ending.
  80506. */
  80507. onAnimationEnd: Nullable<() => void>;
  80508. /**
  80509. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80510. */
  80511. blendMode: number;
  80512. /**
  80513. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80514. * to override the particles.
  80515. */
  80516. forceDepthWrite: boolean;
  80517. /** 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 */
  80518. preWarmCycles: number;
  80519. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80520. preWarmStepOffset: number;
  80521. /**
  80522. * 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)
  80523. */
  80524. spriteCellChangeSpeed: number;
  80525. /**
  80526. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80527. */
  80528. startSpriteCellID: number;
  80529. /**
  80530. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80531. */
  80532. endSpriteCellID: number;
  80533. /**
  80534. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80535. */
  80536. spriteCellWidth: number;
  80537. /**
  80538. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80539. */
  80540. spriteCellHeight: number;
  80541. /**
  80542. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80543. */
  80544. spriteRandomStartCell: boolean;
  80545. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80546. translationPivot: Vector2;
  80547. /** @hidden */
  80548. protected _isAnimationSheetEnabled: boolean;
  80549. /**
  80550. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80551. */
  80552. beginAnimationOnStart: boolean;
  80553. /**
  80554. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80555. */
  80556. beginAnimationFrom: number;
  80557. /**
  80558. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80559. */
  80560. beginAnimationTo: number;
  80561. /**
  80562. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80563. */
  80564. beginAnimationLoop: boolean;
  80565. /**
  80566. * Gets or sets a world offset applied to all particles
  80567. */
  80568. worldOffset: Vector3;
  80569. /**
  80570. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80571. */
  80572. isAnimationSheetEnabled: boolean;
  80573. /**
  80574. * Get hosting scene
  80575. * @returns the scene
  80576. */
  80577. getScene(): Scene;
  80578. /**
  80579. * You can use gravity if you want to give an orientation to your particles.
  80580. */
  80581. gravity: Vector3;
  80582. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80583. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80584. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80585. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80586. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80587. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80588. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80589. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80590. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80591. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80592. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80593. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80594. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80595. /**
  80596. * Defines the delay in milliseconds before starting the system (0 by default)
  80597. */
  80598. startDelay: number;
  80599. /**
  80600. * Gets the current list of drag gradients.
  80601. * You must use addDragGradient and removeDragGradient to udpate this list
  80602. * @returns the list of drag gradients
  80603. */
  80604. getDragGradients(): Nullable<Array<FactorGradient>>;
  80605. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80606. limitVelocityDamping: number;
  80607. /**
  80608. * Gets the current list of limit velocity gradients.
  80609. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80610. * @returns the list of limit velocity gradients
  80611. */
  80612. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80613. /**
  80614. * Gets the current list of color gradients.
  80615. * You must use addColorGradient and removeColorGradient to udpate this list
  80616. * @returns the list of color gradients
  80617. */
  80618. getColorGradients(): Nullable<Array<ColorGradient>>;
  80619. /**
  80620. * Gets the current list of size gradients.
  80621. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80622. * @returns the list of size gradients
  80623. */
  80624. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80625. /**
  80626. * Gets the current list of color remap gradients.
  80627. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80628. * @returns the list of color remap gradients
  80629. */
  80630. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80631. /**
  80632. * Gets the current list of alpha remap gradients.
  80633. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80634. * @returns the list of alpha remap gradients
  80635. */
  80636. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80637. /**
  80638. * Gets the current list of life time gradients.
  80639. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80640. * @returns the list of life time gradients
  80641. */
  80642. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80643. /**
  80644. * Gets the current list of angular speed gradients.
  80645. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80646. * @returns the list of angular speed gradients
  80647. */
  80648. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80649. /**
  80650. * Gets the current list of velocity gradients.
  80651. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80652. * @returns the list of velocity gradients
  80653. */
  80654. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80655. /**
  80656. * Gets the current list of start size gradients.
  80657. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80658. * @returns the list of start size gradients
  80659. */
  80660. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80661. /**
  80662. * Gets the current list of emit rate gradients.
  80663. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80664. * @returns the list of emit rate gradients
  80665. */
  80666. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80667. /**
  80668. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80669. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80670. */
  80671. direction1: Vector3;
  80672. /**
  80673. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80674. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80675. */
  80676. direction2: Vector3;
  80677. /**
  80678. * 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.
  80679. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80680. */
  80681. minEmitBox: Vector3;
  80682. /**
  80683. * 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.
  80684. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80685. */
  80686. maxEmitBox: Vector3;
  80687. /**
  80688. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80689. */
  80690. color1: Color4;
  80691. /**
  80692. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80693. */
  80694. color2: Color4;
  80695. /**
  80696. * Color the particle will have at the end of its lifetime
  80697. */
  80698. colorDead: Color4;
  80699. /**
  80700. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80701. */
  80702. textureMask: Color4;
  80703. /**
  80704. * The particle emitter type defines the emitter used by the particle system.
  80705. * It can be for example box, sphere, or cone...
  80706. */
  80707. particleEmitterType: IParticleEmitterType;
  80708. /** @hidden */
  80709. _isSubEmitter: boolean;
  80710. /**
  80711. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80712. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80713. */
  80714. billboardMode: number;
  80715. protected _isBillboardBased: boolean;
  80716. /**
  80717. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80718. */
  80719. isBillboardBased: boolean;
  80720. /**
  80721. * The scene the particle system belongs to.
  80722. */
  80723. protected _scene: Scene;
  80724. /**
  80725. * Local cache of defines for image processing.
  80726. */
  80727. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80728. /**
  80729. * Default configuration related to image processing available in the standard Material.
  80730. */
  80731. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80732. /**
  80733. * Gets the image processing configuration used either in this material.
  80734. */
  80735. /**
  80736. * Sets the Default image processing configuration used either in the this material.
  80737. *
  80738. * If sets to null, the scene one is in use.
  80739. */
  80740. imageProcessingConfiguration: ImageProcessingConfiguration;
  80741. /**
  80742. * Attaches a new image processing configuration to the Standard Material.
  80743. * @param configuration
  80744. */
  80745. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80746. /** @hidden */
  80747. protected _reset(): void;
  80748. /** @hidden */
  80749. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80750. /**
  80751. * Instantiates a particle system.
  80752. * 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.
  80753. * @param name The name of the particle system
  80754. */
  80755. constructor(name: string);
  80756. /**
  80757. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80758. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80759. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80760. * @returns the emitter
  80761. */
  80762. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80763. /**
  80764. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80765. * @param radius The radius of the hemisphere to emit from
  80766. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80767. * @returns the emitter
  80768. */
  80769. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80770. /**
  80771. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80772. * @param radius The radius of the sphere to emit from
  80773. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80774. * @returns the emitter
  80775. */
  80776. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80777. /**
  80778. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80779. * @param radius The radius of the sphere to emit from
  80780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80782. * @returns the emitter
  80783. */
  80784. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80785. /**
  80786. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80787. * @param radius The radius of the emission cylinder
  80788. * @param height The height of the emission cylinder
  80789. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80790. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80791. * @returns the emitter
  80792. */
  80793. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80794. /**
  80795. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80796. * @param radius The radius of the cylinder to emit from
  80797. * @param height The height of the emission cylinder
  80798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80801. * @returns the emitter
  80802. */
  80803. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80804. /**
  80805. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80806. * @param radius The radius of the cone to emit from
  80807. * @param angle The base angle of the cone
  80808. * @returns the emitter
  80809. */
  80810. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80811. /**
  80812. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80815. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80816. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80817. * @returns the emitter
  80818. */
  80819. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80820. }
  80821. }
  80822. declare module BABYLON {
  80823. /**
  80824. * Type of sub emitter
  80825. */
  80826. export enum SubEmitterType {
  80827. /**
  80828. * Attached to the particle over it's lifetime
  80829. */
  80830. ATTACHED = 0,
  80831. /**
  80832. * Created when the particle dies
  80833. */
  80834. END = 1
  80835. }
  80836. /**
  80837. * Sub emitter class used to emit particles from an existing particle
  80838. */
  80839. export class SubEmitter {
  80840. /**
  80841. * the particle system to be used by the sub emitter
  80842. */
  80843. particleSystem: ParticleSystem;
  80844. /**
  80845. * Type of the submitter (Default: END)
  80846. */
  80847. type: SubEmitterType;
  80848. /**
  80849. * 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)
  80850. * Note: This only is supported when using an emitter of type Mesh
  80851. */
  80852. inheritDirection: boolean;
  80853. /**
  80854. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80855. */
  80856. inheritedVelocityAmount: number;
  80857. /**
  80858. * Creates a sub emitter
  80859. * @param particleSystem the particle system to be used by the sub emitter
  80860. */
  80861. constructor(
  80862. /**
  80863. * the particle system to be used by the sub emitter
  80864. */
  80865. particleSystem: ParticleSystem);
  80866. /**
  80867. * Clones the sub emitter
  80868. * @returns the cloned sub emitter
  80869. */
  80870. clone(): SubEmitter;
  80871. /**
  80872. * Serialize current object to a JSON object
  80873. * @returns the serialized object
  80874. */
  80875. serialize(): any;
  80876. /** @hidden */
  80877. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80878. /**
  80879. * Creates a new SubEmitter from a serialized JSON version
  80880. * @param serializationObject defines the JSON object to read from
  80881. * @param scene defines the hosting scene
  80882. * @param rootUrl defines the rootUrl for data loading
  80883. * @returns a new SubEmitter
  80884. */
  80885. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80886. /** Release associated resources */
  80887. dispose(): void;
  80888. }
  80889. }
  80890. declare module BABYLON {
  80891. /** @hidden */
  80892. export var clipPlaneFragmentDeclaration: {
  80893. name: string;
  80894. shader: string;
  80895. };
  80896. }
  80897. declare module BABYLON {
  80898. /** @hidden */
  80899. export var imageProcessingDeclaration: {
  80900. name: string;
  80901. shader: string;
  80902. };
  80903. }
  80904. declare module BABYLON {
  80905. /** @hidden */
  80906. export var imageProcessingFunctions: {
  80907. name: string;
  80908. shader: string;
  80909. };
  80910. }
  80911. declare module BABYLON {
  80912. /** @hidden */
  80913. export var clipPlaneFragment: {
  80914. name: string;
  80915. shader: string;
  80916. };
  80917. }
  80918. declare module BABYLON {
  80919. /** @hidden */
  80920. export var particlesPixelShader: {
  80921. name: string;
  80922. shader: string;
  80923. };
  80924. }
  80925. declare module BABYLON {
  80926. /** @hidden */
  80927. export var clipPlaneVertexDeclaration: {
  80928. name: string;
  80929. shader: string;
  80930. };
  80931. }
  80932. declare module BABYLON {
  80933. /** @hidden */
  80934. export var clipPlaneVertex: {
  80935. name: string;
  80936. shader: string;
  80937. };
  80938. }
  80939. declare module BABYLON {
  80940. /** @hidden */
  80941. export var particlesVertexShader: {
  80942. name: string;
  80943. shader: string;
  80944. };
  80945. }
  80946. declare module BABYLON {
  80947. /**
  80948. * This represents a particle system in Babylon.
  80949. * 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.
  80950. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80951. * @example https://doc.babylonjs.com/babylon101/particles
  80952. */
  80953. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80954. /**
  80955. * Billboard mode will only apply to Y axis
  80956. */
  80957. static readonly BILLBOARDMODE_Y: number;
  80958. /**
  80959. * Billboard mode will apply to all axes
  80960. */
  80961. static readonly BILLBOARDMODE_ALL: number;
  80962. /**
  80963. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80964. */
  80965. static readonly BILLBOARDMODE_STRETCHED: number;
  80966. /**
  80967. * This function can be defined to provide custom update for active particles.
  80968. * This function will be called instead of regular update (age, position, color, etc.).
  80969. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80970. */
  80971. updateFunction: (particles: Particle[]) => void;
  80972. private _emitterWorldMatrix;
  80973. /**
  80974. * This function can be defined to specify initial direction for every new particle.
  80975. * It by default use the emitterType defined function
  80976. */
  80977. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80978. /**
  80979. * This function can be defined to specify initial position for every new particle.
  80980. * It by default use the emitterType defined function
  80981. */
  80982. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80983. /**
  80984. * @hidden
  80985. */
  80986. _inheritedVelocityOffset: Vector3;
  80987. /**
  80988. * An event triggered when the system is disposed
  80989. */
  80990. onDisposeObservable: Observable<ParticleSystem>;
  80991. private _onDisposeObserver;
  80992. /**
  80993. * Sets a callback that will be triggered when the system is disposed
  80994. */
  80995. onDispose: () => void;
  80996. private _particles;
  80997. private _epsilon;
  80998. private _capacity;
  80999. private _stockParticles;
  81000. private _newPartsExcess;
  81001. private _vertexData;
  81002. private _vertexBuffer;
  81003. private _vertexBuffers;
  81004. private _spriteBuffer;
  81005. private _indexBuffer;
  81006. private _effect;
  81007. private _customEffect;
  81008. private _cachedDefines;
  81009. private _scaledColorStep;
  81010. private _colorDiff;
  81011. private _scaledDirection;
  81012. private _scaledGravity;
  81013. private _currentRenderId;
  81014. private _alive;
  81015. private _useInstancing;
  81016. private _started;
  81017. private _stopped;
  81018. private _actualFrame;
  81019. private _scaledUpdateSpeed;
  81020. private _vertexBufferSize;
  81021. /** @hidden */
  81022. _currentEmitRateGradient: Nullable<FactorGradient>;
  81023. /** @hidden */
  81024. _currentEmitRate1: number;
  81025. /** @hidden */
  81026. _currentEmitRate2: number;
  81027. /** @hidden */
  81028. _currentStartSizeGradient: Nullable<FactorGradient>;
  81029. /** @hidden */
  81030. _currentStartSize1: number;
  81031. /** @hidden */
  81032. _currentStartSize2: number;
  81033. private readonly _rawTextureWidth;
  81034. private _rampGradientsTexture;
  81035. private _useRampGradients;
  81036. /** Gets or sets a boolean indicating that ramp gradients must be used
  81037. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  81038. */
  81039. useRampGradients: boolean;
  81040. /**
  81041. * 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.
  81042. * 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: [])
  81043. */
  81044. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  81045. private _subEmitters;
  81046. /**
  81047. * @hidden
  81048. * If the particle systems emitter should be disposed when the particle system is disposed
  81049. */
  81050. _disposeEmitterOnDispose: boolean;
  81051. /**
  81052. * The current active Sub-systems, this property is used by the root particle system only.
  81053. */
  81054. activeSubSystems: Array<ParticleSystem>;
  81055. private _rootParticleSystem;
  81056. /**
  81057. * Gets the current list of active particles
  81058. */
  81059. readonly particles: Particle[];
  81060. /**
  81061. * Returns the string "ParticleSystem"
  81062. * @returns a string containing the class name
  81063. */
  81064. getClassName(): string;
  81065. /**
  81066. * Instantiates a particle system.
  81067. * 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.
  81068. * @param name The name of the particle system
  81069. * @param capacity The max number of particles alive at the same time
  81070. * @param scene The scene the particle system belongs to
  81071. * @param customEffect a custom effect used to change the way particles are rendered by default
  81072. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  81073. * @param epsilon Offset used to render the particles
  81074. */
  81075. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  81076. private _addFactorGradient;
  81077. private _removeFactorGradient;
  81078. /**
  81079. * Adds a new life time gradient
  81080. * @param gradient defines the gradient to use (between 0 and 1)
  81081. * @param factor defines the life time factor to affect to the specified gradient
  81082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81083. * @returns the current particle system
  81084. */
  81085. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81086. /**
  81087. * Remove a specific life time gradient
  81088. * @param gradient defines the gradient to remove
  81089. * @returns the current particle system
  81090. */
  81091. removeLifeTimeGradient(gradient: number): IParticleSystem;
  81092. /**
  81093. * Adds a new size gradient
  81094. * @param gradient defines the gradient to use (between 0 and 1)
  81095. * @param factor defines the size factor to affect to the specified gradient
  81096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81097. * @returns the current particle system
  81098. */
  81099. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81100. /**
  81101. * Remove a specific size gradient
  81102. * @param gradient defines the gradient to remove
  81103. * @returns the current particle system
  81104. */
  81105. removeSizeGradient(gradient: number): IParticleSystem;
  81106. /**
  81107. * Adds a new color remap gradient
  81108. * @param gradient defines the gradient to use (between 0 and 1)
  81109. * @param min defines the color remap minimal range
  81110. * @param max defines the color remap maximal range
  81111. * @returns the current particle system
  81112. */
  81113. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81114. /**
  81115. * Remove a specific color remap gradient
  81116. * @param gradient defines the gradient to remove
  81117. * @returns the current particle system
  81118. */
  81119. removeColorRemapGradient(gradient: number): IParticleSystem;
  81120. /**
  81121. * Adds a new alpha remap gradient
  81122. * @param gradient defines the gradient to use (between 0 and 1)
  81123. * @param min defines the alpha remap minimal range
  81124. * @param max defines the alpha remap maximal range
  81125. * @returns the current particle system
  81126. */
  81127. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  81128. /**
  81129. * Remove a specific alpha remap gradient
  81130. * @param gradient defines the gradient to remove
  81131. * @returns the current particle system
  81132. */
  81133. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  81134. /**
  81135. * Adds a new angular speed gradient
  81136. * @param gradient defines the gradient to use (between 0 and 1)
  81137. * @param factor defines the angular speed to affect to the specified gradient
  81138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81139. * @returns the current particle system
  81140. */
  81141. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81142. /**
  81143. * Remove a specific angular speed gradient
  81144. * @param gradient defines the gradient to remove
  81145. * @returns the current particle system
  81146. */
  81147. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  81148. /**
  81149. * Adds a new velocity gradient
  81150. * @param gradient defines the gradient to use (between 0 and 1)
  81151. * @param factor defines the velocity to affect to the specified gradient
  81152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81153. * @returns the current particle system
  81154. */
  81155. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81156. /**
  81157. * Remove a specific velocity gradient
  81158. * @param gradient defines the gradient to remove
  81159. * @returns the current particle system
  81160. */
  81161. removeVelocityGradient(gradient: number): IParticleSystem;
  81162. /**
  81163. * Adds a new limit velocity gradient
  81164. * @param gradient defines the gradient to use (between 0 and 1)
  81165. * @param factor defines the limit velocity value to affect to the specified gradient
  81166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81167. * @returns the current particle system
  81168. */
  81169. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81170. /**
  81171. * Remove a specific limit velocity gradient
  81172. * @param gradient defines the gradient to remove
  81173. * @returns the current particle system
  81174. */
  81175. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  81176. /**
  81177. * Adds a new drag gradient
  81178. * @param gradient defines the gradient to use (between 0 and 1)
  81179. * @param factor defines the drag value to affect to the specified gradient
  81180. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81181. * @returns the current particle system
  81182. */
  81183. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81184. /**
  81185. * Remove a specific drag gradient
  81186. * @param gradient defines the gradient to remove
  81187. * @returns the current particle system
  81188. */
  81189. removeDragGradient(gradient: number): IParticleSystem;
  81190. /**
  81191. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  81192. * @param gradient defines the gradient to use (between 0 and 1)
  81193. * @param factor defines the emit rate value to affect to the specified gradient
  81194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81195. * @returns the current particle system
  81196. */
  81197. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81198. /**
  81199. * Remove a specific emit rate gradient
  81200. * @param gradient defines the gradient to remove
  81201. * @returns the current particle system
  81202. */
  81203. removeEmitRateGradient(gradient: number): IParticleSystem;
  81204. /**
  81205. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  81206. * @param gradient defines the gradient to use (between 0 and 1)
  81207. * @param factor defines the start size value to affect to the specified gradient
  81208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81209. * @returns the current particle system
  81210. */
  81211. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81212. /**
  81213. * Remove a specific start size gradient
  81214. * @param gradient defines the gradient to remove
  81215. * @returns the current particle system
  81216. */
  81217. removeStartSizeGradient(gradient: number): IParticleSystem;
  81218. private _createRampGradientTexture;
  81219. /**
  81220. * Gets the current list of ramp gradients.
  81221. * You must use addRampGradient and removeRampGradient to udpate this list
  81222. * @returns the list of ramp gradients
  81223. */
  81224. getRampGradients(): Nullable<Array<Color3Gradient>>;
  81225. /**
  81226. * Adds a new ramp gradient used to remap particle colors
  81227. * @param gradient defines the gradient to use (between 0 and 1)
  81228. * @param color defines the color to affect to the specified gradient
  81229. * @returns the current particle system
  81230. */
  81231. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  81232. /**
  81233. * Remove a specific ramp gradient
  81234. * @param gradient defines the gradient to remove
  81235. * @returns the current particle system
  81236. */
  81237. removeRampGradient(gradient: number): ParticleSystem;
  81238. /**
  81239. * Adds a new color gradient
  81240. * @param gradient defines the gradient to use (between 0 and 1)
  81241. * @param color1 defines the color to affect to the specified gradient
  81242. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81243. * @returns this particle system
  81244. */
  81245. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81246. /**
  81247. * Remove a specific color gradient
  81248. * @param gradient defines the gradient to remove
  81249. * @returns this particle system
  81250. */
  81251. removeColorGradient(gradient: number): IParticleSystem;
  81252. private _fetchR;
  81253. protected _reset(): void;
  81254. private _resetEffect;
  81255. private _createVertexBuffers;
  81256. private _createIndexBuffer;
  81257. /**
  81258. * Gets the maximum number of particles active at the same time.
  81259. * @returns The max number of active particles.
  81260. */
  81261. getCapacity(): number;
  81262. /**
  81263. * Gets whether there are still active particles in the system.
  81264. * @returns True if it is alive, otherwise false.
  81265. */
  81266. isAlive(): boolean;
  81267. /**
  81268. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81269. * @returns True if it has been started, otherwise false.
  81270. */
  81271. isStarted(): boolean;
  81272. private _prepareSubEmitterInternalArray;
  81273. /**
  81274. * Starts the particle system and begins to emit
  81275. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  81276. */
  81277. start(delay?: number): void;
  81278. /**
  81279. * Stops the particle system.
  81280. * @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.
  81281. */
  81282. stop(stopSubEmitters?: boolean): void;
  81283. /**
  81284. * Remove all active particles
  81285. */
  81286. reset(): void;
  81287. /**
  81288. * @hidden (for internal use only)
  81289. */
  81290. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  81291. /**
  81292. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  81293. * Its lifetime will start back at 0.
  81294. */
  81295. recycleParticle: (particle: Particle) => void;
  81296. private _stopSubEmitters;
  81297. private _createParticle;
  81298. private _removeFromRoot;
  81299. private _emitFromParticle;
  81300. private _update;
  81301. /** @hidden */
  81302. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  81303. /** @hidden */
  81304. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  81305. /** @hidden */
  81306. private _getEffect;
  81307. /**
  81308. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  81309. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  81310. */
  81311. animate(preWarmOnly?: boolean): void;
  81312. private _appendParticleVertices;
  81313. /**
  81314. * Rebuilds the particle system.
  81315. */
  81316. rebuild(): void;
  81317. /**
  81318. * Is this system ready to be used/rendered
  81319. * @return true if the system is ready
  81320. */
  81321. isReady(): boolean;
  81322. private _render;
  81323. /**
  81324. * Renders the particle system in its current state.
  81325. * @returns the current number of particles
  81326. */
  81327. render(): number;
  81328. /**
  81329. * Disposes the particle system and free the associated resources
  81330. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81331. */
  81332. dispose(disposeTexture?: boolean): void;
  81333. /**
  81334. * Clones the particle system.
  81335. * @param name The name of the cloned object
  81336. * @param newEmitter The new emitter to use
  81337. * @returns the cloned particle system
  81338. */
  81339. clone(name: string, newEmitter: any): ParticleSystem;
  81340. /**
  81341. * Serializes the particle system to a JSON object.
  81342. * @returns the JSON object
  81343. */
  81344. serialize(): any;
  81345. /** @hidden */
  81346. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81347. /** @hidden */
  81348. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81349. /**
  81350. * Parses a JSON object to create a particle system.
  81351. * @param parsedParticleSystem The JSON object to parse
  81352. * @param scene The scene to create the particle system in
  81353. * @param rootUrl The root url to use to load external dependencies like texture
  81354. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81355. * @returns the Parsed particle system
  81356. */
  81357. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81358. }
  81359. }
  81360. declare module BABYLON {
  81361. /**
  81362. * A particle represents one of the element emitted by a particle system.
  81363. * This is mainly define by its coordinates, direction, velocity and age.
  81364. */
  81365. export class Particle {
  81366. /**
  81367. * The particle system the particle belongs to.
  81368. */
  81369. particleSystem: ParticleSystem;
  81370. private static _Count;
  81371. /**
  81372. * Unique ID of the particle
  81373. */
  81374. id: number;
  81375. /**
  81376. * The world position of the particle in the scene.
  81377. */
  81378. position: Vector3;
  81379. /**
  81380. * The world direction of the particle in the scene.
  81381. */
  81382. direction: Vector3;
  81383. /**
  81384. * The color of the particle.
  81385. */
  81386. color: Color4;
  81387. /**
  81388. * The color change of the particle per step.
  81389. */
  81390. colorStep: Color4;
  81391. /**
  81392. * Defines how long will the life of the particle be.
  81393. */
  81394. lifeTime: number;
  81395. /**
  81396. * The current age of the particle.
  81397. */
  81398. age: number;
  81399. /**
  81400. * The current size of the particle.
  81401. */
  81402. size: number;
  81403. /**
  81404. * The current scale of the particle.
  81405. */
  81406. scale: Vector2;
  81407. /**
  81408. * The current angle of the particle.
  81409. */
  81410. angle: number;
  81411. /**
  81412. * Defines how fast is the angle changing.
  81413. */
  81414. angularSpeed: number;
  81415. /**
  81416. * Defines the cell index used by the particle to be rendered from a sprite.
  81417. */
  81418. cellIndex: number;
  81419. /**
  81420. * The information required to support color remapping
  81421. */
  81422. remapData: Vector4;
  81423. /** @hidden */
  81424. _randomCellOffset?: number;
  81425. /** @hidden */
  81426. _initialDirection: Nullable<Vector3>;
  81427. /** @hidden */
  81428. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81429. /** @hidden */
  81430. _initialStartSpriteCellID: number;
  81431. /** @hidden */
  81432. _initialEndSpriteCellID: number;
  81433. /** @hidden */
  81434. _currentColorGradient: Nullable<ColorGradient>;
  81435. /** @hidden */
  81436. _currentColor1: Color4;
  81437. /** @hidden */
  81438. _currentColor2: Color4;
  81439. /** @hidden */
  81440. _currentSizeGradient: Nullable<FactorGradient>;
  81441. /** @hidden */
  81442. _currentSize1: number;
  81443. /** @hidden */
  81444. _currentSize2: number;
  81445. /** @hidden */
  81446. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81447. /** @hidden */
  81448. _currentAngularSpeed1: number;
  81449. /** @hidden */
  81450. _currentAngularSpeed2: number;
  81451. /** @hidden */
  81452. _currentVelocityGradient: Nullable<FactorGradient>;
  81453. /** @hidden */
  81454. _currentVelocity1: number;
  81455. /** @hidden */
  81456. _currentVelocity2: number;
  81457. /** @hidden */
  81458. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81459. /** @hidden */
  81460. _currentLimitVelocity1: number;
  81461. /** @hidden */
  81462. _currentLimitVelocity2: number;
  81463. /** @hidden */
  81464. _currentDragGradient: Nullable<FactorGradient>;
  81465. /** @hidden */
  81466. _currentDrag1: number;
  81467. /** @hidden */
  81468. _currentDrag2: number;
  81469. /** @hidden */
  81470. _randomNoiseCoordinates1: Vector3;
  81471. /** @hidden */
  81472. _randomNoiseCoordinates2: Vector3;
  81473. /**
  81474. * Creates a new instance Particle
  81475. * @param particleSystem the particle system the particle belongs to
  81476. */
  81477. constructor(
  81478. /**
  81479. * The particle system the particle belongs to.
  81480. */
  81481. particleSystem: ParticleSystem);
  81482. private updateCellInfoFromSystem;
  81483. /**
  81484. * Defines how the sprite cell index is updated for the particle
  81485. */
  81486. updateCellIndex(): void;
  81487. /** @hidden */
  81488. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81489. /** @hidden */
  81490. _inheritParticleInfoToSubEmitters(): void;
  81491. /** @hidden */
  81492. _reset(): void;
  81493. /**
  81494. * Copy the properties of particle to another one.
  81495. * @param other the particle to copy the information to.
  81496. */
  81497. copyTo(other: Particle): void;
  81498. }
  81499. }
  81500. declare module BABYLON {
  81501. /**
  81502. * Particle emitter represents a volume emitting particles.
  81503. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81504. */
  81505. export interface IParticleEmitterType {
  81506. /**
  81507. * Called by the particle System when the direction is computed for the created particle.
  81508. * @param worldMatrix is the world matrix of the particle system
  81509. * @param directionToUpdate is the direction vector to update with the result
  81510. * @param particle is the particle we are computed the direction for
  81511. */
  81512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81513. /**
  81514. * Called by the particle System when the position is computed for the created particle.
  81515. * @param worldMatrix is the world matrix of the particle system
  81516. * @param positionToUpdate is the position vector to update with the result
  81517. * @param particle is the particle we are computed the position for
  81518. */
  81519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81520. /**
  81521. * Clones the current emitter and returns a copy of it
  81522. * @returns the new emitter
  81523. */
  81524. clone(): IParticleEmitterType;
  81525. /**
  81526. * Called by the GPUParticleSystem to setup the update shader
  81527. * @param effect defines the update shader
  81528. */
  81529. applyToShader(effect: Effect): void;
  81530. /**
  81531. * Returns a string to use to update the GPU particles update shader
  81532. * @returns the effect defines string
  81533. */
  81534. getEffectDefines(): string;
  81535. /**
  81536. * Returns a string representing the class name
  81537. * @returns a string containing the class name
  81538. */
  81539. getClassName(): string;
  81540. /**
  81541. * Serializes the particle system to a JSON object.
  81542. * @returns the JSON object
  81543. */
  81544. serialize(): any;
  81545. /**
  81546. * Parse properties from a JSON object
  81547. * @param serializationObject defines the JSON object
  81548. */
  81549. parse(serializationObject: any): void;
  81550. }
  81551. }
  81552. declare module BABYLON {
  81553. /**
  81554. * Particle emitter emitting particles from the inside of a box.
  81555. * It emits the particles randomly between 2 given directions.
  81556. */
  81557. export class BoxParticleEmitter implements IParticleEmitterType {
  81558. /**
  81559. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81560. */
  81561. direction1: Vector3;
  81562. /**
  81563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81564. */
  81565. direction2: Vector3;
  81566. /**
  81567. * 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.
  81568. */
  81569. minEmitBox: Vector3;
  81570. /**
  81571. * 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.
  81572. */
  81573. maxEmitBox: Vector3;
  81574. /**
  81575. * Creates a new instance BoxParticleEmitter
  81576. */
  81577. constructor();
  81578. /**
  81579. * Called by the particle System when the direction is computed for the created particle.
  81580. * @param worldMatrix is the world matrix of the particle system
  81581. * @param directionToUpdate is the direction vector to update with the result
  81582. * @param particle is the particle we are computed the direction for
  81583. */
  81584. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81585. /**
  81586. * Called by the particle System when the position is computed for the created particle.
  81587. * @param worldMatrix is the world matrix of the particle system
  81588. * @param positionToUpdate is the position vector to update with the result
  81589. * @param particle is the particle we are computed the position for
  81590. */
  81591. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81592. /**
  81593. * Clones the current emitter and returns a copy of it
  81594. * @returns the new emitter
  81595. */
  81596. clone(): BoxParticleEmitter;
  81597. /**
  81598. * Called by the GPUParticleSystem to setup the update shader
  81599. * @param effect defines the update shader
  81600. */
  81601. applyToShader(effect: Effect): void;
  81602. /**
  81603. * Returns a string to use to update the GPU particles update shader
  81604. * @returns a string containng the defines string
  81605. */
  81606. getEffectDefines(): string;
  81607. /**
  81608. * Returns the string "BoxParticleEmitter"
  81609. * @returns a string containing the class name
  81610. */
  81611. getClassName(): string;
  81612. /**
  81613. * Serializes the particle system to a JSON object.
  81614. * @returns the JSON object
  81615. */
  81616. serialize(): any;
  81617. /**
  81618. * Parse properties from a JSON object
  81619. * @param serializationObject defines the JSON object
  81620. */
  81621. parse(serializationObject: any): void;
  81622. }
  81623. }
  81624. declare module BABYLON {
  81625. /**
  81626. * Particle emitter emitting particles from the inside of a cone.
  81627. * It emits the particles alongside the cone volume from the base to the particle.
  81628. * The emission direction might be randomized.
  81629. */
  81630. export class ConeParticleEmitter implements IParticleEmitterType {
  81631. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81632. directionRandomizer: number;
  81633. private _radius;
  81634. private _angle;
  81635. private _height;
  81636. /**
  81637. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81638. */
  81639. radiusRange: number;
  81640. /**
  81641. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81642. */
  81643. heightRange: number;
  81644. /**
  81645. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81646. */
  81647. emitFromSpawnPointOnly: boolean;
  81648. /**
  81649. * Gets or sets the radius of the emission cone
  81650. */
  81651. radius: number;
  81652. /**
  81653. * Gets or sets the angle of the emission cone
  81654. */
  81655. angle: number;
  81656. private _buildHeight;
  81657. /**
  81658. * Creates a new instance ConeParticleEmitter
  81659. * @param radius the radius of the emission cone (1 by default)
  81660. * @param angle the cone base angle (PI by default)
  81661. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81662. */
  81663. constructor(radius?: number, angle?: number,
  81664. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81665. directionRandomizer?: number);
  81666. /**
  81667. * Called by the particle System when the direction is computed for the created particle.
  81668. * @param worldMatrix is the world matrix of the particle system
  81669. * @param directionToUpdate is the direction vector to update with the result
  81670. * @param particle is the particle we are computed the direction for
  81671. */
  81672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81673. /**
  81674. * Called by the particle System when the position is computed for the created particle.
  81675. * @param worldMatrix is the world matrix of the particle system
  81676. * @param positionToUpdate is the position vector to update with the result
  81677. * @param particle is the particle we are computed the position for
  81678. */
  81679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81680. /**
  81681. * Clones the current emitter and returns a copy of it
  81682. * @returns the new emitter
  81683. */
  81684. clone(): ConeParticleEmitter;
  81685. /**
  81686. * Called by the GPUParticleSystem to setup the update shader
  81687. * @param effect defines the update shader
  81688. */
  81689. applyToShader(effect: Effect): void;
  81690. /**
  81691. * Returns a string to use to update the GPU particles update shader
  81692. * @returns a string containng the defines string
  81693. */
  81694. getEffectDefines(): string;
  81695. /**
  81696. * Returns the string "ConeParticleEmitter"
  81697. * @returns a string containing the class name
  81698. */
  81699. getClassName(): string;
  81700. /**
  81701. * Serializes the particle system to a JSON object.
  81702. * @returns the JSON object
  81703. */
  81704. serialize(): any;
  81705. /**
  81706. * Parse properties from a JSON object
  81707. * @param serializationObject defines the JSON object
  81708. */
  81709. parse(serializationObject: any): void;
  81710. }
  81711. }
  81712. declare module BABYLON {
  81713. /**
  81714. * Particle emitter emitting particles from the inside of a cylinder.
  81715. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81716. */
  81717. export class CylinderParticleEmitter implements IParticleEmitterType {
  81718. /**
  81719. * The radius of the emission cylinder.
  81720. */
  81721. radius: number;
  81722. /**
  81723. * The height of the emission cylinder.
  81724. */
  81725. height: number;
  81726. /**
  81727. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81728. */
  81729. radiusRange: number;
  81730. /**
  81731. * How much to randomize the particle direction [0-1].
  81732. */
  81733. directionRandomizer: number;
  81734. /**
  81735. * Creates a new instance CylinderParticleEmitter
  81736. * @param radius the radius of the emission cylinder (1 by default)
  81737. * @param height the height of the emission cylinder (1 by default)
  81738. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81740. */
  81741. constructor(
  81742. /**
  81743. * The radius of the emission cylinder.
  81744. */
  81745. radius?: number,
  81746. /**
  81747. * The height of the emission cylinder.
  81748. */
  81749. height?: number,
  81750. /**
  81751. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81752. */
  81753. radiusRange?: number,
  81754. /**
  81755. * How much to randomize the particle direction [0-1].
  81756. */
  81757. directionRandomizer?: number);
  81758. /**
  81759. * Called by the particle System when the direction is computed for the created particle.
  81760. * @param worldMatrix is the world matrix of the particle system
  81761. * @param directionToUpdate is the direction vector to update with the result
  81762. * @param particle is the particle we are computed the direction for
  81763. */
  81764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81765. /**
  81766. * Called by the particle System when the position is computed for the created particle.
  81767. * @param worldMatrix is the world matrix of the particle system
  81768. * @param positionToUpdate is the position vector to update with the result
  81769. * @param particle is the particle we are computed the position for
  81770. */
  81771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81772. /**
  81773. * Clones the current emitter and returns a copy of it
  81774. * @returns the new emitter
  81775. */
  81776. clone(): CylinderParticleEmitter;
  81777. /**
  81778. * Called by the GPUParticleSystem to setup the update shader
  81779. * @param effect defines the update shader
  81780. */
  81781. applyToShader(effect: Effect): void;
  81782. /**
  81783. * Returns a string to use to update the GPU particles update shader
  81784. * @returns a string containng the defines string
  81785. */
  81786. getEffectDefines(): string;
  81787. /**
  81788. * Returns the string "CylinderParticleEmitter"
  81789. * @returns a string containing the class name
  81790. */
  81791. getClassName(): string;
  81792. /**
  81793. * Serializes the particle system to a JSON object.
  81794. * @returns the JSON object
  81795. */
  81796. serialize(): any;
  81797. /**
  81798. * Parse properties from a JSON object
  81799. * @param serializationObject defines the JSON object
  81800. */
  81801. parse(serializationObject: any): void;
  81802. }
  81803. /**
  81804. * Particle emitter emitting particles from the inside of a cylinder.
  81805. * It emits the particles randomly between two vectors.
  81806. */
  81807. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81808. /**
  81809. * The min limit of the emission direction.
  81810. */
  81811. direction1: Vector3;
  81812. /**
  81813. * The max limit of the emission direction.
  81814. */
  81815. direction2: Vector3;
  81816. /**
  81817. * Creates a new instance CylinderDirectedParticleEmitter
  81818. * @param radius the radius of the emission cylinder (1 by default)
  81819. * @param height the height of the emission cylinder (1 by default)
  81820. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81821. * @param direction1 the min limit of the emission direction (up vector by default)
  81822. * @param direction2 the max limit of the emission direction (up vector by default)
  81823. */
  81824. constructor(radius?: number, height?: number, radiusRange?: number,
  81825. /**
  81826. * The min limit of the emission direction.
  81827. */
  81828. direction1?: Vector3,
  81829. /**
  81830. * The max limit of the emission direction.
  81831. */
  81832. direction2?: Vector3);
  81833. /**
  81834. * Called by the particle System when the direction is computed for the created particle.
  81835. * @param worldMatrix is the world matrix of the particle system
  81836. * @param directionToUpdate is the direction vector to update with the result
  81837. * @param particle is the particle we are computed the direction for
  81838. */
  81839. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81840. /**
  81841. * Clones the current emitter and returns a copy of it
  81842. * @returns the new emitter
  81843. */
  81844. clone(): CylinderDirectedParticleEmitter;
  81845. /**
  81846. * Called by the GPUParticleSystem to setup the update shader
  81847. * @param effect defines the update shader
  81848. */
  81849. applyToShader(effect: Effect): void;
  81850. /**
  81851. * Returns a string to use to update the GPU particles update shader
  81852. * @returns a string containng the defines string
  81853. */
  81854. getEffectDefines(): string;
  81855. /**
  81856. * Returns the string "CylinderDirectedParticleEmitter"
  81857. * @returns a string containing the class name
  81858. */
  81859. getClassName(): string;
  81860. /**
  81861. * Serializes the particle system to a JSON object.
  81862. * @returns the JSON object
  81863. */
  81864. serialize(): any;
  81865. /**
  81866. * Parse properties from a JSON object
  81867. * @param serializationObject defines the JSON object
  81868. */
  81869. parse(serializationObject: any): void;
  81870. }
  81871. }
  81872. declare module BABYLON {
  81873. /**
  81874. * Particle emitter emitting particles from the inside of a hemisphere.
  81875. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81876. */
  81877. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81878. /**
  81879. * The radius of the emission hemisphere.
  81880. */
  81881. radius: number;
  81882. /**
  81883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81884. */
  81885. radiusRange: number;
  81886. /**
  81887. * How much to randomize the particle direction [0-1].
  81888. */
  81889. directionRandomizer: number;
  81890. /**
  81891. * Creates a new instance HemisphericParticleEmitter
  81892. * @param radius the radius of the emission hemisphere (1 by default)
  81893. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81895. */
  81896. constructor(
  81897. /**
  81898. * The radius of the emission hemisphere.
  81899. */
  81900. radius?: number,
  81901. /**
  81902. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81903. */
  81904. radiusRange?: number,
  81905. /**
  81906. * How much to randomize the particle direction [0-1].
  81907. */
  81908. directionRandomizer?: number);
  81909. /**
  81910. * Called by the particle System when the direction is computed for the created particle.
  81911. * @param worldMatrix is the world matrix of the particle system
  81912. * @param directionToUpdate is the direction vector to update with the result
  81913. * @param particle is the particle we are computed the direction for
  81914. */
  81915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81916. /**
  81917. * Called by the particle System when the position is computed for the created particle.
  81918. * @param worldMatrix is the world matrix of the particle system
  81919. * @param positionToUpdate is the position vector to update with the result
  81920. * @param particle is the particle we are computed the position for
  81921. */
  81922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81923. /**
  81924. * Clones the current emitter and returns a copy of it
  81925. * @returns the new emitter
  81926. */
  81927. clone(): HemisphericParticleEmitter;
  81928. /**
  81929. * Called by the GPUParticleSystem to setup the update shader
  81930. * @param effect defines the update shader
  81931. */
  81932. applyToShader(effect: Effect): void;
  81933. /**
  81934. * Returns a string to use to update the GPU particles update shader
  81935. * @returns a string containng the defines string
  81936. */
  81937. getEffectDefines(): string;
  81938. /**
  81939. * Returns the string "HemisphericParticleEmitter"
  81940. * @returns a string containing the class name
  81941. */
  81942. getClassName(): string;
  81943. /**
  81944. * Serializes the particle system to a JSON object.
  81945. * @returns the JSON object
  81946. */
  81947. serialize(): any;
  81948. /**
  81949. * Parse properties from a JSON object
  81950. * @param serializationObject defines the JSON object
  81951. */
  81952. parse(serializationObject: any): void;
  81953. }
  81954. }
  81955. declare module BABYLON {
  81956. /**
  81957. * Particle emitter emitting particles from a point.
  81958. * It emits the particles randomly between 2 given directions.
  81959. */
  81960. export class PointParticleEmitter implements IParticleEmitterType {
  81961. /**
  81962. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81963. */
  81964. direction1: Vector3;
  81965. /**
  81966. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81967. */
  81968. direction2: Vector3;
  81969. /**
  81970. * Creates a new instance PointParticleEmitter
  81971. */
  81972. constructor();
  81973. /**
  81974. * Called by the particle System when the direction is computed for the created particle.
  81975. * @param worldMatrix is the world matrix of the particle system
  81976. * @param directionToUpdate is the direction vector to update with the result
  81977. * @param particle is the particle we are computed the direction for
  81978. */
  81979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81980. /**
  81981. * Called by the particle System when the position is computed for the created particle.
  81982. * @param worldMatrix is the world matrix of the particle system
  81983. * @param positionToUpdate is the position vector to update with the result
  81984. * @param particle is the particle we are computed the position for
  81985. */
  81986. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81987. /**
  81988. * Clones the current emitter and returns a copy of it
  81989. * @returns the new emitter
  81990. */
  81991. clone(): PointParticleEmitter;
  81992. /**
  81993. * Called by the GPUParticleSystem to setup the update shader
  81994. * @param effect defines the update shader
  81995. */
  81996. applyToShader(effect: Effect): void;
  81997. /**
  81998. * Returns a string to use to update the GPU particles update shader
  81999. * @returns a string containng the defines string
  82000. */
  82001. getEffectDefines(): string;
  82002. /**
  82003. * Returns the string "PointParticleEmitter"
  82004. * @returns a string containing the class name
  82005. */
  82006. getClassName(): string;
  82007. /**
  82008. * Serializes the particle system to a JSON object.
  82009. * @returns the JSON object
  82010. */
  82011. serialize(): any;
  82012. /**
  82013. * Parse properties from a JSON object
  82014. * @param serializationObject defines the JSON object
  82015. */
  82016. parse(serializationObject: any): void;
  82017. }
  82018. }
  82019. declare module BABYLON {
  82020. /**
  82021. * Particle emitter emitting particles from the inside of a sphere.
  82022. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  82023. */
  82024. export class SphereParticleEmitter implements IParticleEmitterType {
  82025. /**
  82026. * The radius of the emission sphere.
  82027. */
  82028. radius: number;
  82029. /**
  82030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82031. */
  82032. radiusRange: number;
  82033. /**
  82034. * How much to randomize the particle direction [0-1].
  82035. */
  82036. directionRandomizer: number;
  82037. /**
  82038. * Creates a new instance SphereParticleEmitter
  82039. * @param radius the radius of the emission sphere (1 by default)
  82040. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82042. */
  82043. constructor(
  82044. /**
  82045. * The radius of the emission sphere.
  82046. */
  82047. radius?: number,
  82048. /**
  82049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82050. */
  82051. radiusRange?: number,
  82052. /**
  82053. * How much to randomize the particle direction [0-1].
  82054. */
  82055. directionRandomizer?: number);
  82056. /**
  82057. * Called by the particle System when the direction is computed for the created particle.
  82058. * @param worldMatrix is the world matrix of the particle system
  82059. * @param directionToUpdate is the direction vector to update with the result
  82060. * @param particle is the particle we are computed the direction for
  82061. */
  82062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82063. /**
  82064. * Called by the particle System when the position is computed for the created particle.
  82065. * @param worldMatrix is the world matrix of the particle system
  82066. * @param positionToUpdate is the position vector to update with the result
  82067. * @param particle is the particle we are computed the position for
  82068. */
  82069. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82070. /**
  82071. * Clones the current emitter and returns a copy of it
  82072. * @returns the new emitter
  82073. */
  82074. clone(): SphereParticleEmitter;
  82075. /**
  82076. * Called by the GPUParticleSystem to setup the update shader
  82077. * @param effect defines the update shader
  82078. */
  82079. applyToShader(effect: Effect): void;
  82080. /**
  82081. * Returns a string to use to update the GPU particles update shader
  82082. * @returns a string containng the defines string
  82083. */
  82084. getEffectDefines(): string;
  82085. /**
  82086. * Returns the string "SphereParticleEmitter"
  82087. * @returns a string containing the class name
  82088. */
  82089. getClassName(): string;
  82090. /**
  82091. * Serializes the particle system to a JSON object.
  82092. * @returns the JSON object
  82093. */
  82094. serialize(): any;
  82095. /**
  82096. * Parse properties from a JSON object
  82097. * @param serializationObject defines the JSON object
  82098. */
  82099. parse(serializationObject: any): void;
  82100. }
  82101. /**
  82102. * Particle emitter emitting particles from the inside of a sphere.
  82103. * It emits the particles randomly between two vectors.
  82104. */
  82105. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  82106. /**
  82107. * The min limit of the emission direction.
  82108. */
  82109. direction1: Vector3;
  82110. /**
  82111. * The max limit of the emission direction.
  82112. */
  82113. direction2: Vector3;
  82114. /**
  82115. * Creates a new instance SphereDirectedParticleEmitter
  82116. * @param radius the radius of the emission sphere (1 by default)
  82117. * @param direction1 the min limit of the emission direction (up vector by default)
  82118. * @param direction2 the max limit of the emission direction (up vector by default)
  82119. */
  82120. constructor(radius?: number,
  82121. /**
  82122. * The min limit of the emission direction.
  82123. */
  82124. direction1?: Vector3,
  82125. /**
  82126. * The max limit of the emission direction.
  82127. */
  82128. direction2?: Vector3);
  82129. /**
  82130. * Called by the particle System when the direction is computed for the created particle.
  82131. * @param worldMatrix is the world matrix of the particle system
  82132. * @param directionToUpdate is the direction vector to update with the result
  82133. * @param particle is the particle we are computed the direction for
  82134. */
  82135. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82136. /**
  82137. * Clones the current emitter and returns a copy of it
  82138. * @returns the new emitter
  82139. */
  82140. clone(): SphereDirectedParticleEmitter;
  82141. /**
  82142. * Called by the GPUParticleSystem to setup the update shader
  82143. * @param effect defines the update shader
  82144. */
  82145. applyToShader(effect: Effect): void;
  82146. /**
  82147. * Returns a string to use to update the GPU particles update shader
  82148. * @returns a string containng the defines string
  82149. */
  82150. getEffectDefines(): string;
  82151. /**
  82152. * Returns the string "SphereDirectedParticleEmitter"
  82153. * @returns a string containing the class name
  82154. */
  82155. getClassName(): string;
  82156. /**
  82157. * Serializes the particle system to a JSON object.
  82158. * @returns the JSON object
  82159. */
  82160. serialize(): any;
  82161. /**
  82162. * Parse properties from a JSON object
  82163. * @param serializationObject defines the JSON object
  82164. */
  82165. parse(serializationObject: any): void;
  82166. }
  82167. }
  82168. declare module BABYLON {
  82169. /**
  82170. * Interface representing a particle system in Babylon.js.
  82171. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  82172. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  82173. */
  82174. export interface IParticleSystem {
  82175. /**
  82176. * List of animations used by the particle system.
  82177. */
  82178. animations: Animation[];
  82179. /**
  82180. * The id of the Particle system.
  82181. */
  82182. id: string;
  82183. /**
  82184. * The name of the Particle system.
  82185. */
  82186. name: string;
  82187. /**
  82188. * The emitter represents the Mesh or position we are attaching the particle system to.
  82189. */
  82190. emitter: Nullable<AbstractMesh | Vector3>;
  82191. /**
  82192. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82193. */
  82194. isBillboardBased: boolean;
  82195. /**
  82196. * The rendering group used by the Particle system to chose when to render.
  82197. */
  82198. renderingGroupId: number;
  82199. /**
  82200. * The layer mask we are rendering the particles through.
  82201. */
  82202. layerMask: number;
  82203. /**
  82204. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82205. */
  82206. updateSpeed: number;
  82207. /**
  82208. * The amount of time the particle system is running (depends of the overall update speed).
  82209. */
  82210. targetStopDuration: number;
  82211. /**
  82212. * The texture used to render each particle. (this can be a spritesheet)
  82213. */
  82214. particleTexture: Nullable<Texture>;
  82215. /**
  82216. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  82217. */
  82218. blendMode: number;
  82219. /**
  82220. * Minimum life time of emitting particles.
  82221. */
  82222. minLifeTime: number;
  82223. /**
  82224. * Maximum life time of emitting particles.
  82225. */
  82226. maxLifeTime: number;
  82227. /**
  82228. * Minimum Size of emitting particles.
  82229. */
  82230. minSize: number;
  82231. /**
  82232. * Maximum Size of emitting particles.
  82233. */
  82234. maxSize: number;
  82235. /**
  82236. * Minimum scale of emitting particles on X axis.
  82237. */
  82238. minScaleX: number;
  82239. /**
  82240. * Maximum scale of emitting particles on X axis.
  82241. */
  82242. maxScaleX: number;
  82243. /**
  82244. * Minimum scale of emitting particles on Y axis.
  82245. */
  82246. minScaleY: number;
  82247. /**
  82248. * Maximum scale of emitting particles on Y axis.
  82249. */
  82250. maxScaleY: number;
  82251. /**
  82252. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82253. */
  82254. color1: Color4;
  82255. /**
  82256. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  82257. */
  82258. color2: Color4;
  82259. /**
  82260. * Color the particle will have at the end of its lifetime.
  82261. */
  82262. colorDead: Color4;
  82263. /**
  82264. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  82265. */
  82266. emitRate: number;
  82267. /**
  82268. * You can use gravity if you want to give an orientation to your particles.
  82269. */
  82270. gravity: Vector3;
  82271. /**
  82272. * Minimum power of emitting particles.
  82273. */
  82274. minEmitPower: number;
  82275. /**
  82276. * Maximum power of emitting particles.
  82277. */
  82278. maxEmitPower: number;
  82279. /**
  82280. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82281. */
  82282. minAngularSpeed: number;
  82283. /**
  82284. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82285. */
  82286. maxAngularSpeed: number;
  82287. /**
  82288. * Gets or sets the minimal initial rotation in radians.
  82289. */
  82290. minInitialRotation: number;
  82291. /**
  82292. * Gets or sets the maximal initial rotation in radians.
  82293. */
  82294. maxInitialRotation: number;
  82295. /**
  82296. * The particle emitter type defines the emitter used by the particle system.
  82297. * It can be for example box, sphere, or cone...
  82298. */
  82299. particleEmitterType: Nullable<IParticleEmitterType>;
  82300. /**
  82301. * Defines the delay in milliseconds before starting the system (0 by default)
  82302. */
  82303. startDelay: number;
  82304. /**
  82305. * 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
  82306. */
  82307. preWarmCycles: number;
  82308. /**
  82309. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  82310. */
  82311. preWarmStepOffset: number;
  82312. /**
  82313. * 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)
  82314. */
  82315. spriteCellChangeSpeed: number;
  82316. /**
  82317. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82318. */
  82319. startSpriteCellID: number;
  82320. /**
  82321. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82322. */
  82323. endSpriteCellID: number;
  82324. /**
  82325. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82326. */
  82327. spriteCellWidth: number;
  82328. /**
  82329. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82330. */
  82331. spriteCellHeight: number;
  82332. /**
  82333. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82334. */
  82335. spriteRandomStartCell: boolean;
  82336. /**
  82337. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82338. */
  82339. isAnimationSheetEnabled: boolean;
  82340. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82341. translationPivot: Vector2;
  82342. /**
  82343. * Gets or sets a texture used to add random noise to particle positions
  82344. */
  82345. noiseTexture: Nullable<BaseTexture>;
  82346. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82347. noiseStrength: Vector3;
  82348. /**
  82349. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82350. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82351. */
  82352. billboardMode: number;
  82353. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82354. limitVelocityDamping: number;
  82355. /**
  82356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82357. */
  82358. beginAnimationOnStart: boolean;
  82359. /**
  82360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82361. */
  82362. beginAnimationFrom: number;
  82363. /**
  82364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82365. */
  82366. beginAnimationTo: number;
  82367. /**
  82368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82369. */
  82370. beginAnimationLoop: boolean;
  82371. /**
  82372. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82373. */
  82374. disposeOnStop: boolean;
  82375. /**
  82376. * Gets the maximum number of particles active at the same time.
  82377. * @returns The max number of active particles.
  82378. */
  82379. getCapacity(): number;
  82380. /**
  82381. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82382. * @returns True if it has been started, otherwise false.
  82383. */
  82384. isStarted(): boolean;
  82385. /**
  82386. * Animates the particle system for this frame.
  82387. */
  82388. animate(): void;
  82389. /**
  82390. * Renders the particle system in its current state.
  82391. * @returns the current number of particles
  82392. */
  82393. render(): number;
  82394. /**
  82395. * Dispose the particle system and frees its associated resources.
  82396. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82397. */
  82398. dispose(disposeTexture?: boolean): void;
  82399. /**
  82400. * Clones the particle system.
  82401. * @param name The name of the cloned object
  82402. * @param newEmitter The new emitter to use
  82403. * @returns the cloned particle system
  82404. */
  82405. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82406. /**
  82407. * Serializes the particle system to a JSON object.
  82408. * @returns the JSON object
  82409. */
  82410. serialize(): any;
  82411. /**
  82412. * Rebuild the particle system
  82413. */
  82414. rebuild(): void;
  82415. /**
  82416. * Starts the particle system and begins to emit
  82417. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82418. */
  82419. start(delay?: number): void;
  82420. /**
  82421. * Stops the particle system.
  82422. */
  82423. stop(): void;
  82424. /**
  82425. * Remove all active particles
  82426. */
  82427. reset(): void;
  82428. /**
  82429. * Is this system ready to be used/rendered
  82430. * @return true if the system is ready
  82431. */
  82432. isReady(): boolean;
  82433. /**
  82434. * Adds a new color gradient
  82435. * @param gradient defines the gradient to use (between 0 and 1)
  82436. * @param color1 defines the color to affect to the specified gradient
  82437. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82438. * @returns the current particle system
  82439. */
  82440. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82441. /**
  82442. * Remove a specific color gradient
  82443. * @param gradient defines the gradient to remove
  82444. * @returns the current particle system
  82445. */
  82446. removeColorGradient(gradient: number): IParticleSystem;
  82447. /**
  82448. * Adds a new size gradient
  82449. * @param gradient defines the gradient to use (between 0 and 1)
  82450. * @param factor defines the size factor to affect to the specified gradient
  82451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82452. * @returns the current particle system
  82453. */
  82454. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82455. /**
  82456. * Remove a specific size gradient
  82457. * @param gradient defines the gradient to remove
  82458. * @returns the current particle system
  82459. */
  82460. removeSizeGradient(gradient: number): IParticleSystem;
  82461. /**
  82462. * Gets the current list of color gradients.
  82463. * You must use addColorGradient and removeColorGradient to udpate this list
  82464. * @returns the list of color gradients
  82465. */
  82466. getColorGradients(): Nullable<Array<ColorGradient>>;
  82467. /**
  82468. * Gets the current list of size gradients.
  82469. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82470. * @returns the list of size gradients
  82471. */
  82472. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82473. /**
  82474. * Gets the current list of angular speed gradients.
  82475. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82476. * @returns the list of angular speed gradients
  82477. */
  82478. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82479. /**
  82480. * Adds a new angular speed gradient
  82481. * @param gradient defines the gradient to use (between 0 and 1)
  82482. * @param factor defines the angular speed to affect to the specified gradient
  82483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82484. * @returns the current particle system
  82485. */
  82486. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82487. /**
  82488. * Remove a specific angular speed gradient
  82489. * @param gradient defines the gradient to remove
  82490. * @returns the current particle system
  82491. */
  82492. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82493. /**
  82494. * Gets the current list of velocity gradients.
  82495. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82496. * @returns the list of velocity gradients
  82497. */
  82498. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82499. /**
  82500. * Adds a new velocity gradient
  82501. * @param gradient defines the gradient to use (between 0 and 1)
  82502. * @param factor defines the velocity to affect to the specified gradient
  82503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82504. * @returns the current particle system
  82505. */
  82506. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82507. /**
  82508. * Remove a specific velocity gradient
  82509. * @param gradient defines the gradient to remove
  82510. * @returns the current particle system
  82511. */
  82512. removeVelocityGradient(gradient: number): IParticleSystem;
  82513. /**
  82514. * Gets the current list of limit velocity gradients.
  82515. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82516. * @returns the list of limit velocity gradients
  82517. */
  82518. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82519. /**
  82520. * Adds a new limit velocity gradient
  82521. * @param gradient defines the gradient to use (between 0 and 1)
  82522. * @param factor defines the limit velocity to affect to the specified gradient
  82523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82524. * @returns the current particle system
  82525. */
  82526. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82527. /**
  82528. * Remove a specific limit velocity gradient
  82529. * @param gradient defines the gradient to remove
  82530. * @returns the current particle system
  82531. */
  82532. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82533. /**
  82534. * Adds a new drag gradient
  82535. * @param gradient defines the gradient to use (between 0 and 1)
  82536. * @param factor defines the drag to affect to the specified gradient
  82537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82538. * @returns the current particle system
  82539. */
  82540. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82541. /**
  82542. * Remove a specific drag gradient
  82543. * @param gradient defines the gradient to remove
  82544. * @returns the current particle system
  82545. */
  82546. removeDragGradient(gradient: number): IParticleSystem;
  82547. /**
  82548. * Gets the current list of drag gradients.
  82549. * You must use addDragGradient and removeDragGradient to udpate this list
  82550. * @returns the list of drag gradients
  82551. */
  82552. getDragGradients(): Nullable<Array<FactorGradient>>;
  82553. /**
  82554. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82555. * @param gradient defines the gradient to use (between 0 and 1)
  82556. * @param factor defines the emit rate to affect to the specified gradient
  82557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82558. * @returns the current particle system
  82559. */
  82560. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82561. /**
  82562. * Remove a specific emit rate gradient
  82563. * @param gradient defines the gradient to remove
  82564. * @returns the current particle system
  82565. */
  82566. removeEmitRateGradient(gradient: number): IParticleSystem;
  82567. /**
  82568. * Gets the current list of emit rate gradients.
  82569. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82570. * @returns the list of emit rate gradients
  82571. */
  82572. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82573. /**
  82574. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82575. * @param gradient defines the gradient to use (between 0 and 1)
  82576. * @param factor defines the start size to affect to the specified gradient
  82577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82578. * @returns the current particle system
  82579. */
  82580. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82581. /**
  82582. * Remove a specific start size gradient
  82583. * @param gradient defines the gradient to remove
  82584. * @returns the current particle system
  82585. */
  82586. removeStartSizeGradient(gradient: number): IParticleSystem;
  82587. /**
  82588. * Gets the current list of start size gradients.
  82589. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82590. * @returns the list of start size gradients
  82591. */
  82592. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82593. /**
  82594. * Adds a new life time gradient
  82595. * @param gradient defines the gradient to use (between 0 and 1)
  82596. * @param factor defines the life time factor to affect to the specified gradient
  82597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82598. * @returns the current particle system
  82599. */
  82600. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82601. /**
  82602. * Remove a specific life time gradient
  82603. * @param gradient defines the gradient to remove
  82604. * @returns the current particle system
  82605. */
  82606. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82607. /**
  82608. * Gets the current list of life time gradients.
  82609. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82610. * @returns the list of life time gradients
  82611. */
  82612. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82613. /**
  82614. * Gets the current list of color gradients.
  82615. * You must use addColorGradient and removeColorGradient to udpate this list
  82616. * @returns the list of color gradients
  82617. */
  82618. getColorGradients(): Nullable<Array<ColorGradient>>;
  82619. /**
  82620. * Adds a new ramp gradient used to remap particle colors
  82621. * @param gradient defines the gradient to use (between 0 and 1)
  82622. * @param color defines the color to affect to the specified gradient
  82623. * @returns the current particle system
  82624. */
  82625. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82626. /**
  82627. * Gets the current list of ramp gradients.
  82628. * You must use addRampGradient and removeRampGradient to udpate this list
  82629. * @returns the list of ramp gradients
  82630. */
  82631. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82632. /** Gets or sets a boolean indicating that ramp gradients must be used
  82633. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82634. */
  82635. useRampGradients: boolean;
  82636. /**
  82637. * Adds a new color remap gradient
  82638. * @param gradient defines the gradient to use (between 0 and 1)
  82639. * @param min defines the color remap minimal range
  82640. * @param max defines the color remap maximal range
  82641. * @returns the current particle system
  82642. */
  82643. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82644. /**
  82645. * Gets the current list of color remap gradients.
  82646. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82647. * @returns the list of color remap gradients
  82648. */
  82649. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82650. /**
  82651. * Adds a new alpha remap gradient
  82652. * @param gradient defines the gradient to use (between 0 and 1)
  82653. * @param min defines the alpha remap minimal range
  82654. * @param max defines the alpha remap maximal range
  82655. * @returns the current particle system
  82656. */
  82657. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82658. /**
  82659. * Gets the current list of alpha remap gradients.
  82660. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82661. * @returns the list of alpha remap gradients
  82662. */
  82663. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82664. /**
  82665. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82668. * @returns the emitter
  82669. */
  82670. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82671. /**
  82672. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82673. * @param radius The radius of the hemisphere to emit from
  82674. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82675. * @returns the emitter
  82676. */
  82677. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82678. /**
  82679. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82680. * @param radius The radius of the sphere to emit from
  82681. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82682. * @returns the emitter
  82683. */
  82684. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82685. /**
  82686. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82687. * @param radius The radius of the sphere to emit from
  82688. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82689. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82690. * @returns the emitter
  82691. */
  82692. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82693. /**
  82694. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82695. * @param radius The radius of the emission cylinder
  82696. * @param height The height of the emission cylinder
  82697. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82698. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82699. * @returns the emitter
  82700. */
  82701. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82702. /**
  82703. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82704. * @param radius The radius of the cylinder to emit from
  82705. * @param height The height of the emission cylinder
  82706. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82709. * @returns the emitter
  82710. */
  82711. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82712. /**
  82713. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82714. * @param radius The radius of the cone to emit from
  82715. * @param angle The base angle of the cone
  82716. * @returns the emitter
  82717. */
  82718. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82719. /**
  82720. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82721. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82722. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82723. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82724. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82725. * @returns the emitter
  82726. */
  82727. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82728. /**
  82729. * Get hosting scene
  82730. * @returns the scene
  82731. */
  82732. getScene(): Scene;
  82733. }
  82734. }
  82735. declare module BABYLON {
  82736. /**
  82737. * Creates an instance based on a source mesh.
  82738. */
  82739. export class InstancedMesh extends AbstractMesh {
  82740. private _sourceMesh;
  82741. private _currentLOD;
  82742. /** @hidden */
  82743. _indexInSourceMeshInstanceArray: number;
  82744. constructor(name: string, source: Mesh);
  82745. /**
  82746. * Returns the string "InstancedMesh".
  82747. */
  82748. getClassName(): string;
  82749. /** Gets the list of lights affecting that mesh */
  82750. readonly lightSources: Light[];
  82751. _resyncLightSources(): void;
  82752. _resyncLighSource(light: Light): void;
  82753. _removeLightSource(light: Light): void;
  82754. /**
  82755. * If the source mesh receives shadows
  82756. */
  82757. readonly receiveShadows: boolean;
  82758. /**
  82759. * The material of the source mesh
  82760. */
  82761. readonly material: Nullable<Material>;
  82762. /**
  82763. * Visibility of the source mesh
  82764. */
  82765. readonly visibility: number;
  82766. /**
  82767. * Skeleton of the source mesh
  82768. */
  82769. readonly skeleton: Nullable<Skeleton>;
  82770. /**
  82771. * Rendering ground id of the source mesh
  82772. */
  82773. renderingGroupId: number;
  82774. /**
  82775. * Returns the total number of vertices (integer).
  82776. */
  82777. getTotalVertices(): number;
  82778. /**
  82779. * Returns a positive integer : the total number of indices in this mesh geometry.
  82780. * @returns the numner of indices or zero if the mesh has no geometry.
  82781. */
  82782. getTotalIndices(): number;
  82783. /**
  82784. * The source mesh of the instance
  82785. */
  82786. readonly sourceMesh: Mesh;
  82787. /**
  82788. * Is this node ready to be used/rendered
  82789. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82790. * @return {boolean} is it ready
  82791. */
  82792. isReady(completeCheck?: boolean): boolean;
  82793. /**
  82794. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82795. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82796. * @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.
  82797. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82798. */
  82799. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82800. /**
  82801. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82802. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82803. * The `data` are either a numeric array either a Float32Array.
  82804. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82805. * 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).
  82806. * Note that a new underlying VertexBuffer object is created each call.
  82807. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82808. *
  82809. * Possible `kind` values :
  82810. * - VertexBuffer.PositionKind
  82811. * - VertexBuffer.UVKind
  82812. * - VertexBuffer.UV2Kind
  82813. * - VertexBuffer.UV3Kind
  82814. * - VertexBuffer.UV4Kind
  82815. * - VertexBuffer.UV5Kind
  82816. * - VertexBuffer.UV6Kind
  82817. * - VertexBuffer.ColorKind
  82818. * - VertexBuffer.MatricesIndicesKind
  82819. * - VertexBuffer.MatricesIndicesExtraKind
  82820. * - VertexBuffer.MatricesWeightsKind
  82821. * - VertexBuffer.MatricesWeightsExtraKind
  82822. *
  82823. * Returns the Mesh.
  82824. */
  82825. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82826. /**
  82827. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82828. * If the mesh has no geometry, it is simply returned as it is.
  82829. * The `data` are either a numeric array either a Float32Array.
  82830. * No new underlying VertexBuffer object is created.
  82831. * 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.
  82832. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82833. *
  82834. * Possible `kind` values :
  82835. * - VertexBuffer.PositionKind
  82836. * - VertexBuffer.UVKind
  82837. * - VertexBuffer.UV2Kind
  82838. * - VertexBuffer.UV3Kind
  82839. * - VertexBuffer.UV4Kind
  82840. * - VertexBuffer.UV5Kind
  82841. * - VertexBuffer.UV6Kind
  82842. * - VertexBuffer.ColorKind
  82843. * - VertexBuffer.MatricesIndicesKind
  82844. * - VertexBuffer.MatricesIndicesExtraKind
  82845. * - VertexBuffer.MatricesWeightsKind
  82846. * - VertexBuffer.MatricesWeightsExtraKind
  82847. *
  82848. * Returns the Mesh.
  82849. */
  82850. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82851. /**
  82852. * Sets the mesh indices.
  82853. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82854. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82855. * This method creates a new index buffer each call.
  82856. * Returns the Mesh.
  82857. */
  82858. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82859. /**
  82860. * Boolean : True if the mesh owns the requested kind of data.
  82861. */
  82862. isVerticesDataPresent(kind: string): boolean;
  82863. /**
  82864. * Returns an array of indices (IndicesArray).
  82865. */
  82866. getIndices(): Nullable<IndicesArray>;
  82867. readonly _positions: Nullable<Vector3[]>;
  82868. /**
  82869. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82870. * This means the mesh underlying bounding box and sphere are recomputed.
  82871. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82872. * @returns the current mesh
  82873. */
  82874. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82875. /** @hidden */
  82876. _preActivate(): InstancedMesh;
  82877. /** @hidden */
  82878. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82879. /** @hidden */
  82880. _postActivate(): void;
  82881. getWorldMatrix(): Matrix;
  82882. readonly isAnInstance: boolean;
  82883. /**
  82884. * Returns the current associated LOD AbstractMesh.
  82885. */
  82886. getLOD(camera: Camera): AbstractMesh;
  82887. /** @hidden */
  82888. _syncSubMeshes(): InstancedMesh;
  82889. /** @hidden */
  82890. _generatePointsArray(): boolean;
  82891. /**
  82892. * Creates a new InstancedMesh from the current mesh.
  82893. * - name (string) : the cloned mesh name
  82894. * - newParent (optional Node) : the optional Node to parent the clone to.
  82895. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82896. *
  82897. * Returns the clone.
  82898. */
  82899. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82900. /**
  82901. * Disposes the InstancedMesh.
  82902. * Returns nothing.
  82903. */
  82904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82905. }
  82906. }
  82907. declare module BABYLON {
  82908. /**
  82909. * Defines the options associated with the creation of a shader material.
  82910. */
  82911. export interface IShaderMaterialOptions {
  82912. /**
  82913. * Does the material work in alpha blend mode
  82914. */
  82915. needAlphaBlending: boolean;
  82916. /**
  82917. * Does the material work in alpha test mode
  82918. */
  82919. needAlphaTesting: boolean;
  82920. /**
  82921. * The list of attribute names used in the shader
  82922. */
  82923. attributes: string[];
  82924. /**
  82925. * The list of unifrom names used in the shader
  82926. */
  82927. uniforms: string[];
  82928. /**
  82929. * The list of UBO names used in the shader
  82930. */
  82931. uniformBuffers: string[];
  82932. /**
  82933. * The list of sampler names used in the shader
  82934. */
  82935. samplers: string[];
  82936. /**
  82937. * The list of defines used in the shader
  82938. */
  82939. defines: string[];
  82940. }
  82941. /**
  82942. * 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.
  82943. *
  82944. * This returned material effects how the mesh will look based on the code in the shaders.
  82945. *
  82946. * @see http://doc.babylonjs.com/how_to/shader_material
  82947. */
  82948. export class ShaderMaterial extends Material {
  82949. private _shaderPath;
  82950. private _options;
  82951. private _textures;
  82952. private _textureArrays;
  82953. private _floats;
  82954. private _ints;
  82955. private _floatsArrays;
  82956. private _colors3;
  82957. private _colors3Arrays;
  82958. private _colors4;
  82959. private _colors4Arrays;
  82960. private _vectors2;
  82961. private _vectors3;
  82962. private _vectors4;
  82963. private _matrices;
  82964. private _matrices3x3;
  82965. private _matrices2x2;
  82966. private _vectors2Arrays;
  82967. private _vectors3Arrays;
  82968. private _vectors4Arrays;
  82969. private _cachedWorldViewMatrix;
  82970. private _cachedWorldViewProjectionMatrix;
  82971. private _renderId;
  82972. /**
  82973. * Instantiate a new shader material.
  82974. * 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.
  82975. * This returned material effects how the mesh will look based on the code in the shaders.
  82976. * @see http://doc.babylonjs.com/how_to/shader_material
  82977. * @param name Define the name of the material in the scene
  82978. * @param scene Define the scene the material belongs to
  82979. * @param shaderPath Defines the route to the shader code in one of three ways:
  82980. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82981. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82982. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82983. * @param options Define the options used to create the shader
  82984. */
  82985. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82986. /**
  82987. * Gets the options used to compile the shader.
  82988. * They can be modified to trigger a new compilation
  82989. */
  82990. readonly options: IShaderMaterialOptions;
  82991. /**
  82992. * Gets the current class name of the material e.g. "ShaderMaterial"
  82993. * Mainly use in serialization.
  82994. * @returns the class name
  82995. */
  82996. getClassName(): string;
  82997. /**
  82998. * Specifies if the material will require alpha blending
  82999. * @returns a boolean specifying if alpha blending is needed
  83000. */
  83001. needAlphaBlending(): boolean;
  83002. /**
  83003. * Specifies if this material should be rendered in alpha test mode
  83004. * @returns a boolean specifying if an alpha test is needed.
  83005. */
  83006. needAlphaTesting(): boolean;
  83007. private _checkUniform;
  83008. /**
  83009. * Set a texture in the shader.
  83010. * @param name Define the name of the uniform samplers as defined in the shader
  83011. * @param texture Define the texture to bind to this sampler
  83012. * @return the material itself allowing "fluent" like uniform updates
  83013. */
  83014. setTexture(name: string, texture: Texture): ShaderMaterial;
  83015. /**
  83016. * Set a texture array in the shader.
  83017. * @param name Define the name of the uniform sampler array as defined in the shader
  83018. * @param textures Define the list of textures to bind to this sampler
  83019. * @return the material itself allowing "fluent" like uniform updates
  83020. */
  83021. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  83022. /**
  83023. * Set a float in the shader.
  83024. * @param name Define the name of the uniform as defined in the shader
  83025. * @param value Define the value to give to the uniform
  83026. * @return the material itself allowing "fluent" like uniform updates
  83027. */
  83028. setFloat(name: string, value: number): ShaderMaterial;
  83029. /**
  83030. * Set a int in the shader.
  83031. * @param name Define the name of the uniform as defined in the shader
  83032. * @param value Define the value to give to the uniform
  83033. * @return the material itself allowing "fluent" like uniform updates
  83034. */
  83035. setInt(name: string, value: number): ShaderMaterial;
  83036. /**
  83037. * Set an array of floats in the shader.
  83038. * @param name Define the name of the uniform as defined in the shader
  83039. * @param value Define the value to give to the uniform
  83040. * @return the material itself allowing "fluent" like uniform updates
  83041. */
  83042. setFloats(name: string, value: number[]): ShaderMaterial;
  83043. /**
  83044. * Set a vec3 in the shader from a Color3.
  83045. * @param name Define the name of the uniform as defined in the shader
  83046. * @param value Define the value to give to the uniform
  83047. * @return the material itself allowing "fluent" like uniform updates
  83048. */
  83049. setColor3(name: string, value: Color3): ShaderMaterial;
  83050. /**
  83051. * Set a vec3 array in the shader from a Color3 array.
  83052. * @param name Define the name of the uniform as defined in the shader
  83053. * @param value Define the value to give to the uniform
  83054. * @return the material itself allowing "fluent" like uniform updates
  83055. */
  83056. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  83057. /**
  83058. * Set a vec4 in the shader from a Color4.
  83059. * @param name Define the name of the uniform as defined in the shader
  83060. * @param value Define the value to give to the uniform
  83061. * @return the material itself allowing "fluent" like uniform updates
  83062. */
  83063. setColor4(name: string, value: Color4): ShaderMaterial;
  83064. /**
  83065. * Set a vec4 array in the shader from a Color4 array.
  83066. * @param name Define the name of the uniform as defined in the shader
  83067. * @param value Define the value to give to the uniform
  83068. * @return the material itself allowing "fluent" like uniform updates
  83069. */
  83070. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  83071. /**
  83072. * Set a vec2 in the shader from a Vector2.
  83073. * @param name Define the name of the uniform as defined in the shader
  83074. * @param value Define the value to give to the uniform
  83075. * @return the material itself allowing "fluent" like uniform updates
  83076. */
  83077. setVector2(name: string, value: Vector2): ShaderMaterial;
  83078. /**
  83079. * Set a vec3 in the shader from a Vector3.
  83080. * @param name Define the name of the uniform as defined in the shader
  83081. * @param value Define the value to give to the uniform
  83082. * @return the material itself allowing "fluent" like uniform updates
  83083. */
  83084. setVector3(name: string, value: Vector3): ShaderMaterial;
  83085. /**
  83086. * Set a vec4 in the shader from a Vector4.
  83087. * @param name Define the name of the uniform as defined in the shader
  83088. * @param value Define the value to give to the uniform
  83089. * @return the material itself allowing "fluent" like uniform updates
  83090. */
  83091. setVector4(name: string, value: Vector4): ShaderMaterial;
  83092. /**
  83093. * Set a mat4 in the shader from a Matrix.
  83094. * @param name Define the name of the uniform as defined in the shader
  83095. * @param value Define the value to give to the uniform
  83096. * @return the material itself allowing "fluent" like uniform updates
  83097. */
  83098. setMatrix(name: string, value: Matrix): ShaderMaterial;
  83099. /**
  83100. * Set a mat3 in the shader from a Float32Array.
  83101. * @param name Define the name of the uniform as defined in the shader
  83102. * @param value Define the value to give to the uniform
  83103. * @return the material itself allowing "fluent" like uniform updates
  83104. */
  83105. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  83106. /**
  83107. * Set a mat2 in the shader from a Float32Array.
  83108. * @param name Define the name of the uniform as defined in the shader
  83109. * @param value Define the value to give to the uniform
  83110. * @return the material itself allowing "fluent" like uniform updates
  83111. */
  83112. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  83113. /**
  83114. * Set a vec2 array in the shader from a number array.
  83115. * @param name Define the name of the uniform as defined in the shader
  83116. * @param value Define the value to give to the uniform
  83117. * @return the material itself allowing "fluent" like uniform updates
  83118. */
  83119. setArray2(name: string, value: number[]): ShaderMaterial;
  83120. /**
  83121. * Set a vec3 array in the shader from a number array.
  83122. * @param name Define the name of the uniform as defined in the shader
  83123. * @param value Define the value to give to the uniform
  83124. * @return the material itself allowing "fluent" like uniform updates
  83125. */
  83126. setArray3(name: string, value: number[]): ShaderMaterial;
  83127. /**
  83128. * Set a vec4 array in the shader from a number array.
  83129. * @param name Define the name of the uniform as defined in the shader
  83130. * @param value Define the value to give to the uniform
  83131. * @return the material itself allowing "fluent" like uniform updates
  83132. */
  83133. setArray4(name: string, value: number[]): ShaderMaterial;
  83134. private _checkCache;
  83135. /**
  83136. * Specifies that the submesh is ready to be used
  83137. * @param mesh defines the mesh to check
  83138. * @param subMesh defines which submesh to check
  83139. * @param useInstances specifies that instances should be used
  83140. * @returns a boolean indicating that the submesh is ready or not
  83141. */
  83142. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83143. /**
  83144. * Checks if the material is ready to render the requested mesh
  83145. * @param mesh Define the mesh to render
  83146. * @param useInstances Define whether or not the material is used with instances
  83147. * @returns true if ready, otherwise false
  83148. */
  83149. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83150. /**
  83151. * Binds the world matrix to the material
  83152. * @param world defines the world transformation matrix
  83153. */
  83154. bindOnlyWorldMatrix(world: Matrix): void;
  83155. /**
  83156. * Binds the material to the mesh
  83157. * @param world defines the world transformation matrix
  83158. * @param mesh defines the mesh to bind the material to
  83159. */
  83160. bind(world: Matrix, mesh?: Mesh): void;
  83161. /**
  83162. * Gets the active textures from the material
  83163. * @returns an array of textures
  83164. */
  83165. getActiveTextures(): BaseTexture[];
  83166. /**
  83167. * Specifies if the material uses a texture
  83168. * @param texture defines the texture to check against the material
  83169. * @returns a boolean specifying if the material uses the texture
  83170. */
  83171. hasTexture(texture: BaseTexture): boolean;
  83172. /**
  83173. * Makes a duplicate of the material, and gives it a new name
  83174. * @param name defines the new name for the duplicated material
  83175. * @returns the cloned material
  83176. */
  83177. clone(name: string): ShaderMaterial;
  83178. /**
  83179. * Disposes the material
  83180. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83181. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  83182. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  83183. */
  83184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  83185. /**
  83186. * Serializes this material in a JSON representation
  83187. * @returns the serialized material object
  83188. */
  83189. serialize(): any;
  83190. /**
  83191. * Creates a shader material from parsed shader material data
  83192. * @param source defines the JSON represnetation of the material
  83193. * @param scene defines the hosting scene
  83194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83195. * @returns a new material
  83196. */
  83197. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  83198. }
  83199. }
  83200. declare module BABYLON {
  83201. /** @hidden */
  83202. export var colorPixelShader: {
  83203. name: string;
  83204. shader: string;
  83205. };
  83206. }
  83207. declare module BABYLON {
  83208. /** @hidden */
  83209. export var colorVertexShader: {
  83210. name: string;
  83211. shader: string;
  83212. };
  83213. }
  83214. declare module BABYLON {
  83215. /**
  83216. * Line mesh
  83217. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83218. */
  83219. export class LinesMesh extends Mesh {
  83220. /**
  83221. * If vertex color should be applied to the mesh
  83222. */
  83223. readonly useVertexColor?: boolean | undefined;
  83224. /**
  83225. * If vertex alpha should be applied to the mesh
  83226. */
  83227. readonly useVertexAlpha?: boolean | undefined;
  83228. /**
  83229. * Color of the line (Default: White)
  83230. */
  83231. color: Color3;
  83232. /**
  83233. * Alpha of the line (Default: 1)
  83234. */
  83235. alpha: number;
  83236. /**
  83237. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83238. * This margin is expressed in world space coordinates, so its value may vary.
  83239. * Default value is 0.1
  83240. */
  83241. intersectionThreshold: number;
  83242. private _colorShader;
  83243. private color4;
  83244. /**
  83245. * Creates a new LinesMesh
  83246. * @param name defines the name
  83247. * @param scene defines the hosting scene
  83248. * @param parent defines the parent mesh if any
  83249. * @param source defines the optional source LinesMesh used to clone data from
  83250. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83251. * When false, achieved by calling a clone(), also passing False.
  83252. * This will make creation of children, recursive.
  83253. * @param useVertexColor defines if this LinesMesh supports vertex color
  83254. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83255. */
  83256. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  83257. /**
  83258. * If vertex color should be applied to the mesh
  83259. */
  83260. useVertexColor?: boolean | undefined,
  83261. /**
  83262. * If vertex alpha should be applied to the mesh
  83263. */
  83264. useVertexAlpha?: boolean | undefined);
  83265. private _addClipPlaneDefine;
  83266. private _removeClipPlaneDefine;
  83267. isReady(): boolean;
  83268. /**
  83269. * Returns the string "LineMesh"
  83270. */
  83271. getClassName(): string;
  83272. /**
  83273. * @hidden
  83274. */
  83275. /**
  83276. * @hidden
  83277. */
  83278. material: Material;
  83279. /**
  83280. * @hidden
  83281. */
  83282. readonly checkCollisions: boolean;
  83283. /** @hidden */
  83284. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  83285. /** @hidden */
  83286. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  83287. /**
  83288. * Disposes of the line mesh
  83289. * @param doNotRecurse If children should be disposed
  83290. */
  83291. dispose(doNotRecurse?: boolean): void;
  83292. /**
  83293. * Returns a new LineMesh object cloned from the current one.
  83294. */
  83295. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  83296. /**
  83297. * Creates a new InstancedLinesMesh object from the mesh model.
  83298. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83299. * @param name defines the name of the new instance
  83300. * @returns a new InstancedLinesMesh
  83301. */
  83302. createInstance(name: string): InstancedLinesMesh;
  83303. }
  83304. /**
  83305. * Creates an instance based on a source LinesMesh
  83306. */
  83307. export class InstancedLinesMesh extends InstancedMesh {
  83308. /**
  83309. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  83310. * This margin is expressed in world space coordinates, so its value may vary.
  83311. * Initilized with the intersectionThreshold value of the source LinesMesh
  83312. */
  83313. intersectionThreshold: number;
  83314. constructor(name: string, source: LinesMesh);
  83315. /**
  83316. * Returns the string "InstancedLinesMesh".
  83317. */
  83318. getClassName(): string;
  83319. }
  83320. }
  83321. declare module BABYLON {
  83322. /** @hidden */
  83323. export var linePixelShader: {
  83324. name: string;
  83325. shader: string;
  83326. };
  83327. }
  83328. declare module BABYLON {
  83329. /** @hidden */
  83330. export var lineVertexShader: {
  83331. name: string;
  83332. shader: string;
  83333. };
  83334. }
  83335. declare module BABYLON {
  83336. interface AbstractMesh {
  83337. /**
  83338. * Gets the edgesRenderer associated with the mesh
  83339. */
  83340. edgesRenderer: Nullable<EdgesRenderer>;
  83341. }
  83342. interface LinesMesh {
  83343. /**
  83344. * Enables the edge rendering mode on the mesh.
  83345. * This mode makes the mesh edges visible
  83346. * @param epsilon defines the maximal distance between two angles to detect a face
  83347. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83348. * @returns the currentAbstractMesh
  83349. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83350. */
  83351. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83352. }
  83353. interface InstancedLinesMesh {
  83354. /**
  83355. * Enables the edge rendering mode on the mesh.
  83356. * This mode makes the mesh edges visible
  83357. * @param epsilon defines the maximal distance between two angles to detect a face
  83358. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83359. * @returns the current InstancedLinesMesh
  83360. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83361. */
  83362. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83363. }
  83364. /**
  83365. * Defines the minimum contract an Edges renderer should follow.
  83366. */
  83367. export interface IEdgesRenderer extends IDisposable {
  83368. /**
  83369. * Gets or sets a boolean indicating if the edgesRenderer is active
  83370. */
  83371. isEnabled: boolean;
  83372. /**
  83373. * Renders the edges of the attached mesh,
  83374. */
  83375. render(): void;
  83376. /**
  83377. * Checks wether or not the edges renderer is ready to render.
  83378. * @return true if ready, otherwise false.
  83379. */
  83380. isReady(): boolean;
  83381. }
  83382. /**
  83383. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83384. */
  83385. export class EdgesRenderer implements IEdgesRenderer {
  83386. /**
  83387. * Define the size of the edges with an orthographic camera
  83388. */
  83389. edgesWidthScalerForOrthographic: number;
  83390. /**
  83391. * Define the size of the edges with a perspective camera
  83392. */
  83393. edgesWidthScalerForPerspective: number;
  83394. protected _source: AbstractMesh;
  83395. protected _linesPositions: number[];
  83396. protected _linesNormals: number[];
  83397. protected _linesIndices: number[];
  83398. protected _epsilon: number;
  83399. protected _indicesCount: number;
  83400. protected _lineShader: ShaderMaterial;
  83401. protected _ib: DataBuffer;
  83402. protected _buffers: {
  83403. [key: string]: Nullable<VertexBuffer>;
  83404. };
  83405. protected _checkVerticesInsteadOfIndices: boolean;
  83406. private _meshRebuildObserver;
  83407. private _meshDisposeObserver;
  83408. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83409. isEnabled: boolean;
  83410. /**
  83411. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83412. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83413. * @param source Mesh used to create edges
  83414. * @param epsilon sum of angles in adjacency to check for edge
  83415. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83416. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83417. */
  83418. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83419. protected _prepareRessources(): void;
  83420. /** @hidden */
  83421. _rebuild(): void;
  83422. /**
  83423. * Releases the required resources for the edges renderer
  83424. */
  83425. dispose(): void;
  83426. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83427. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83428. /**
  83429. * Checks if the pair of p0 and p1 is en edge
  83430. * @param faceIndex
  83431. * @param edge
  83432. * @param faceNormals
  83433. * @param p0
  83434. * @param p1
  83435. * @private
  83436. */
  83437. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83438. /**
  83439. * push line into the position, normal and index buffer
  83440. * @protected
  83441. */
  83442. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83443. /**
  83444. * Generates lines edges from adjacencjes
  83445. * @private
  83446. */
  83447. _generateEdgesLines(): void;
  83448. /**
  83449. * Checks wether or not the edges renderer is ready to render.
  83450. * @return true if ready, otherwise false.
  83451. */
  83452. isReady(): boolean;
  83453. /**
  83454. * Renders the edges of the attached mesh,
  83455. */
  83456. render(): void;
  83457. }
  83458. /**
  83459. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83460. */
  83461. export class LineEdgesRenderer extends EdgesRenderer {
  83462. /**
  83463. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83464. * @param source LineMesh used to generate edges
  83465. * @param epsilon not important (specified angle for edge detection)
  83466. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83467. */
  83468. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83469. /**
  83470. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83471. */
  83472. _generateEdgesLines(): void;
  83473. }
  83474. }
  83475. declare module BABYLON {
  83476. /**
  83477. * This represents the object necessary to create a rendering group.
  83478. * This is exclusively used and created by the rendering manager.
  83479. * To modify the behavior, you use the available helpers in your scene or meshes.
  83480. * @hidden
  83481. */
  83482. export class RenderingGroup {
  83483. index: number;
  83484. private static _zeroVector;
  83485. private _scene;
  83486. private _opaqueSubMeshes;
  83487. private _transparentSubMeshes;
  83488. private _alphaTestSubMeshes;
  83489. private _depthOnlySubMeshes;
  83490. private _particleSystems;
  83491. private _spriteManagers;
  83492. private _opaqueSortCompareFn;
  83493. private _alphaTestSortCompareFn;
  83494. private _transparentSortCompareFn;
  83495. private _renderOpaque;
  83496. private _renderAlphaTest;
  83497. private _renderTransparent;
  83498. /** @hidden */
  83499. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83500. onBeforeTransparentRendering: () => void;
  83501. /**
  83502. * Set the opaque sort comparison function.
  83503. * If null the sub meshes will be render in the order they were created
  83504. */
  83505. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83506. /**
  83507. * Set the alpha test sort comparison function.
  83508. * If null the sub meshes will be render in the order they were created
  83509. */
  83510. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83511. /**
  83512. * Set the transparent sort comparison function.
  83513. * If null the sub meshes will be render in the order they were created
  83514. */
  83515. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83516. /**
  83517. * Creates a new rendering group.
  83518. * @param index The rendering group index
  83519. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83520. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83521. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83522. */
  83523. 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>);
  83524. /**
  83525. * Render all the sub meshes contained in the group.
  83526. * @param customRenderFunction Used to override the default render behaviour of the group.
  83527. * @returns true if rendered some submeshes.
  83528. */
  83529. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83530. /**
  83531. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83532. * @param subMeshes The submeshes to render
  83533. */
  83534. private renderOpaqueSorted;
  83535. /**
  83536. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83537. * @param subMeshes The submeshes to render
  83538. */
  83539. private renderAlphaTestSorted;
  83540. /**
  83541. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83542. * @param subMeshes The submeshes to render
  83543. */
  83544. private renderTransparentSorted;
  83545. /**
  83546. * Renders the submeshes in a specified order.
  83547. * @param subMeshes The submeshes to sort before render
  83548. * @param sortCompareFn The comparison function use to sort
  83549. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83550. * @param transparent Specifies to activate blending if true
  83551. */
  83552. private static renderSorted;
  83553. /**
  83554. * Renders the submeshes in the order they were dispatched (no sort applied).
  83555. * @param subMeshes The submeshes to render
  83556. */
  83557. private static renderUnsorted;
  83558. /**
  83559. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83560. * are rendered back to front if in the same alpha index.
  83561. *
  83562. * @param a The first submesh
  83563. * @param b The second submesh
  83564. * @returns The result of the comparison
  83565. */
  83566. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83567. /**
  83568. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83569. * are rendered back to front.
  83570. *
  83571. * @param a The first submesh
  83572. * @param b The second submesh
  83573. * @returns The result of the comparison
  83574. */
  83575. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83576. /**
  83577. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83578. * are rendered front to back (prevent overdraw).
  83579. *
  83580. * @param a The first submesh
  83581. * @param b The second submesh
  83582. * @returns The result of the comparison
  83583. */
  83584. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83585. /**
  83586. * Resets the different lists of submeshes to prepare a new frame.
  83587. */
  83588. prepare(): void;
  83589. dispose(): void;
  83590. /**
  83591. * Inserts the submesh in its correct queue depending on its material.
  83592. * @param subMesh The submesh to dispatch
  83593. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83594. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83595. */
  83596. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83597. dispatchSprites(spriteManager: ISpriteManager): void;
  83598. dispatchParticles(particleSystem: IParticleSystem): void;
  83599. private _renderParticles;
  83600. private _renderSprites;
  83601. }
  83602. }
  83603. declare module BABYLON {
  83604. /**
  83605. * Interface describing the different options available in the rendering manager
  83606. * regarding Auto Clear between groups.
  83607. */
  83608. export interface IRenderingManagerAutoClearSetup {
  83609. /**
  83610. * Defines whether or not autoclear is enable.
  83611. */
  83612. autoClear: boolean;
  83613. /**
  83614. * Defines whether or not to autoclear the depth buffer.
  83615. */
  83616. depth: boolean;
  83617. /**
  83618. * Defines whether or not to autoclear the stencil buffer.
  83619. */
  83620. stencil: boolean;
  83621. }
  83622. /**
  83623. * This class is used by the onRenderingGroupObservable
  83624. */
  83625. export class RenderingGroupInfo {
  83626. /**
  83627. * The Scene that being rendered
  83628. */
  83629. scene: Scene;
  83630. /**
  83631. * The camera currently used for the rendering pass
  83632. */
  83633. camera: Nullable<Camera>;
  83634. /**
  83635. * The ID of the renderingGroup being processed
  83636. */
  83637. renderingGroupId: number;
  83638. }
  83639. /**
  83640. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83641. * It is enable to manage the different groups as well as the different necessary sort functions.
  83642. * This should not be used directly aside of the few static configurations
  83643. */
  83644. export class RenderingManager {
  83645. /**
  83646. * The max id used for rendering groups (not included)
  83647. */
  83648. static MAX_RENDERINGGROUPS: number;
  83649. /**
  83650. * The min id used for rendering groups (included)
  83651. */
  83652. static MIN_RENDERINGGROUPS: number;
  83653. /**
  83654. * Used to globally prevent autoclearing scenes.
  83655. */
  83656. static AUTOCLEAR: boolean;
  83657. /**
  83658. * @hidden
  83659. */
  83660. _useSceneAutoClearSetup: boolean;
  83661. private _scene;
  83662. private _renderingGroups;
  83663. private _depthStencilBufferAlreadyCleaned;
  83664. private _autoClearDepthStencil;
  83665. private _customOpaqueSortCompareFn;
  83666. private _customAlphaTestSortCompareFn;
  83667. private _customTransparentSortCompareFn;
  83668. private _renderingGroupInfo;
  83669. /**
  83670. * Instantiates a new rendering group for a particular scene
  83671. * @param scene Defines the scene the groups belongs to
  83672. */
  83673. constructor(scene: Scene);
  83674. private _clearDepthStencilBuffer;
  83675. /**
  83676. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83677. * @hidden
  83678. */
  83679. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83680. /**
  83681. * Resets the different information of the group to prepare a new frame
  83682. * @hidden
  83683. */
  83684. reset(): void;
  83685. /**
  83686. * Dispose and release the group and its associated resources.
  83687. * @hidden
  83688. */
  83689. dispose(): void;
  83690. /**
  83691. * Clear the info related to rendering groups preventing retention points during dispose.
  83692. */
  83693. freeRenderingGroups(): void;
  83694. private _prepareRenderingGroup;
  83695. /**
  83696. * Add a sprite manager to the rendering manager in order to render it this frame.
  83697. * @param spriteManager Define the sprite manager to render
  83698. */
  83699. dispatchSprites(spriteManager: ISpriteManager): void;
  83700. /**
  83701. * Add a particle system to the rendering manager in order to render it this frame.
  83702. * @param particleSystem Define the particle system to render
  83703. */
  83704. dispatchParticles(particleSystem: IParticleSystem): void;
  83705. /**
  83706. * Add a submesh to the manager in order to render it this frame
  83707. * @param subMesh The submesh to dispatch
  83708. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83709. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83710. */
  83711. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83712. /**
  83713. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83714. * This allowed control for front to back rendering or reversly depending of the special needs.
  83715. *
  83716. * @param renderingGroupId The rendering group id corresponding to its index
  83717. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83718. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83719. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83720. */
  83721. 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;
  83722. /**
  83723. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83724. *
  83725. * @param renderingGroupId The rendering group id corresponding to its index
  83726. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83727. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83728. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83729. */
  83730. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83731. /**
  83732. * Gets the current auto clear configuration for one rendering group of the rendering
  83733. * manager.
  83734. * @param index the rendering group index to get the information for
  83735. * @returns The auto clear setup for the requested rendering group
  83736. */
  83737. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83738. }
  83739. }
  83740. declare module BABYLON {
  83741. /**
  83742. * This Helps creating a texture that will be created from a camera in your scene.
  83743. * It is basically a dynamic texture that could be used to create special effects for instance.
  83744. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83745. */
  83746. export class RenderTargetTexture extends Texture {
  83747. isCube: boolean;
  83748. /**
  83749. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83750. */
  83751. static readonly REFRESHRATE_RENDER_ONCE: number;
  83752. /**
  83753. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83754. */
  83755. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83756. /**
  83757. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83758. * the central point of your effect and can save a lot of performances.
  83759. */
  83760. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83761. /**
  83762. * Use this predicate to dynamically define the list of mesh you want to render.
  83763. * If set, the renderList property will be overwritten.
  83764. */
  83765. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83766. private _renderList;
  83767. /**
  83768. * Use this list to define the list of mesh you want to render.
  83769. */
  83770. renderList: Nullable<Array<AbstractMesh>>;
  83771. private _hookArray;
  83772. /**
  83773. * Define if particles should be rendered in your texture.
  83774. */
  83775. renderParticles: boolean;
  83776. /**
  83777. * Define if sprites should be rendered in your texture.
  83778. */
  83779. renderSprites: boolean;
  83780. /**
  83781. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83782. */
  83783. coordinatesMode: number;
  83784. /**
  83785. * Define the camera used to render the texture.
  83786. */
  83787. activeCamera: Nullable<Camera>;
  83788. /**
  83789. * Override the render function of the texture with your own one.
  83790. */
  83791. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83792. /**
  83793. * Define if camera post processes should be use while rendering the texture.
  83794. */
  83795. useCameraPostProcesses: boolean;
  83796. /**
  83797. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83798. */
  83799. ignoreCameraViewport: boolean;
  83800. private _postProcessManager;
  83801. private _postProcesses;
  83802. private _resizeObserver;
  83803. /**
  83804. * An event triggered when the texture is unbind.
  83805. */
  83806. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83807. /**
  83808. * An event triggered when the texture is unbind.
  83809. */
  83810. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83811. private _onAfterUnbindObserver;
  83812. /**
  83813. * Set a after unbind callback in the texture.
  83814. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83815. */
  83816. onAfterUnbind: () => void;
  83817. /**
  83818. * An event triggered before rendering the texture
  83819. */
  83820. onBeforeRenderObservable: Observable<number>;
  83821. private _onBeforeRenderObserver;
  83822. /**
  83823. * Set a before render callback in the texture.
  83824. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83825. */
  83826. onBeforeRender: (faceIndex: number) => void;
  83827. /**
  83828. * An event triggered after rendering the texture
  83829. */
  83830. onAfterRenderObservable: Observable<number>;
  83831. private _onAfterRenderObserver;
  83832. /**
  83833. * Set a after render callback in the texture.
  83834. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83835. */
  83836. onAfterRender: (faceIndex: number) => void;
  83837. /**
  83838. * An event triggered after the texture clear
  83839. */
  83840. onClearObservable: Observable<Engine>;
  83841. private _onClearObserver;
  83842. /**
  83843. * Set a clear callback in the texture.
  83844. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83845. */
  83846. onClear: (Engine: Engine) => void;
  83847. /**
  83848. * An event triggered when the texture is resized.
  83849. */
  83850. onResizeObservable: Observable<RenderTargetTexture>;
  83851. /**
  83852. * Define the clear color of the Render Target if it should be different from the scene.
  83853. */
  83854. clearColor: Color4;
  83855. protected _size: number | {
  83856. width: number;
  83857. height: number;
  83858. };
  83859. protected _initialSizeParameter: number | {
  83860. width: number;
  83861. height: number;
  83862. } | {
  83863. ratio: number;
  83864. };
  83865. protected _sizeRatio: Nullable<number>;
  83866. /** @hidden */
  83867. _generateMipMaps: boolean;
  83868. protected _renderingManager: RenderingManager;
  83869. /** @hidden */
  83870. _waitingRenderList: string[];
  83871. protected _doNotChangeAspectRatio: boolean;
  83872. protected _currentRefreshId: number;
  83873. protected _refreshRate: number;
  83874. protected _textureMatrix: Matrix;
  83875. protected _samples: number;
  83876. protected _renderTargetOptions: RenderTargetCreationOptions;
  83877. /**
  83878. * Gets render target creation options that were used.
  83879. */
  83880. readonly renderTargetOptions: RenderTargetCreationOptions;
  83881. protected _engine: Engine;
  83882. protected _onRatioRescale(): void;
  83883. /**
  83884. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83885. * It must define where the camera used to render the texture is set
  83886. */
  83887. boundingBoxPosition: Vector3;
  83888. private _boundingBoxSize;
  83889. /**
  83890. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83891. * When defined, the cubemap will switch to local mode
  83892. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83893. * @example https://www.babylonjs-playground.com/#RNASML
  83894. */
  83895. boundingBoxSize: Vector3;
  83896. /**
  83897. * In case the RTT has been created with a depth texture, get the associated
  83898. * depth texture.
  83899. * Otherwise, return null.
  83900. */
  83901. depthStencilTexture: Nullable<InternalTexture>;
  83902. /**
  83903. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83904. * or used a shadow, depth texture...
  83905. * @param name The friendly name of the texture
  83906. * @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)
  83907. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83908. * @param generateMipMaps True if mip maps need to be generated after render.
  83909. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83910. * @param type The type of the buffer in the RTT (int, half float, float...)
  83911. * @param isCube True if a cube texture needs to be created
  83912. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83913. * @param generateDepthBuffer True to generate a depth buffer
  83914. * @param generateStencilBuffer True to generate a stencil buffer
  83915. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83916. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83917. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83918. */
  83919. constructor(name: string, size: number | {
  83920. width: number;
  83921. height: number;
  83922. } | {
  83923. ratio: number;
  83924. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83925. /**
  83926. * Creates a depth stencil texture.
  83927. * This is only available in WebGL 2 or with the depth texture extension available.
  83928. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83929. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83930. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83931. */
  83932. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83933. private _processSizeParameter;
  83934. /**
  83935. * Define the number of samples to use in case of MSAA.
  83936. * It defaults to one meaning no MSAA has been enabled.
  83937. */
  83938. samples: number;
  83939. /**
  83940. * Resets the refresh counter of the texture and start bak from scratch.
  83941. * Could be useful to regenerate the texture if it is setup to render only once.
  83942. */
  83943. resetRefreshCounter(): void;
  83944. /**
  83945. * Define the refresh rate of the texture or the rendering frequency.
  83946. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83947. */
  83948. refreshRate: number;
  83949. /**
  83950. * Adds a post process to the render target rendering passes.
  83951. * @param postProcess define the post process to add
  83952. */
  83953. addPostProcess(postProcess: PostProcess): void;
  83954. /**
  83955. * Clear all the post processes attached to the render target
  83956. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83957. */
  83958. clearPostProcesses(dispose?: boolean): void;
  83959. /**
  83960. * Remove one of the post process from the list of attached post processes to the texture
  83961. * @param postProcess define the post process to remove from the list
  83962. */
  83963. removePostProcess(postProcess: PostProcess): void;
  83964. /** @hidden */
  83965. _shouldRender(): boolean;
  83966. /**
  83967. * Gets the actual render size of the texture.
  83968. * @returns the width of the render size
  83969. */
  83970. getRenderSize(): number;
  83971. /**
  83972. * Gets the actual render width of the texture.
  83973. * @returns the width of the render size
  83974. */
  83975. getRenderWidth(): number;
  83976. /**
  83977. * Gets the actual render height of the texture.
  83978. * @returns the height of the render size
  83979. */
  83980. getRenderHeight(): number;
  83981. /**
  83982. * Get if the texture can be rescaled or not.
  83983. */
  83984. readonly canRescale: boolean;
  83985. /**
  83986. * Resize the texture using a ratio.
  83987. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83988. */
  83989. scale(ratio: number): void;
  83990. /**
  83991. * Get the texture reflection matrix used to rotate/transform the reflection.
  83992. * @returns the reflection matrix
  83993. */
  83994. getReflectionTextureMatrix(): Matrix;
  83995. /**
  83996. * Resize the texture to a new desired size.
  83997. * Be carrefull as it will recreate all the data in the new texture.
  83998. * @param size Define the new size. It can be:
  83999. * - a number for squared texture,
  84000. * - an object containing { width: number, height: number }
  84001. * - or an object containing a ratio { ratio: number }
  84002. */
  84003. resize(size: number | {
  84004. width: number;
  84005. height: number;
  84006. } | {
  84007. ratio: number;
  84008. }): void;
  84009. /**
  84010. * Renders all the objects from the render list into the texture.
  84011. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84012. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84013. */
  84014. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84015. private _bestReflectionRenderTargetDimension;
  84016. /**
  84017. * @hidden
  84018. * @param faceIndex face index to bind to if this is a cubetexture
  84019. */
  84020. _bindFrameBuffer(faceIndex?: number): void;
  84021. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84022. private renderToTarget;
  84023. /**
  84024. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84025. * This allowed control for front to back rendering or reversly depending of the special needs.
  84026. *
  84027. * @param renderingGroupId The rendering group id corresponding to its index
  84028. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84029. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84030. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84031. */
  84032. 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;
  84033. /**
  84034. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84035. *
  84036. * @param renderingGroupId The rendering group id corresponding to its index
  84037. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84038. */
  84039. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84040. /**
  84041. * Clones the texture.
  84042. * @returns the cloned texture
  84043. */
  84044. clone(): RenderTargetTexture;
  84045. /**
  84046. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84047. * @returns The JSON representation of the texture
  84048. */
  84049. serialize(): any;
  84050. /**
  84051. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84052. */
  84053. disposeFramebufferObjects(): void;
  84054. /**
  84055. * Dispose the texture and release its associated resources.
  84056. */
  84057. dispose(): void;
  84058. /** @hidden */
  84059. _rebuild(): void;
  84060. /**
  84061. * Clear the info related to rendering groups preventing retention point in material dispose.
  84062. */
  84063. freeRenderingGroups(): void;
  84064. /**
  84065. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84066. * @returns the view count
  84067. */
  84068. getViewCount(): number;
  84069. }
  84070. }
  84071. declare module BABYLON {
  84072. /**
  84073. * Base class for the main features of a material in Babylon.js
  84074. */
  84075. export class Material implements IAnimatable {
  84076. /**
  84077. * Returns the triangle fill mode
  84078. */
  84079. static readonly TriangleFillMode: number;
  84080. /**
  84081. * Returns the wireframe mode
  84082. */
  84083. static readonly WireFrameFillMode: number;
  84084. /**
  84085. * Returns the point fill mode
  84086. */
  84087. static readonly PointFillMode: number;
  84088. /**
  84089. * Returns the point list draw mode
  84090. */
  84091. static readonly PointListDrawMode: number;
  84092. /**
  84093. * Returns the line list draw mode
  84094. */
  84095. static readonly LineListDrawMode: number;
  84096. /**
  84097. * Returns the line loop draw mode
  84098. */
  84099. static readonly LineLoopDrawMode: number;
  84100. /**
  84101. * Returns the line strip draw mode
  84102. */
  84103. static readonly LineStripDrawMode: number;
  84104. /**
  84105. * Returns the triangle strip draw mode
  84106. */
  84107. static readonly TriangleStripDrawMode: number;
  84108. /**
  84109. * Returns the triangle fan draw mode
  84110. */
  84111. static readonly TriangleFanDrawMode: number;
  84112. /**
  84113. * Stores the clock-wise side orientation
  84114. */
  84115. static readonly ClockWiseSideOrientation: number;
  84116. /**
  84117. * Stores the counter clock-wise side orientation
  84118. */
  84119. static readonly CounterClockWiseSideOrientation: number;
  84120. /**
  84121. * The dirty texture flag value
  84122. */
  84123. static readonly TextureDirtyFlag: number;
  84124. /**
  84125. * The dirty light flag value
  84126. */
  84127. static readonly LightDirtyFlag: number;
  84128. /**
  84129. * The dirty fresnel flag value
  84130. */
  84131. static readonly FresnelDirtyFlag: number;
  84132. /**
  84133. * The dirty attribute flag value
  84134. */
  84135. static readonly AttributesDirtyFlag: number;
  84136. /**
  84137. * The dirty misc flag value
  84138. */
  84139. static readonly MiscDirtyFlag: number;
  84140. /**
  84141. * The all dirty flag value
  84142. */
  84143. static readonly AllDirtyFlag: number;
  84144. /**
  84145. * The ID of the material
  84146. */
  84147. id: string;
  84148. /**
  84149. * Gets or sets the unique id of the material
  84150. */
  84151. uniqueId: number;
  84152. /**
  84153. * The name of the material
  84154. */
  84155. name: string;
  84156. /**
  84157. * Gets or sets user defined metadata
  84158. */
  84159. metadata: any;
  84160. /**
  84161. * For internal use only. Please do not use.
  84162. */
  84163. reservedDataStore: any;
  84164. /**
  84165. * Specifies if the ready state should be checked on each call
  84166. */
  84167. checkReadyOnEveryCall: boolean;
  84168. /**
  84169. * Specifies if the ready state should be checked once
  84170. */
  84171. checkReadyOnlyOnce: boolean;
  84172. /**
  84173. * The state of the material
  84174. */
  84175. state: string;
  84176. /**
  84177. * The alpha value of the material
  84178. */
  84179. protected _alpha: number;
  84180. /**
  84181. * List of inspectable custom properties (used by the Inspector)
  84182. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84183. */
  84184. inspectableCustomProperties: IInspectable[];
  84185. /**
  84186. * Sets the alpha value of the material
  84187. */
  84188. /**
  84189. * Gets the alpha value of the material
  84190. */
  84191. alpha: number;
  84192. /**
  84193. * Specifies if back face culling is enabled
  84194. */
  84195. protected _backFaceCulling: boolean;
  84196. /**
  84197. * Sets the back-face culling state
  84198. */
  84199. /**
  84200. * Gets the back-face culling state
  84201. */
  84202. backFaceCulling: boolean;
  84203. /**
  84204. * Stores the value for side orientation
  84205. */
  84206. sideOrientation: number;
  84207. /**
  84208. * Callback triggered when the material is compiled
  84209. */
  84210. onCompiled: Nullable<(effect: Effect) => void>;
  84211. /**
  84212. * Callback triggered when an error occurs
  84213. */
  84214. onError: Nullable<(effect: Effect, errors: string) => void>;
  84215. /**
  84216. * Callback triggered to get the render target textures
  84217. */
  84218. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84219. /**
  84220. * Gets a boolean indicating that current material needs to register RTT
  84221. */
  84222. readonly hasRenderTargetTextures: boolean;
  84223. /**
  84224. * Specifies if the material should be serialized
  84225. */
  84226. doNotSerialize: boolean;
  84227. /**
  84228. * @hidden
  84229. */
  84230. _storeEffectOnSubMeshes: boolean;
  84231. /**
  84232. * Stores the animations for the material
  84233. */
  84234. animations: Nullable<Array<Animation>>;
  84235. /**
  84236. * An event triggered when the material is disposed
  84237. */
  84238. onDisposeObservable: Observable<Material>;
  84239. /**
  84240. * An observer which watches for dispose events
  84241. */
  84242. private _onDisposeObserver;
  84243. private _onUnBindObservable;
  84244. /**
  84245. * Called during a dispose event
  84246. */
  84247. onDispose: () => void;
  84248. private _onBindObservable;
  84249. /**
  84250. * An event triggered when the material is bound
  84251. */
  84252. readonly onBindObservable: Observable<AbstractMesh>;
  84253. /**
  84254. * An observer which watches for bind events
  84255. */
  84256. private _onBindObserver;
  84257. /**
  84258. * Called during a bind event
  84259. */
  84260. onBind: (Mesh: AbstractMesh) => void;
  84261. /**
  84262. * An event triggered when the material is unbound
  84263. */
  84264. readonly onUnBindObservable: Observable<Material>;
  84265. /**
  84266. * Stores the value of the alpha mode
  84267. */
  84268. private _alphaMode;
  84269. /**
  84270. * Sets the value of the alpha mode.
  84271. *
  84272. * | Value | Type | Description |
  84273. * | --- | --- | --- |
  84274. * | 0 | ALPHA_DISABLE | |
  84275. * | 1 | ALPHA_ADD | |
  84276. * | 2 | ALPHA_COMBINE | |
  84277. * | 3 | ALPHA_SUBTRACT | |
  84278. * | 4 | ALPHA_MULTIPLY | |
  84279. * | 5 | ALPHA_MAXIMIZED | |
  84280. * | 6 | ALPHA_ONEONE | |
  84281. * | 7 | ALPHA_PREMULTIPLIED | |
  84282. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84283. * | 9 | ALPHA_INTERPOLATE | |
  84284. * | 10 | ALPHA_SCREENMODE | |
  84285. *
  84286. */
  84287. /**
  84288. * Gets the value of the alpha mode
  84289. */
  84290. alphaMode: number;
  84291. /**
  84292. * Stores the state of the need depth pre-pass value
  84293. */
  84294. private _needDepthPrePass;
  84295. /**
  84296. * Sets the need depth pre-pass value
  84297. */
  84298. /**
  84299. * Gets the depth pre-pass value
  84300. */
  84301. needDepthPrePass: boolean;
  84302. /**
  84303. * Specifies if depth writing should be disabled
  84304. */
  84305. disableDepthWrite: boolean;
  84306. /**
  84307. * Specifies if depth writing should be forced
  84308. */
  84309. forceDepthWrite: boolean;
  84310. /**
  84311. * Specifies if there should be a separate pass for culling
  84312. */
  84313. separateCullingPass: boolean;
  84314. /**
  84315. * Stores the state specifing if fog should be enabled
  84316. */
  84317. private _fogEnabled;
  84318. /**
  84319. * Sets the state for enabling fog
  84320. */
  84321. /**
  84322. * Gets the value of the fog enabled state
  84323. */
  84324. fogEnabled: boolean;
  84325. /**
  84326. * Stores the size of points
  84327. */
  84328. pointSize: number;
  84329. /**
  84330. * Stores the z offset value
  84331. */
  84332. zOffset: number;
  84333. /**
  84334. * Gets a value specifying if wireframe mode is enabled
  84335. */
  84336. /**
  84337. * Sets the state of wireframe mode
  84338. */
  84339. wireframe: boolean;
  84340. /**
  84341. * Gets the value specifying if point clouds are enabled
  84342. */
  84343. /**
  84344. * Sets the state of point cloud mode
  84345. */
  84346. pointsCloud: boolean;
  84347. /**
  84348. * Gets the material fill mode
  84349. */
  84350. /**
  84351. * Sets the material fill mode
  84352. */
  84353. fillMode: number;
  84354. /**
  84355. * @hidden
  84356. * Stores the effects for the material
  84357. */
  84358. _effect: Nullable<Effect>;
  84359. /**
  84360. * @hidden
  84361. * Specifies if the material was previously ready
  84362. */
  84363. _wasPreviouslyReady: boolean;
  84364. /**
  84365. * Specifies if uniform buffers should be used
  84366. */
  84367. private _useUBO;
  84368. /**
  84369. * Stores a reference to the scene
  84370. */
  84371. private _scene;
  84372. /**
  84373. * Stores the fill mode state
  84374. */
  84375. private _fillMode;
  84376. /**
  84377. * Specifies if the depth write state should be cached
  84378. */
  84379. private _cachedDepthWriteState;
  84380. /**
  84381. * Stores the uniform buffer
  84382. */
  84383. protected _uniformBuffer: UniformBuffer;
  84384. /** @hidden */
  84385. _indexInSceneMaterialArray: number;
  84386. /** @hidden */
  84387. meshMap: Nullable<{
  84388. [id: string]: AbstractMesh | undefined;
  84389. }>;
  84390. /**
  84391. * Creates a material instance
  84392. * @param name defines the name of the material
  84393. * @param scene defines the scene to reference
  84394. * @param doNotAdd specifies if the material should be added to the scene
  84395. */
  84396. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84397. /**
  84398. * Returns a string representation of the current material
  84399. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84400. * @returns a string with material information
  84401. */
  84402. toString(fullDetails?: boolean): string;
  84403. /**
  84404. * Gets the class name of the material
  84405. * @returns a string with the class name of the material
  84406. */
  84407. getClassName(): string;
  84408. /**
  84409. * Specifies if updates for the material been locked
  84410. */
  84411. readonly isFrozen: boolean;
  84412. /**
  84413. * Locks updates for the material
  84414. */
  84415. freeze(): void;
  84416. /**
  84417. * Unlocks updates for the material
  84418. */
  84419. unfreeze(): void;
  84420. /**
  84421. * Specifies if the material is ready to be used
  84422. * @param mesh defines the mesh to check
  84423. * @param useInstances specifies if instances should be used
  84424. * @returns a boolean indicating if the material is ready to be used
  84425. */
  84426. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84427. /**
  84428. * Specifies that the submesh is ready to be used
  84429. * @param mesh defines the mesh to check
  84430. * @param subMesh defines which submesh to check
  84431. * @param useInstances specifies that instances should be used
  84432. * @returns a boolean indicating that the submesh is ready or not
  84433. */
  84434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84435. /**
  84436. * Returns the material effect
  84437. * @returns the effect associated with the material
  84438. */
  84439. getEffect(): Nullable<Effect>;
  84440. /**
  84441. * Returns the current scene
  84442. * @returns a Scene
  84443. */
  84444. getScene(): Scene;
  84445. /**
  84446. * Specifies if the material will require alpha blending
  84447. * @returns a boolean specifying if alpha blending is needed
  84448. */
  84449. needAlphaBlending(): boolean;
  84450. /**
  84451. * Specifies if the mesh will require alpha blending
  84452. * @param mesh defines the mesh to check
  84453. * @returns a boolean specifying if alpha blending is needed for the mesh
  84454. */
  84455. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84456. /**
  84457. * Specifies if this material should be rendered in alpha test mode
  84458. * @returns a boolean specifying if an alpha test is needed.
  84459. */
  84460. needAlphaTesting(): boolean;
  84461. /**
  84462. * Gets the texture used for the alpha test
  84463. * @returns the texture to use for alpha testing
  84464. */
  84465. getAlphaTestTexture(): Nullable<BaseTexture>;
  84466. /**
  84467. * Marks the material to indicate that it needs to be re-calculated
  84468. */
  84469. markDirty(): void;
  84470. /** @hidden */
  84471. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84472. /**
  84473. * Binds the material to the mesh
  84474. * @param world defines the world transformation matrix
  84475. * @param mesh defines the mesh to bind the material to
  84476. */
  84477. bind(world: Matrix, mesh?: Mesh): void;
  84478. /**
  84479. * Binds the submesh to the material
  84480. * @param world defines the world transformation matrix
  84481. * @param mesh defines the mesh containing the submesh
  84482. * @param subMesh defines the submesh to bind the material to
  84483. */
  84484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84485. /**
  84486. * Binds the world matrix to the material
  84487. * @param world defines the world transformation matrix
  84488. */
  84489. bindOnlyWorldMatrix(world: Matrix): void;
  84490. /**
  84491. * Binds the scene's uniform buffer to the effect.
  84492. * @param effect defines the effect to bind to the scene uniform buffer
  84493. * @param sceneUbo defines the uniform buffer storing scene data
  84494. */
  84495. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84496. /**
  84497. * Binds the view matrix to the effect
  84498. * @param effect defines the effect to bind the view matrix to
  84499. */
  84500. bindView(effect: Effect): void;
  84501. /**
  84502. * Binds the view projection matrix to the effect
  84503. * @param effect defines the effect to bind the view projection matrix to
  84504. */
  84505. bindViewProjection(effect: Effect): void;
  84506. /**
  84507. * Specifies if material alpha testing should be turned on for the mesh
  84508. * @param mesh defines the mesh to check
  84509. */
  84510. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84511. /**
  84512. * Processes to execute after binding the material to a mesh
  84513. * @param mesh defines the rendered mesh
  84514. */
  84515. protected _afterBind(mesh?: Mesh): void;
  84516. /**
  84517. * Unbinds the material from the mesh
  84518. */
  84519. unbind(): void;
  84520. /**
  84521. * Gets the active textures from the material
  84522. * @returns an array of textures
  84523. */
  84524. getActiveTextures(): BaseTexture[];
  84525. /**
  84526. * Specifies if the material uses a texture
  84527. * @param texture defines the texture to check against the material
  84528. * @returns a boolean specifying if the material uses the texture
  84529. */
  84530. hasTexture(texture: BaseTexture): boolean;
  84531. /**
  84532. * Makes a duplicate of the material, and gives it a new name
  84533. * @param name defines the new name for the duplicated material
  84534. * @returns the cloned material
  84535. */
  84536. clone(name: string): Nullable<Material>;
  84537. /**
  84538. * Gets the meshes bound to the material
  84539. * @returns an array of meshes bound to the material
  84540. */
  84541. getBindedMeshes(): AbstractMesh[];
  84542. /**
  84543. * Force shader compilation
  84544. * @param mesh defines the mesh associated with this material
  84545. * @param onCompiled defines a function to execute once the material is compiled
  84546. * @param options defines the options to configure the compilation
  84547. */
  84548. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84549. clipPlane: boolean;
  84550. }>): void;
  84551. /**
  84552. * Force shader compilation
  84553. * @param mesh defines the mesh that will use this material
  84554. * @param options defines additional options for compiling the shaders
  84555. * @returns a promise that resolves when the compilation completes
  84556. */
  84557. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84558. clipPlane: boolean;
  84559. }>): Promise<void>;
  84560. private static readonly _AllDirtyCallBack;
  84561. private static readonly _ImageProcessingDirtyCallBack;
  84562. private static readonly _TextureDirtyCallBack;
  84563. private static readonly _FresnelDirtyCallBack;
  84564. private static readonly _MiscDirtyCallBack;
  84565. private static readonly _LightsDirtyCallBack;
  84566. private static readonly _AttributeDirtyCallBack;
  84567. private static _FresnelAndMiscDirtyCallBack;
  84568. private static _TextureAndMiscDirtyCallBack;
  84569. private static readonly _DirtyCallbackArray;
  84570. private static readonly _RunDirtyCallBacks;
  84571. /**
  84572. * Marks a define in the material to indicate that it needs to be re-computed
  84573. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84574. */
  84575. markAsDirty(flag: number): void;
  84576. /**
  84577. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84578. * @param func defines a function which checks material defines against the submeshes
  84579. */
  84580. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84581. /**
  84582. * Indicates that we need to re-calculated for all submeshes
  84583. */
  84584. protected _markAllSubMeshesAsAllDirty(): void;
  84585. /**
  84586. * Indicates that image processing needs to be re-calculated for all submeshes
  84587. */
  84588. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84589. /**
  84590. * Indicates that textures need to be re-calculated for all submeshes
  84591. */
  84592. protected _markAllSubMeshesAsTexturesDirty(): void;
  84593. /**
  84594. * Indicates that fresnel needs to be re-calculated for all submeshes
  84595. */
  84596. protected _markAllSubMeshesAsFresnelDirty(): void;
  84597. /**
  84598. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84599. */
  84600. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84601. /**
  84602. * Indicates that lights need to be re-calculated for all submeshes
  84603. */
  84604. protected _markAllSubMeshesAsLightsDirty(): void;
  84605. /**
  84606. * Indicates that attributes need to be re-calculated for all submeshes
  84607. */
  84608. protected _markAllSubMeshesAsAttributesDirty(): void;
  84609. /**
  84610. * Indicates that misc needs to be re-calculated for all submeshes
  84611. */
  84612. protected _markAllSubMeshesAsMiscDirty(): void;
  84613. /**
  84614. * Indicates that textures and misc need to be re-calculated for all submeshes
  84615. */
  84616. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84617. /**
  84618. * Disposes the material
  84619. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84620. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84621. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84622. */
  84623. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84624. /** @hidden */
  84625. private releaseVertexArrayObject;
  84626. /**
  84627. * Serializes this material
  84628. * @returns the serialized material object
  84629. */
  84630. serialize(): any;
  84631. /**
  84632. * Creates a material from parsed material data
  84633. * @param parsedMaterial defines parsed material data
  84634. * @param scene defines the hosting scene
  84635. * @param rootUrl defines the root URL to use to load textures
  84636. * @returns a new material
  84637. */
  84638. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84639. }
  84640. }
  84641. declare module BABYLON {
  84642. /**
  84643. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84644. * separate meshes. This can be use to improve performances.
  84645. * @see http://doc.babylonjs.com/how_to/multi_materials
  84646. */
  84647. export class MultiMaterial extends Material {
  84648. private _subMaterials;
  84649. /**
  84650. * Gets or Sets the list of Materials used within the multi material.
  84651. * They need to be ordered according to the submeshes order in the associated mesh
  84652. */
  84653. subMaterials: Nullable<Material>[];
  84654. /**
  84655. * Function used to align with Node.getChildren()
  84656. * @returns the list of Materials used within the multi material
  84657. */
  84658. getChildren(): Nullable<Material>[];
  84659. /**
  84660. * Instantiates a new Multi Material
  84661. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84662. * separate meshes. This can be use to improve performances.
  84663. * @see http://doc.babylonjs.com/how_to/multi_materials
  84664. * @param name Define the name in the scene
  84665. * @param scene Define the scene the material belongs to
  84666. */
  84667. constructor(name: string, scene: Scene);
  84668. private _hookArray;
  84669. /**
  84670. * Get one of the submaterial by its index in the submaterials array
  84671. * @param index The index to look the sub material at
  84672. * @returns The Material if the index has been defined
  84673. */
  84674. getSubMaterial(index: number): Nullable<Material>;
  84675. /**
  84676. * Get the list of active textures for the whole sub materials list.
  84677. * @returns All the textures that will be used during the rendering
  84678. */
  84679. getActiveTextures(): BaseTexture[];
  84680. /**
  84681. * Gets the current class name of the material e.g. "MultiMaterial"
  84682. * Mainly use in serialization.
  84683. * @returns the class name
  84684. */
  84685. getClassName(): string;
  84686. /**
  84687. * Checks if the material is ready to render the requested sub mesh
  84688. * @param mesh Define the mesh the submesh belongs to
  84689. * @param subMesh Define the sub mesh to look readyness for
  84690. * @param useInstances Define whether or not the material is used with instances
  84691. * @returns true if ready, otherwise false
  84692. */
  84693. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84694. /**
  84695. * Clones the current material and its related sub materials
  84696. * @param name Define the name of the newly cloned material
  84697. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84698. * @returns the cloned material
  84699. */
  84700. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84701. /**
  84702. * Serializes the materials into a JSON representation.
  84703. * @returns the JSON representation
  84704. */
  84705. serialize(): any;
  84706. /**
  84707. * Dispose the material and release its associated resources
  84708. * @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)
  84709. * @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)
  84710. * @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)
  84711. */
  84712. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84713. /**
  84714. * Creates a MultiMaterial from parsed MultiMaterial data.
  84715. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84716. * @param scene defines the hosting scene
  84717. * @returns a new MultiMaterial
  84718. */
  84719. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84720. }
  84721. }
  84722. declare module BABYLON {
  84723. /**
  84724. * Base class for submeshes
  84725. */
  84726. export class BaseSubMesh {
  84727. /** @hidden */
  84728. _materialDefines: Nullable<MaterialDefines>;
  84729. /** @hidden */
  84730. _materialEffect: Nullable<Effect>;
  84731. /**
  84732. * Gets associated effect
  84733. */
  84734. readonly effect: Nullable<Effect>;
  84735. /**
  84736. * Sets associated effect (effect used to render this submesh)
  84737. * @param effect defines the effect to associate with
  84738. * @param defines defines the set of defines used to compile this effect
  84739. */
  84740. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84741. }
  84742. /**
  84743. * Defines a subdivision inside a mesh
  84744. */
  84745. export class SubMesh extends BaseSubMesh implements ICullable {
  84746. /** the material index to use */
  84747. materialIndex: number;
  84748. /** vertex index start */
  84749. verticesStart: number;
  84750. /** vertices count */
  84751. verticesCount: number;
  84752. /** index start */
  84753. indexStart: number;
  84754. /** indices count */
  84755. indexCount: number;
  84756. /** @hidden */
  84757. _linesIndexCount: number;
  84758. private _mesh;
  84759. private _renderingMesh;
  84760. private _boundingInfo;
  84761. private _linesIndexBuffer;
  84762. /** @hidden */
  84763. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84764. /** @hidden */
  84765. _trianglePlanes: Plane[];
  84766. /** @hidden */
  84767. _lastColliderTransformMatrix: Nullable<Matrix>;
  84768. /** @hidden */
  84769. _renderId: number;
  84770. /** @hidden */
  84771. _alphaIndex: number;
  84772. /** @hidden */
  84773. _distanceToCamera: number;
  84774. /** @hidden */
  84775. _id: number;
  84776. private _currentMaterial;
  84777. /**
  84778. * Add a new submesh to a mesh
  84779. * @param materialIndex defines the material index to use
  84780. * @param verticesStart defines vertex index start
  84781. * @param verticesCount defines vertices count
  84782. * @param indexStart defines index start
  84783. * @param indexCount defines indices count
  84784. * @param mesh defines the parent mesh
  84785. * @param renderingMesh defines an optional rendering mesh
  84786. * @param createBoundingBox defines if bounding box should be created for this submesh
  84787. * @returns the new submesh
  84788. */
  84789. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84790. /**
  84791. * Creates a new submesh
  84792. * @param materialIndex defines the material index to use
  84793. * @param verticesStart defines vertex index start
  84794. * @param verticesCount defines vertices count
  84795. * @param indexStart defines index start
  84796. * @param indexCount defines indices count
  84797. * @param mesh defines the parent mesh
  84798. * @param renderingMesh defines an optional rendering mesh
  84799. * @param createBoundingBox defines if bounding box should be created for this submesh
  84800. */
  84801. constructor(
  84802. /** the material index to use */
  84803. materialIndex: number,
  84804. /** vertex index start */
  84805. verticesStart: number,
  84806. /** vertices count */
  84807. verticesCount: number,
  84808. /** index start */
  84809. indexStart: number,
  84810. /** indices count */
  84811. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84812. /**
  84813. * Returns true if this submesh covers the entire parent mesh
  84814. * @ignorenaming
  84815. */
  84816. readonly IsGlobal: boolean;
  84817. /**
  84818. * Returns the submesh BoudingInfo object
  84819. * @returns current bounding info (or mesh's one if the submesh is global)
  84820. */
  84821. getBoundingInfo(): BoundingInfo;
  84822. /**
  84823. * Sets the submesh BoundingInfo
  84824. * @param boundingInfo defines the new bounding info to use
  84825. * @returns the SubMesh
  84826. */
  84827. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84828. /**
  84829. * Returns the mesh of the current submesh
  84830. * @return the parent mesh
  84831. */
  84832. getMesh(): AbstractMesh;
  84833. /**
  84834. * Returns the rendering mesh of the submesh
  84835. * @returns the rendering mesh (could be different from parent mesh)
  84836. */
  84837. getRenderingMesh(): Mesh;
  84838. /**
  84839. * Returns the submesh material
  84840. * @returns null or the current material
  84841. */
  84842. getMaterial(): Nullable<Material>;
  84843. /**
  84844. * Sets a new updated BoundingInfo object to the submesh
  84845. * @param data defines an optional position array to use to determine the bounding info
  84846. * @returns the SubMesh
  84847. */
  84848. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84849. /** @hidden */
  84850. _checkCollision(collider: Collider): boolean;
  84851. /**
  84852. * Updates the submesh BoundingInfo
  84853. * @param world defines the world matrix to use to update the bounding info
  84854. * @returns the submesh
  84855. */
  84856. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84857. /**
  84858. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84859. * @param frustumPlanes defines the frustum planes
  84860. * @returns true if the submesh is intersecting with the frustum
  84861. */
  84862. isInFrustum(frustumPlanes: Plane[]): boolean;
  84863. /**
  84864. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84865. * @param frustumPlanes defines the frustum planes
  84866. * @returns true if the submesh is inside the frustum
  84867. */
  84868. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84869. /**
  84870. * Renders the submesh
  84871. * @param enableAlphaMode defines if alpha needs to be used
  84872. * @returns the submesh
  84873. */
  84874. render(enableAlphaMode: boolean): SubMesh;
  84875. /**
  84876. * @hidden
  84877. */
  84878. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84879. /**
  84880. * Checks if the submesh intersects with a ray
  84881. * @param ray defines the ray to test
  84882. * @returns true is the passed ray intersects the submesh bounding box
  84883. */
  84884. canIntersects(ray: Ray): boolean;
  84885. /**
  84886. * Intersects current submesh with a ray
  84887. * @param ray defines the ray to test
  84888. * @param positions defines mesh's positions array
  84889. * @param indices defines mesh's indices array
  84890. * @param fastCheck defines if only bounding info should be used
  84891. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84892. * @returns intersection info or null if no intersection
  84893. */
  84894. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84895. /** @hidden */
  84896. private _intersectLines;
  84897. /** @hidden */
  84898. private _intersectUnIndexedLines;
  84899. /** @hidden */
  84900. private _intersectTriangles;
  84901. /** @hidden */
  84902. private _intersectUnIndexedTriangles;
  84903. /** @hidden */
  84904. _rebuild(): void;
  84905. /**
  84906. * Creates a new submesh from the passed mesh
  84907. * @param newMesh defines the new hosting mesh
  84908. * @param newRenderingMesh defines an optional rendering mesh
  84909. * @returns the new submesh
  84910. */
  84911. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84912. /**
  84913. * Release associated resources
  84914. */
  84915. dispose(): void;
  84916. /**
  84917. * Gets the class name
  84918. * @returns the string "SubMesh".
  84919. */
  84920. getClassName(): string;
  84921. /**
  84922. * Creates a new submesh from indices data
  84923. * @param materialIndex the index of the main mesh material
  84924. * @param startIndex the index where to start the copy in the mesh indices array
  84925. * @param indexCount the number of indices to copy then from the startIndex
  84926. * @param mesh the main mesh to create the submesh from
  84927. * @param renderingMesh the optional rendering mesh
  84928. * @returns a new submesh
  84929. */
  84930. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84931. }
  84932. }
  84933. declare module BABYLON {
  84934. /**
  84935. * Class used to represent data loading progression
  84936. */
  84937. export class SceneLoaderFlags {
  84938. private static _ForceFullSceneLoadingForIncremental;
  84939. private static _ShowLoadingScreen;
  84940. private static _CleanBoneMatrixWeights;
  84941. private static _loggingLevel;
  84942. /**
  84943. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84944. */
  84945. static ForceFullSceneLoadingForIncremental: boolean;
  84946. /**
  84947. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84948. */
  84949. static ShowLoadingScreen: boolean;
  84950. /**
  84951. * Defines the current logging level (while loading the scene)
  84952. * @ignorenaming
  84953. */
  84954. static loggingLevel: number;
  84955. /**
  84956. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84957. */
  84958. static CleanBoneMatrixWeights: boolean;
  84959. }
  84960. }
  84961. declare module BABYLON {
  84962. /**
  84963. * Class used to store geometry data (vertex buffers + index buffer)
  84964. */
  84965. export class Geometry implements IGetSetVerticesData {
  84966. /**
  84967. * Gets or sets the ID of the geometry
  84968. */
  84969. id: string;
  84970. /**
  84971. * Gets or sets the unique ID of the geometry
  84972. */
  84973. uniqueId: number;
  84974. /**
  84975. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84976. */
  84977. delayLoadState: number;
  84978. /**
  84979. * Gets the file containing the data to load when running in delay load state
  84980. */
  84981. delayLoadingFile: Nullable<string>;
  84982. /**
  84983. * Callback called when the geometry is updated
  84984. */
  84985. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84986. private _scene;
  84987. private _engine;
  84988. private _meshes;
  84989. private _totalVertices;
  84990. /** @hidden */
  84991. _indices: IndicesArray;
  84992. /** @hidden */
  84993. _vertexBuffers: {
  84994. [key: string]: VertexBuffer;
  84995. };
  84996. private _isDisposed;
  84997. private _extend;
  84998. private _boundingBias;
  84999. /** @hidden */
  85000. _delayInfo: Array<string>;
  85001. private _indexBuffer;
  85002. private _indexBufferIsUpdatable;
  85003. /** @hidden */
  85004. _boundingInfo: Nullable<BoundingInfo>;
  85005. /** @hidden */
  85006. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85007. /** @hidden */
  85008. _softwareSkinningFrameId: number;
  85009. private _vertexArrayObjects;
  85010. private _updatable;
  85011. /** @hidden */
  85012. _positions: Nullable<Vector3[]>;
  85013. /**
  85014. * 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
  85015. */
  85016. /**
  85017. * 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
  85018. */
  85019. boundingBias: Vector2;
  85020. /**
  85021. * Static function used to attach a new empty geometry to a mesh
  85022. * @param mesh defines the mesh to attach the geometry to
  85023. * @returns the new Geometry
  85024. */
  85025. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85026. /**
  85027. * Creates a new geometry
  85028. * @param id defines the unique ID
  85029. * @param scene defines the hosting scene
  85030. * @param vertexData defines the VertexData used to get geometry data
  85031. * @param updatable defines if geometry must be updatable (false by default)
  85032. * @param mesh defines the mesh that will be associated with the geometry
  85033. */
  85034. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85035. /**
  85036. * Gets the current extend of the geometry
  85037. */
  85038. readonly extend: {
  85039. minimum: Vector3;
  85040. maximum: Vector3;
  85041. };
  85042. /**
  85043. * Gets the hosting scene
  85044. * @returns the hosting Scene
  85045. */
  85046. getScene(): Scene;
  85047. /**
  85048. * Gets the hosting engine
  85049. * @returns the hosting Engine
  85050. */
  85051. getEngine(): Engine;
  85052. /**
  85053. * Defines if the geometry is ready to use
  85054. * @returns true if the geometry is ready to be used
  85055. */
  85056. isReady(): boolean;
  85057. /**
  85058. * Gets a value indicating that the geometry should not be serialized
  85059. */
  85060. readonly doNotSerialize: boolean;
  85061. /** @hidden */
  85062. _rebuild(): void;
  85063. /**
  85064. * Affects all geometry data in one call
  85065. * @param vertexData defines the geometry data
  85066. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85067. */
  85068. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85069. /**
  85070. * Set specific vertex data
  85071. * @param kind defines the data kind (Position, normal, etc...)
  85072. * @param data defines the vertex data to use
  85073. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85074. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85075. */
  85076. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85077. /**
  85078. * Removes a specific vertex data
  85079. * @param kind defines the data kind (Position, normal, etc...)
  85080. */
  85081. removeVerticesData(kind: string): void;
  85082. /**
  85083. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85084. * @param buffer defines the vertex buffer to use
  85085. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85086. */
  85087. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85088. /**
  85089. * Update a specific vertex buffer
  85090. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85091. * It will do nothing if the buffer is not updatable
  85092. * @param kind defines the data kind (Position, normal, etc...)
  85093. * @param data defines the data to use
  85094. * @param offset defines the offset in the target buffer where to store the data
  85095. * @param useBytes set to true if the offset is in bytes
  85096. */
  85097. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85098. /**
  85099. * Update a specific vertex buffer
  85100. * This function will create a new buffer if the current one is not updatable
  85101. * @param kind defines the data kind (Position, normal, etc...)
  85102. * @param data defines the data to use
  85103. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85104. */
  85105. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85106. private _updateBoundingInfo;
  85107. /** @hidden */
  85108. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85109. /**
  85110. * Gets total number of vertices
  85111. * @returns the total number of vertices
  85112. */
  85113. getTotalVertices(): number;
  85114. /**
  85115. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85116. * @param kind defines the data kind (Position, normal, etc...)
  85117. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85118. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85119. * @returns a float array containing vertex data
  85120. */
  85121. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85122. /**
  85123. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85124. * @param kind defines the data kind (Position, normal, etc...)
  85125. * @returns true if the vertex buffer with the specified kind is updatable
  85126. */
  85127. isVertexBufferUpdatable(kind: string): boolean;
  85128. /**
  85129. * Gets a specific vertex buffer
  85130. * @param kind defines the data kind (Position, normal, etc...)
  85131. * @returns a VertexBuffer
  85132. */
  85133. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85134. /**
  85135. * Returns all vertex buffers
  85136. * @return an object holding all vertex buffers indexed by kind
  85137. */
  85138. getVertexBuffers(): Nullable<{
  85139. [key: string]: VertexBuffer;
  85140. }>;
  85141. /**
  85142. * Gets a boolean indicating if specific vertex buffer is present
  85143. * @param kind defines the data kind (Position, normal, etc...)
  85144. * @returns true if data is present
  85145. */
  85146. isVerticesDataPresent(kind: string): boolean;
  85147. /**
  85148. * Gets a list of all attached data kinds (Position, normal, etc...)
  85149. * @returns a list of string containing all kinds
  85150. */
  85151. getVerticesDataKinds(): string[];
  85152. /**
  85153. * Update index buffer
  85154. * @param indices defines the indices to store in the index buffer
  85155. * @param offset defines the offset in the target buffer where to store the data
  85156. * @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)
  85157. */
  85158. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85159. /**
  85160. * Creates a new index buffer
  85161. * @param indices defines the indices to store in the index buffer
  85162. * @param totalVertices defines the total number of vertices (could be null)
  85163. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85164. */
  85165. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85166. /**
  85167. * Return the total number of indices
  85168. * @returns the total number of indices
  85169. */
  85170. getTotalIndices(): number;
  85171. /**
  85172. * Gets the index buffer array
  85173. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85174. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85175. * @returns the index buffer array
  85176. */
  85177. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85178. /**
  85179. * Gets the index buffer
  85180. * @return the index buffer
  85181. */
  85182. getIndexBuffer(): Nullable<DataBuffer>;
  85183. /** @hidden */
  85184. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85185. /**
  85186. * Release the associated resources for a specific mesh
  85187. * @param mesh defines the source mesh
  85188. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85189. */
  85190. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85191. /**
  85192. * Apply current geometry to a given mesh
  85193. * @param mesh defines the mesh to apply geometry to
  85194. */
  85195. applyToMesh(mesh: Mesh): void;
  85196. private _updateExtend;
  85197. private _applyToMesh;
  85198. private notifyUpdate;
  85199. /**
  85200. * Load the geometry if it was flagged as delay loaded
  85201. * @param scene defines the hosting scene
  85202. * @param onLoaded defines a callback called when the geometry is loaded
  85203. */
  85204. load(scene: Scene, onLoaded?: () => void): void;
  85205. private _queueLoad;
  85206. /**
  85207. * Invert the geometry to move from a right handed system to a left handed one.
  85208. */
  85209. toLeftHanded(): void;
  85210. /** @hidden */
  85211. _resetPointsArrayCache(): void;
  85212. /** @hidden */
  85213. _generatePointsArray(): boolean;
  85214. /**
  85215. * Gets a value indicating if the geometry is disposed
  85216. * @returns true if the geometry was disposed
  85217. */
  85218. isDisposed(): boolean;
  85219. private _disposeVertexArrayObjects;
  85220. /**
  85221. * Free all associated resources
  85222. */
  85223. dispose(): void;
  85224. /**
  85225. * Clone the current geometry into a new geometry
  85226. * @param id defines the unique ID of the new geometry
  85227. * @returns a new geometry object
  85228. */
  85229. copy(id: string): Geometry;
  85230. /**
  85231. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85232. * @return a JSON representation of the current geometry data (without the vertices data)
  85233. */
  85234. serialize(): any;
  85235. private toNumberArray;
  85236. /**
  85237. * Serialize all vertices data into a JSON oject
  85238. * @returns a JSON representation of the current geometry data
  85239. */
  85240. serializeVerticeData(): any;
  85241. /**
  85242. * Extracts a clone of a mesh geometry
  85243. * @param mesh defines the source mesh
  85244. * @param id defines the unique ID of the new geometry object
  85245. * @returns the new geometry object
  85246. */
  85247. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85248. /**
  85249. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85250. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85251. * Be aware Math.random() could cause collisions, but:
  85252. * "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"
  85253. * @returns a string containing a new GUID
  85254. */
  85255. static RandomId(): string;
  85256. /** @hidden */
  85257. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85258. private static _CleanMatricesWeights;
  85259. /**
  85260. * Create a new geometry from persisted data (Using .babylon file format)
  85261. * @param parsedVertexData defines the persisted data
  85262. * @param scene defines the hosting scene
  85263. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85264. * @returns the new geometry object
  85265. */
  85266. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85267. }
  85268. }
  85269. declare module BABYLON {
  85270. /**
  85271. * Define an interface for all classes that will get and set the data on vertices
  85272. */
  85273. export interface IGetSetVerticesData {
  85274. /**
  85275. * Gets a boolean indicating if specific vertex data is present
  85276. * @param kind defines the vertex data kind to use
  85277. * @returns true is data kind is present
  85278. */
  85279. isVerticesDataPresent(kind: string): boolean;
  85280. /**
  85281. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85282. * @param kind defines the data kind (Position, normal, etc...)
  85283. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85284. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85285. * @returns a float array containing vertex data
  85286. */
  85287. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85288. /**
  85289. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85290. * @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.
  85291. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85292. * @returns the indices array or an empty array if the mesh has no geometry
  85293. */
  85294. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85295. /**
  85296. * Set specific vertex data
  85297. * @param kind defines the data kind (Position, normal, etc...)
  85298. * @param data defines the vertex data to use
  85299. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85300. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85301. */
  85302. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85303. /**
  85304. * Update a specific associated vertex buffer
  85305. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85306. * - VertexBuffer.PositionKind
  85307. * - VertexBuffer.UVKind
  85308. * - VertexBuffer.UV2Kind
  85309. * - VertexBuffer.UV3Kind
  85310. * - VertexBuffer.UV4Kind
  85311. * - VertexBuffer.UV5Kind
  85312. * - VertexBuffer.UV6Kind
  85313. * - VertexBuffer.ColorKind
  85314. * - VertexBuffer.MatricesIndicesKind
  85315. * - VertexBuffer.MatricesIndicesExtraKind
  85316. * - VertexBuffer.MatricesWeightsKind
  85317. * - VertexBuffer.MatricesWeightsExtraKind
  85318. * @param data defines the data source
  85319. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85320. * @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)
  85321. */
  85322. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85323. /**
  85324. * Creates a new index buffer
  85325. * @param indices defines the indices to store in the index buffer
  85326. * @param totalVertices defines the total number of vertices (could be null)
  85327. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85328. */
  85329. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85330. }
  85331. /**
  85332. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85333. */
  85334. export class VertexData {
  85335. /**
  85336. * Mesh side orientation : usually the external or front surface
  85337. */
  85338. static readonly FRONTSIDE: number;
  85339. /**
  85340. * Mesh side orientation : usually the internal or back surface
  85341. */
  85342. static readonly BACKSIDE: number;
  85343. /**
  85344. * Mesh side orientation : both internal and external or front and back surfaces
  85345. */
  85346. static readonly DOUBLESIDE: number;
  85347. /**
  85348. * Mesh side orientation : by default, `FRONTSIDE`
  85349. */
  85350. static readonly DEFAULTSIDE: number;
  85351. /**
  85352. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85353. */
  85354. positions: Nullable<FloatArray>;
  85355. /**
  85356. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85357. */
  85358. normals: Nullable<FloatArray>;
  85359. /**
  85360. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85361. */
  85362. tangents: Nullable<FloatArray>;
  85363. /**
  85364. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85365. */
  85366. uvs: Nullable<FloatArray>;
  85367. /**
  85368. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85369. */
  85370. uvs2: Nullable<FloatArray>;
  85371. /**
  85372. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85373. */
  85374. uvs3: Nullable<FloatArray>;
  85375. /**
  85376. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85377. */
  85378. uvs4: Nullable<FloatArray>;
  85379. /**
  85380. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85381. */
  85382. uvs5: Nullable<FloatArray>;
  85383. /**
  85384. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85385. */
  85386. uvs6: Nullable<FloatArray>;
  85387. /**
  85388. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85389. */
  85390. colors: Nullable<FloatArray>;
  85391. /**
  85392. * 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).
  85393. */
  85394. matricesIndices: Nullable<FloatArray>;
  85395. /**
  85396. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85397. */
  85398. matricesWeights: Nullable<FloatArray>;
  85399. /**
  85400. * An array extending the number of possible indices
  85401. */
  85402. matricesIndicesExtra: Nullable<FloatArray>;
  85403. /**
  85404. * An array extending the number of possible weights when the number of indices is extended
  85405. */
  85406. matricesWeightsExtra: Nullable<FloatArray>;
  85407. /**
  85408. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85409. */
  85410. indices: Nullable<IndicesArray>;
  85411. /**
  85412. * Uses the passed data array to set the set the values for the specified kind of data
  85413. * @param data a linear array of floating numbers
  85414. * @param kind the type of data that is being set, eg positions, colors etc
  85415. */
  85416. set(data: FloatArray, kind: string): void;
  85417. /**
  85418. * Associates the vertexData to the passed Mesh.
  85419. * Sets it as updatable or not (default `false`)
  85420. * @param mesh the mesh the vertexData is applied to
  85421. * @param updatable when used and having the value true allows new data to update the vertexData
  85422. * @returns the VertexData
  85423. */
  85424. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85425. /**
  85426. * Associates the vertexData to the passed Geometry.
  85427. * Sets it as updatable or not (default `false`)
  85428. * @param geometry the geometry the vertexData is applied to
  85429. * @param updatable when used and having the value true allows new data to update the vertexData
  85430. * @returns VertexData
  85431. */
  85432. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85433. /**
  85434. * Updates the associated mesh
  85435. * @param mesh the mesh to be updated
  85436. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85437. * @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
  85438. * @returns VertexData
  85439. */
  85440. updateMesh(mesh: Mesh): VertexData;
  85441. /**
  85442. * Updates the associated geometry
  85443. * @param geometry the geometry to be updated
  85444. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85445. * @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
  85446. * @returns VertexData.
  85447. */
  85448. updateGeometry(geometry: Geometry): VertexData;
  85449. private _applyTo;
  85450. private _update;
  85451. /**
  85452. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85453. * @param matrix the transforming matrix
  85454. * @returns the VertexData
  85455. */
  85456. transform(matrix: Matrix): VertexData;
  85457. /**
  85458. * Merges the passed VertexData into the current one
  85459. * @param other the VertexData to be merged into the current one
  85460. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85461. * @returns the modified VertexData
  85462. */
  85463. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85464. private _mergeElement;
  85465. private _validate;
  85466. /**
  85467. * Serializes the VertexData
  85468. * @returns a serialized object
  85469. */
  85470. serialize(): any;
  85471. /**
  85472. * Extracts the vertexData from a mesh
  85473. * @param mesh the mesh from which to extract the VertexData
  85474. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85475. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85476. * @returns the object VertexData associated to the passed mesh
  85477. */
  85478. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85479. /**
  85480. * Extracts the vertexData from the geometry
  85481. * @param geometry the geometry from which to extract the VertexData
  85482. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85483. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85484. * @returns the object VertexData associated to the passed mesh
  85485. */
  85486. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85487. private static _ExtractFrom;
  85488. /**
  85489. * Creates the VertexData for a Ribbon
  85490. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85491. * * pathArray array of paths, each of which an array of successive Vector3
  85492. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85493. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85494. * * 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
  85495. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85496. * * 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)
  85497. * * 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)
  85498. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85499. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85500. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85501. * @returns the VertexData of the ribbon
  85502. */
  85503. static CreateRibbon(options: {
  85504. pathArray: Vector3[][];
  85505. closeArray?: boolean;
  85506. closePath?: boolean;
  85507. offset?: number;
  85508. sideOrientation?: number;
  85509. frontUVs?: Vector4;
  85510. backUVs?: Vector4;
  85511. invertUV?: boolean;
  85512. uvs?: Vector2[];
  85513. colors?: Color4[];
  85514. }): VertexData;
  85515. /**
  85516. * Creates the VertexData for a box
  85517. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85518. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85519. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85520. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85521. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85522. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85523. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85525. * * 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)
  85526. * * 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)
  85527. * @returns the VertexData of the box
  85528. */
  85529. static CreateBox(options: {
  85530. size?: number;
  85531. width?: number;
  85532. height?: number;
  85533. depth?: number;
  85534. faceUV?: Vector4[];
  85535. faceColors?: Color4[];
  85536. sideOrientation?: number;
  85537. frontUVs?: Vector4;
  85538. backUVs?: Vector4;
  85539. }): VertexData;
  85540. /**
  85541. * Creates the VertexData for a tiled box
  85542. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85543. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85544. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85545. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85547. * @returns the VertexData of the box
  85548. */
  85549. static CreateTiledBox(options: {
  85550. pattern?: number;
  85551. width?: number;
  85552. height?: number;
  85553. depth?: number;
  85554. tileSize?: number;
  85555. tileWidth?: number;
  85556. tileHeight?: number;
  85557. alignHorizontal?: number;
  85558. alignVertical?: number;
  85559. faceUV?: Vector4[];
  85560. faceColors?: Color4[];
  85561. sideOrientation?: number;
  85562. }): VertexData;
  85563. /**
  85564. * Creates the VertexData for a tiled plane
  85565. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85566. * * pattern a limited pattern arrangement depending on the number
  85567. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85568. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85569. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85570. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85571. * * 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)
  85572. * * 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)
  85573. * @returns the VertexData of the tiled plane
  85574. */
  85575. static CreateTiledPlane(options: {
  85576. pattern?: number;
  85577. tileSize?: number;
  85578. tileWidth?: number;
  85579. tileHeight?: number;
  85580. size?: number;
  85581. width?: number;
  85582. height?: number;
  85583. alignHorizontal?: number;
  85584. alignVertical?: number;
  85585. sideOrientation?: number;
  85586. frontUVs?: Vector4;
  85587. backUVs?: Vector4;
  85588. }): VertexData;
  85589. /**
  85590. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85591. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85592. * * segments sets the number of horizontal strips optional, default 32
  85593. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85594. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85595. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85596. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85597. * * 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
  85598. * * 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
  85599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85600. * * 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)
  85601. * * 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)
  85602. * @returns the VertexData of the ellipsoid
  85603. */
  85604. static CreateSphere(options: {
  85605. segments?: number;
  85606. diameter?: number;
  85607. diameterX?: number;
  85608. diameterY?: number;
  85609. diameterZ?: number;
  85610. arc?: number;
  85611. slice?: number;
  85612. sideOrientation?: number;
  85613. frontUVs?: Vector4;
  85614. backUVs?: Vector4;
  85615. }): VertexData;
  85616. /**
  85617. * Creates the VertexData for a cylinder, cone or prism
  85618. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85619. * * height sets the height (y direction) of the cylinder, optional, default 2
  85620. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85621. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85622. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85623. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85624. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85625. * * 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
  85626. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85627. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85628. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85629. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85631. * * 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)
  85632. * * 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)
  85633. * @returns the VertexData of the cylinder, cone or prism
  85634. */
  85635. static CreateCylinder(options: {
  85636. height?: number;
  85637. diameterTop?: number;
  85638. diameterBottom?: number;
  85639. diameter?: number;
  85640. tessellation?: number;
  85641. subdivisions?: number;
  85642. arc?: number;
  85643. faceColors?: Color4[];
  85644. faceUV?: Vector4[];
  85645. hasRings?: boolean;
  85646. enclose?: boolean;
  85647. sideOrientation?: number;
  85648. frontUVs?: Vector4;
  85649. backUVs?: Vector4;
  85650. }): VertexData;
  85651. /**
  85652. * Creates the VertexData for a torus
  85653. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85654. * * diameter the diameter of the torus, optional default 1
  85655. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85656. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85657. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85658. * * 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)
  85659. * * 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)
  85660. * @returns the VertexData of the torus
  85661. */
  85662. static CreateTorus(options: {
  85663. diameter?: number;
  85664. thickness?: number;
  85665. tessellation?: number;
  85666. sideOrientation?: number;
  85667. frontUVs?: Vector4;
  85668. backUVs?: Vector4;
  85669. }): VertexData;
  85670. /**
  85671. * Creates the VertexData of the LineSystem
  85672. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85673. * - lines an array of lines, each line being an array of successive Vector3
  85674. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85675. * @returns the VertexData of the LineSystem
  85676. */
  85677. static CreateLineSystem(options: {
  85678. lines: Vector3[][];
  85679. colors?: Nullable<Color4[][]>;
  85680. }): VertexData;
  85681. /**
  85682. * Create the VertexData for a DashedLines
  85683. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85684. * - points an array successive Vector3
  85685. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85686. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85687. * - dashNb the intended total number of dashes, optional, default 200
  85688. * @returns the VertexData for the DashedLines
  85689. */
  85690. static CreateDashedLines(options: {
  85691. points: Vector3[];
  85692. dashSize?: number;
  85693. gapSize?: number;
  85694. dashNb?: number;
  85695. }): VertexData;
  85696. /**
  85697. * Creates the VertexData for a Ground
  85698. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85699. * - width the width (x direction) of the ground, optional, default 1
  85700. * - height the height (z direction) of the ground, optional, default 1
  85701. * - subdivisions the number of subdivisions per side, optional, default 1
  85702. * @returns the VertexData of the Ground
  85703. */
  85704. static CreateGround(options: {
  85705. width?: number;
  85706. height?: number;
  85707. subdivisions?: number;
  85708. subdivisionsX?: number;
  85709. subdivisionsY?: number;
  85710. }): VertexData;
  85711. /**
  85712. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85713. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85714. * * xmin the ground minimum X coordinate, optional, default -1
  85715. * * zmin the ground minimum Z coordinate, optional, default -1
  85716. * * xmax the ground maximum X coordinate, optional, default 1
  85717. * * zmax the ground maximum Z coordinate, optional, default 1
  85718. * * 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}
  85719. * * 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}
  85720. * @returns the VertexData of the TiledGround
  85721. */
  85722. static CreateTiledGround(options: {
  85723. xmin: number;
  85724. zmin: number;
  85725. xmax: number;
  85726. zmax: number;
  85727. subdivisions?: {
  85728. w: number;
  85729. h: number;
  85730. };
  85731. precision?: {
  85732. w: number;
  85733. h: number;
  85734. };
  85735. }): VertexData;
  85736. /**
  85737. * Creates the VertexData of the Ground designed from a heightmap
  85738. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85739. * * width the width (x direction) of the ground
  85740. * * height the height (z direction) of the ground
  85741. * * subdivisions the number of subdivisions per side
  85742. * * minHeight the minimum altitude on the ground, optional, default 0
  85743. * * maxHeight the maximum altitude on the ground, optional default 1
  85744. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85745. * * buffer the array holding the image color data
  85746. * * bufferWidth the width of image
  85747. * * bufferHeight the height of image
  85748. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85749. * @returns the VertexData of the Ground designed from a heightmap
  85750. */
  85751. static CreateGroundFromHeightMap(options: {
  85752. width: number;
  85753. height: number;
  85754. subdivisions: number;
  85755. minHeight: number;
  85756. maxHeight: number;
  85757. colorFilter: Color3;
  85758. buffer: Uint8Array;
  85759. bufferWidth: number;
  85760. bufferHeight: number;
  85761. alphaFilter: number;
  85762. }): VertexData;
  85763. /**
  85764. * Creates the VertexData for a Plane
  85765. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85766. * * size sets the width and height of the plane to the value of size, optional default 1
  85767. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85768. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85770. * * 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)
  85771. * * 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)
  85772. * @returns the VertexData of the box
  85773. */
  85774. static CreatePlane(options: {
  85775. size?: number;
  85776. width?: number;
  85777. height?: number;
  85778. sideOrientation?: number;
  85779. frontUVs?: Vector4;
  85780. backUVs?: Vector4;
  85781. }): VertexData;
  85782. /**
  85783. * Creates the VertexData of the Disc or regular Polygon
  85784. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85785. * * radius the radius of the disc, optional default 0.5
  85786. * * tessellation the number of polygon sides, optional, default 64
  85787. * * 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
  85788. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85789. * * 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)
  85790. * * 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)
  85791. * @returns the VertexData of the box
  85792. */
  85793. static CreateDisc(options: {
  85794. radius?: number;
  85795. tessellation?: number;
  85796. arc?: number;
  85797. sideOrientation?: number;
  85798. frontUVs?: Vector4;
  85799. backUVs?: Vector4;
  85800. }): VertexData;
  85801. /**
  85802. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85803. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85804. * @param polygon a mesh built from polygonTriangulation.build()
  85805. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85806. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85807. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85808. * @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)
  85809. * @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)
  85810. * @returns the VertexData of the Polygon
  85811. */
  85812. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85813. /**
  85814. * Creates the VertexData of the IcoSphere
  85815. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85816. * * radius the radius of the IcoSphere, optional default 1
  85817. * * radiusX allows stretching in the x direction, optional, default radius
  85818. * * radiusY allows stretching in the y direction, optional, default radius
  85819. * * radiusZ allows stretching in the z direction, optional, default radius
  85820. * * flat when true creates a flat shaded mesh, optional, default true
  85821. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85822. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85823. * * 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)
  85824. * * 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)
  85825. * @returns the VertexData of the IcoSphere
  85826. */
  85827. static CreateIcoSphere(options: {
  85828. radius?: number;
  85829. radiusX?: number;
  85830. radiusY?: number;
  85831. radiusZ?: number;
  85832. flat?: boolean;
  85833. subdivisions?: number;
  85834. sideOrientation?: number;
  85835. frontUVs?: Vector4;
  85836. backUVs?: Vector4;
  85837. }): VertexData;
  85838. /**
  85839. * Creates the VertexData for a Polyhedron
  85840. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85841. * * type provided types are:
  85842. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85843. * * 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)
  85844. * * size the size of the IcoSphere, optional default 1
  85845. * * sizeX allows stretching in the x direction, optional, default size
  85846. * * sizeY allows stretching in the y direction, optional, default size
  85847. * * sizeZ allows stretching in the z direction, optional, default size
  85848. * * 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
  85849. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85850. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85851. * * flat when true creates a flat shaded mesh, optional, default true
  85852. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85853. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85854. * * 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)
  85855. * * 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)
  85856. * @returns the VertexData of the Polyhedron
  85857. */
  85858. static CreatePolyhedron(options: {
  85859. type?: number;
  85860. size?: number;
  85861. sizeX?: number;
  85862. sizeY?: number;
  85863. sizeZ?: number;
  85864. custom?: any;
  85865. faceUV?: Vector4[];
  85866. faceColors?: Color4[];
  85867. flat?: boolean;
  85868. sideOrientation?: number;
  85869. frontUVs?: Vector4;
  85870. backUVs?: Vector4;
  85871. }): VertexData;
  85872. /**
  85873. * Creates the VertexData for a TorusKnot
  85874. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85875. * * radius the radius of the torus knot, optional, default 2
  85876. * * tube the thickness of the tube, optional, default 0.5
  85877. * * radialSegments the number of sides on each tube segments, optional, default 32
  85878. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85879. * * p the number of windings around the z axis, optional, default 2
  85880. * * q the number of windings around the x axis, optional, default 3
  85881. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85882. * * 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)
  85883. * * 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)
  85884. * @returns the VertexData of the Torus Knot
  85885. */
  85886. static CreateTorusKnot(options: {
  85887. radius?: number;
  85888. tube?: number;
  85889. radialSegments?: number;
  85890. tubularSegments?: number;
  85891. p?: number;
  85892. q?: number;
  85893. sideOrientation?: number;
  85894. frontUVs?: Vector4;
  85895. backUVs?: Vector4;
  85896. }): VertexData;
  85897. /**
  85898. * Compute normals for given positions and indices
  85899. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85900. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85901. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85902. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85903. * * facetNormals : optional array of facet normals (vector3)
  85904. * * facetPositions : optional array of facet positions (vector3)
  85905. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85906. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85907. * * bInfo : optional bounding info, required for facetPartitioning computation
  85908. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85909. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85910. * * useRightHandedSystem: optional boolean to for right handed system computation
  85911. * * depthSort : optional boolean to enable the facet depth sort computation
  85912. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85913. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85914. */
  85915. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85916. facetNormals?: any;
  85917. facetPositions?: any;
  85918. facetPartitioning?: any;
  85919. ratio?: number;
  85920. bInfo?: any;
  85921. bbSize?: Vector3;
  85922. subDiv?: any;
  85923. useRightHandedSystem?: boolean;
  85924. depthSort?: boolean;
  85925. distanceTo?: Vector3;
  85926. depthSortedFacets?: any;
  85927. }): void;
  85928. /** @hidden */
  85929. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85930. /**
  85931. * Applies VertexData created from the imported parameters to the geometry
  85932. * @param parsedVertexData the parsed data from an imported file
  85933. * @param geometry the geometry to apply the VertexData to
  85934. */
  85935. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85936. }
  85937. }
  85938. declare module BABYLON {
  85939. /**
  85940. * Defines a target to use with MorphTargetManager
  85941. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85942. */
  85943. export class MorphTarget implements IAnimatable {
  85944. /** defines the name of the target */
  85945. name: string;
  85946. /**
  85947. * Gets or sets the list of animations
  85948. */
  85949. animations: Animation[];
  85950. private _scene;
  85951. private _positions;
  85952. private _normals;
  85953. private _tangents;
  85954. private _uvs;
  85955. private _influence;
  85956. /**
  85957. * Observable raised when the influence changes
  85958. */
  85959. onInfluenceChanged: Observable<boolean>;
  85960. /** @hidden */
  85961. _onDataLayoutChanged: Observable<void>;
  85962. /**
  85963. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85964. */
  85965. influence: number;
  85966. /**
  85967. * Gets or sets the id of the morph Target
  85968. */
  85969. id: string;
  85970. private _animationPropertiesOverride;
  85971. /**
  85972. * Gets or sets the animation properties override
  85973. */
  85974. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85975. /**
  85976. * Creates a new MorphTarget
  85977. * @param name defines the name of the target
  85978. * @param influence defines the influence to use
  85979. * @param scene defines the scene the morphtarget belongs to
  85980. */
  85981. constructor(
  85982. /** defines the name of the target */
  85983. name: string, influence?: number, scene?: Nullable<Scene>);
  85984. /**
  85985. * Gets a boolean defining if the target contains position data
  85986. */
  85987. readonly hasPositions: boolean;
  85988. /**
  85989. * Gets a boolean defining if the target contains normal data
  85990. */
  85991. readonly hasNormals: boolean;
  85992. /**
  85993. * Gets a boolean defining if the target contains tangent data
  85994. */
  85995. readonly hasTangents: boolean;
  85996. /**
  85997. * Gets a boolean defining if the target contains texture coordinates data
  85998. */
  85999. readonly hasUVs: boolean;
  86000. /**
  86001. * Affects position data to this target
  86002. * @param data defines the position data to use
  86003. */
  86004. setPositions(data: Nullable<FloatArray>): void;
  86005. /**
  86006. * Gets the position data stored in this target
  86007. * @returns a FloatArray containing the position data (or null if not present)
  86008. */
  86009. getPositions(): Nullable<FloatArray>;
  86010. /**
  86011. * Affects normal data to this target
  86012. * @param data defines the normal data to use
  86013. */
  86014. setNormals(data: Nullable<FloatArray>): void;
  86015. /**
  86016. * Gets the normal data stored in this target
  86017. * @returns a FloatArray containing the normal data (or null if not present)
  86018. */
  86019. getNormals(): Nullable<FloatArray>;
  86020. /**
  86021. * Affects tangent data to this target
  86022. * @param data defines the tangent data to use
  86023. */
  86024. setTangents(data: Nullable<FloatArray>): void;
  86025. /**
  86026. * Gets the tangent data stored in this target
  86027. * @returns a FloatArray containing the tangent data (or null if not present)
  86028. */
  86029. getTangents(): Nullable<FloatArray>;
  86030. /**
  86031. * Affects texture coordinates data to this target
  86032. * @param data defines the texture coordinates data to use
  86033. */
  86034. setUVs(data: Nullable<FloatArray>): void;
  86035. /**
  86036. * Gets the texture coordinates data stored in this target
  86037. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  86038. */
  86039. getUVs(): Nullable<FloatArray>;
  86040. /**
  86041. * Serializes the current target into a Serialization object
  86042. * @returns the serialized object
  86043. */
  86044. serialize(): any;
  86045. /**
  86046. * Returns the string "MorphTarget"
  86047. * @returns "MorphTarget"
  86048. */
  86049. getClassName(): string;
  86050. /**
  86051. * Creates a new target from serialized data
  86052. * @param serializationObject defines the serialized data to use
  86053. * @returns a new MorphTarget
  86054. */
  86055. static Parse(serializationObject: any): MorphTarget;
  86056. /**
  86057. * Creates a MorphTarget from mesh data
  86058. * @param mesh defines the source mesh
  86059. * @param name defines the name to use for the new target
  86060. * @param influence defines the influence to attach to the target
  86061. * @returns a new MorphTarget
  86062. */
  86063. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  86064. }
  86065. }
  86066. declare module BABYLON {
  86067. /**
  86068. * This class is used to deform meshes using morphing between different targets
  86069. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  86070. */
  86071. export class MorphTargetManager {
  86072. private _targets;
  86073. private _targetInfluenceChangedObservers;
  86074. private _targetDataLayoutChangedObservers;
  86075. private _activeTargets;
  86076. private _scene;
  86077. private _influences;
  86078. private _supportsNormals;
  86079. private _supportsTangents;
  86080. private _supportsUVs;
  86081. private _vertexCount;
  86082. private _uniqueId;
  86083. private _tempInfluences;
  86084. /**
  86085. * Gets or sets a boolean indicating if normals must be morphed
  86086. */
  86087. enableNormalMorphing: boolean;
  86088. /**
  86089. * Gets or sets a boolean indicating if tangents must be morphed
  86090. */
  86091. enableTangentMorphing: boolean;
  86092. /**
  86093. * Gets or sets a boolean indicating if UV must be morphed
  86094. */
  86095. enableUVMorphing: boolean;
  86096. /**
  86097. * Creates a new MorphTargetManager
  86098. * @param scene defines the current scene
  86099. */
  86100. constructor(scene?: Nullable<Scene>);
  86101. /**
  86102. * Gets the unique ID of this manager
  86103. */
  86104. readonly uniqueId: number;
  86105. /**
  86106. * Gets the number of vertices handled by this manager
  86107. */
  86108. readonly vertexCount: number;
  86109. /**
  86110. * Gets a boolean indicating if this manager supports morphing of normals
  86111. */
  86112. readonly supportsNormals: boolean;
  86113. /**
  86114. * Gets a boolean indicating if this manager supports morphing of tangents
  86115. */
  86116. readonly supportsTangents: boolean;
  86117. /**
  86118. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  86119. */
  86120. readonly supportsUVs: boolean;
  86121. /**
  86122. * Gets the number of targets stored in this manager
  86123. */
  86124. readonly numTargets: number;
  86125. /**
  86126. * Gets the number of influencers (ie. the number of targets with influences > 0)
  86127. */
  86128. readonly numInfluencers: number;
  86129. /**
  86130. * Gets the list of influences (one per target)
  86131. */
  86132. readonly influences: Float32Array;
  86133. /**
  86134. * Gets the active target at specified index. An active target is a target with an influence > 0
  86135. * @param index defines the index to check
  86136. * @returns the requested target
  86137. */
  86138. getActiveTarget(index: number): MorphTarget;
  86139. /**
  86140. * Gets the target at specified index
  86141. * @param index defines the index to check
  86142. * @returns the requested target
  86143. */
  86144. getTarget(index: number): MorphTarget;
  86145. /**
  86146. * Add a new target to this manager
  86147. * @param target defines the target to add
  86148. */
  86149. addTarget(target: MorphTarget): void;
  86150. /**
  86151. * Removes a target from the manager
  86152. * @param target defines the target to remove
  86153. */
  86154. removeTarget(target: MorphTarget): void;
  86155. /**
  86156. * Serializes the current manager into a Serialization object
  86157. * @returns the serialized object
  86158. */
  86159. serialize(): any;
  86160. private _syncActiveTargets;
  86161. /**
  86162. * Syncrhonize the targets with all the meshes using this morph target manager
  86163. */
  86164. synchronize(): void;
  86165. /**
  86166. * Creates a new MorphTargetManager from serialized data
  86167. * @param serializationObject defines the serialized data
  86168. * @param scene defines the hosting scene
  86169. * @returns the new MorphTargetManager
  86170. */
  86171. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  86172. }
  86173. }
  86174. declare module BABYLON {
  86175. /**
  86176. * Class used to represent a specific level of detail of a mesh
  86177. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  86178. */
  86179. export class MeshLODLevel {
  86180. /** Defines the distance where this level should star being displayed */
  86181. distance: number;
  86182. /** Defines the mesh to use to render this level */
  86183. mesh: Nullable<Mesh>;
  86184. /**
  86185. * Creates a new LOD level
  86186. * @param distance defines the distance where this level should star being displayed
  86187. * @param mesh defines the mesh to use to render this level
  86188. */
  86189. constructor(
  86190. /** Defines the distance where this level should star being displayed */
  86191. distance: number,
  86192. /** Defines the mesh to use to render this level */
  86193. mesh: Nullable<Mesh>);
  86194. }
  86195. }
  86196. declare module BABYLON {
  86197. /**
  86198. * Mesh representing the gorund
  86199. */
  86200. export class GroundMesh extends Mesh {
  86201. /** If octree should be generated */
  86202. generateOctree: boolean;
  86203. private _heightQuads;
  86204. /** @hidden */
  86205. _subdivisionsX: number;
  86206. /** @hidden */
  86207. _subdivisionsY: number;
  86208. /** @hidden */
  86209. _width: number;
  86210. /** @hidden */
  86211. _height: number;
  86212. /** @hidden */
  86213. _minX: number;
  86214. /** @hidden */
  86215. _maxX: number;
  86216. /** @hidden */
  86217. _minZ: number;
  86218. /** @hidden */
  86219. _maxZ: number;
  86220. constructor(name: string, scene: Scene);
  86221. /**
  86222. * "GroundMesh"
  86223. * @returns "GroundMesh"
  86224. */
  86225. getClassName(): string;
  86226. /**
  86227. * The minimum of x and y subdivisions
  86228. */
  86229. readonly subdivisions: number;
  86230. /**
  86231. * X subdivisions
  86232. */
  86233. readonly subdivisionsX: number;
  86234. /**
  86235. * Y subdivisions
  86236. */
  86237. readonly subdivisionsY: number;
  86238. /**
  86239. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86240. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86241. * @param chunksCount the number of subdivisions for x and y
  86242. * @param octreeBlocksSize (Default: 32)
  86243. */
  86244. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  86245. /**
  86246. * Returns a height (y) value in the Worl system :
  86247. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86248. * @param x x coordinate
  86249. * @param z z coordinate
  86250. * @returns the ground y position if (x, z) are outside the ground surface.
  86251. */
  86252. getHeightAtCoordinates(x: number, z: number): number;
  86253. /**
  86254. * Returns a normalized vector (Vector3) orthogonal to the ground
  86255. * at the ground coordinates (x, z) expressed in the World system.
  86256. * @param x x coordinate
  86257. * @param z z coordinate
  86258. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86259. */
  86260. getNormalAtCoordinates(x: number, z: number): Vector3;
  86261. /**
  86262. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86263. * at the ground coordinates (x, z) expressed in the World system.
  86264. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86265. * @param x x coordinate
  86266. * @param z z coordinate
  86267. * @param ref vector to store the result
  86268. * @returns the GroundMesh.
  86269. */
  86270. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  86271. /**
  86272. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86273. * if the ground has been updated.
  86274. * This can be used in the render loop.
  86275. * @returns the GroundMesh.
  86276. */
  86277. updateCoordinateHeights(): GroundMesh;
  86278. private _getFacetAt;
  86279. private _initHeightQuads;
  86280. private _computeHeightQuads;
  86281. /**
  86282. * Serializes this ground mesh
  86283. * @param serializationObject object to write serialization to
  86284. */
  86285. serialize(serializationObject: any): void;
  86286. /**
  86287. * Parses a serialized ground mesh
  86288. * @param parsedMesh the serialized mesh
  86289. * @param scene the scene to create the ground mesh in
  86290. * @returns the created ground mesh
  86291. */
  86292. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  86293. }
  86294. }
  86295. declare module BABYLON {
  86296. /**
  86297. * Interface for Physics-Joint data
  86298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86299. */
  86300. export interface PhysicsJointData {
  86301. /**
  86302. * The main pivot of the joint
  86303. */
  86304. mainPivot?: Vector3;
  86305. /**
  86306. * The connected pivot of the joint
  86307. */
  86308. connectedPivot?: Vector3;
  86309. /**
  86310. * The main axis of the joint
  86311. */
  86312. mainAxis?: Vector3;
  86313. /**
  86314. * The connected axis of the joint
  86315. */
  86316. connectedAxis?: Vector3;
  86317. /**
  86318. * The collision of the joint
  86319. */
  86320. collision?: boolean;
  86321. /**
  86322. * Native Oimo/Cannon/Energy data
  86323. */
  86324. nativeParams?: any;
  86325. }
  86326. /**
  86327. * This is a holder class for the physics joint created by the physics plugin
  86328. * It holds a set of functions to control the underlying joint
  86329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86330. */
  86331. export class PhysicsJoint {
  86332. /**
  86333. * The type of the physics joint
  86334. */
  86335. type: number;
  86336. /**
  86337. * The data for the physics joint
  86338. */
  86339. jointData: PhysicsJointData;
  86340. private _physicsJoint;
  86341. protected _physicsPlugin: IPhysicsEnginePlugin;
  86342. /**
  86343. * Initializes the physics joint
  86344. * @param type The type of the physics joint
  86345. * @param jointData The data for the physics joint
  86346. */
  86347. constructor(
  86348. /**
  86349. * The type of the physics joint
  86350. */
  86351. type: number,
  86352. /**
  86353. * The data for the physics joint
  86354. */
  86355. jointData: PhysicsJointData);
  86356. /**
  86357. * Gets the physics joint
  86358. */
  86359. /**
  86360. * Sets the physics joint
  86361. */
  86362. physicsJoint: any;
  86363. /**
  86364. * Sets the physics plugin
  86365. */
  86366. physicsPlugin: IPhysicsEnginePlugin;
  86367. /**
  86368. * Execute a function that is physics-plugin specific.
  86369. * @param {Function} func the function that will be executed.
  86370. * It accepts two parameters: the physics world and the physics joint
  86371. */
  86372. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86373. /**
  86374. * Distance-Joint type
  86375. */
  86376. static DistanceJoint: number;
  86377. /**
  86378. * Hinge-Joint type
  86379. */
  86380. static HingeJoint: number;
  86381. /**
  86382. * Ball-and-Socket joint type
  86383. */
  86384. static BallAndSocketJoint: number;
  86385. /**
  86386. * Wheel-Joint type
  86387. */
  86388. static WheelJoint: number;
  86389. /**
  86390. * Slider-Joint type
  86391. */
  86392. static SliderJoint: number;
  86393. /**
  86394. * Prismatic-Joint type
  86395. */
  86396. static PrismaticJoint: number;
  86397. /**
  86398. * Universal-Joint type
  86399. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86400. */
  86401. static UniversalJoint: number;
  86402. /**
  86403. * Hinge-Joint 2 type
  86404. */
  86405. static Hinge2Joint: number;
  86406. /**
  86407. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86408. */
  86409. static PointToPointJoint: number;
  86410. /**
  86411. * Spring-Joint type
  86412. */
  86413. static SpringJoint: number;
  86414. /**
  86415. * Lock-Joint type
  86416. */
  86417. static LockJoint: number;
  86418. }
  86419. /**
  86420. * A class representing a physics distance joint
  86421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86422. */
  86423. export class DistanceJoint extends PhysicsJoint {
  86424. /**
  86425. *
  86426. * @param jointData The data for the Distance-Joint
  86427. */
  86428. constructor(jointData: DistanceJointData);
  86429. /**
  86430. * Update the predefined distance.
  86431. * @param maxDistance The maximum preferred distance
  86432. * @param minDistance The minimum preferred distance
  86433. */
  86434. updateDistance(maxDistance: number, minDistance?: number): void;
  86435. }
  86436. /**
  86437. * Represents a Motor-Enabled Joint
  86438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86439. */
  86440. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86441. /**
  86442. * Initializes the Motor-Enabled Joint
  86443. * @param type The type of the joint
  86444. * @param jointData The physica joint data for the joint
  86445. */
  86446. constructor(type: number, jointData: PhysicsJointData);
  86447. /**
  86448. * Set the motor values.
  86449. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86450. * @param force the force to apply
  86451. * @param maxForce max force for this motor.
  86452. */
  86453. setMotor(force?: number, maxForce?: number): void;
  86454. /**
  86455. * Set the motor's limits.
  86456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86457. * @param upperLimit The upper limit of the motor
  86458. * @param lowerLimit The lower limit of the motor
  86459. */
  86460. setLimit(upperLimit: number, lowerLimit?: number): void;
  86461. }
  86462. /**
  86463. * This class represents a single physics Hinge-Joint
  86464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86465. */
  86466. export class HingeJoint extends MotorEnabledJoint {
  86467. /**
  86468. * Initializes the Hinge-Joint
  86469. * @param jointData The joint data for the Hinge-Joint
  86470. */
  86471. constructor(jointData: PhysicsJointData);
  86472. /**
  86473. * Set the motor values.
  86474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86475. * @param {number} force the force to apply
  86476. * @param {number} maxForce max force for this motor.
  86477. */
  86478. setMotor(force?: number, maxForce?: number): void;
  86479. /**
  86480. * Set the motor's limits.
  86481. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86482. * @param upperLimit The upper limit of the motor
  86483. * @param lowerLimit The lower limit of the motor
  86484. */
  86485. setLimit(upperLimit: number, lowerLimit?: number): void;
  86486. }
  86487. /**
  86488. * This class represents a dual hinge physics joint (same as wheel joint)
  86489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86490. */
  86491. export class Hinge2Joint extends MotorEnabledJoint {
  86492. /**
  86493. * Initializes the Hinge2-Joint
  86494. * @param jointData The joint data for the Hinge2-Joint
  86495. */
  86496. constructor(jointData: PhysicsJointData);
  86497. /**
  86498. * Set the motor values.
  86499. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86500. * @param {number} targetSpeed the speed the motor is to reach
  86501. * @param {number} maxForce max force for this motor.
  86502. * @param {motorIndex} the motor's index, 0 or 1.
  86503. */
  86504. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86505. /**
  86506. * Set the motor limits.
  86507. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86508. * @param {number} upperLimit the upper limit
  86509. * @param {number} lowerLimit lower limit
  86510. * @param {motorIndex} the motor's index, 0 or 1.
  86511. */
  86512. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86513. }
  86514. /**
  86515. * Interface for a motor enabled joint
  86516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86517. */
  86518. export interface IMotorEnabledJoint {
  86519. /**
  86520. * Physics joint
  86521. */
  86522. physicsJoint: any;
  86523. /**
  86524. * Sets the motor of the motor-enabled joint
  86525. * @param force The force of the motor
  86526. * @param maxForce The maximum force of the motor
  86527. * @param motorIndex The index of the motor
  86528. */
  86529. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86530. /**
  86531. * Sets the limit of the motor
  86532. * @param upperLimit The upper limit of the motor
  86533. * @param lowerLimit The lower limit of the motor
  86534. * @param motorIndex The index of the motor
  86535. */
  86536. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86537. }
  86538. /**
  86539. * Joint data for a Distance-Joint
  86540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86541. */
  86542. export interface DistanceJointData extends PhysicsJointData {
  86543. /**
  86544. * Max distance the 2 joint objects can be apart
  86545. */
  86546. maxDistance: number;
  86547. }
  86548. /**
  86549. * Joint data from a spring joint
  86550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86551. */
  86552. export interface SpringJointData extends PhysicsJointData {
  86553. /**
  86554. * Length of the spring
  86555. */
  86556. length: number;
  86557. /**
  86558. * Stiffness of the spring
  86559. */
  86560. stiffness: number;
  86561. /**
  86562. * Damping of the spring
  86563. */
  86564. damping: number;
  86565. /** this callback will be called when applying the force to the impostors. */
  86566. forceApplicationCallback: () => void;
  86567. }
  86568. }
  86569. declare module BABYLON {
  86570. /**
  86571. * Holds the data for the raycast result
  86572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86573. */
  86574. export class PhysicsRaycastResult {
  86575. private _hasHit;
  86576. private _hitDistance;
  86577. private _hitNormalWorld;
  86578. private _hitPointWorld;
  86579. private _rayFromWorld;
  86580. private _rayToWorld;
  86581. /**
  86582. * Gets if there was a hit
  86583. */
  86584. readonly hasHit: boolean;
  86585. /**
  86586. * Gets the distance from the hit
  86587. */
  86588. readonly hitDistance: number;
  86589. /**
  86590. * Gets the hit normal/direction in the world
  86591. */
  86592. readonly hitNormalWorld: Vector3;
  86593. /**
  86594. * Gets the hit point in the world
  86595. */
  86596. readonly hitPointWorld: Vector3;
  86597. /**
  86598. * Gets the ray "start point" of the ray in the world
  86599. */
  86600. readonly rayFromWorld: Vector3;
  86601. /**
  86602. * Gets the ray "end point" of the ray in the world
  86603. */
  86604. readonly rayToWorld: Vector3;
  86605. /**
  86606. * Sets the hit data (normal & point in world space)
  86607. * @param hitNormalWorld defines the normal in world space
  86608. * @param hitPointWorld defines the point in world space
  86609. */
  86610. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86611. /**
  86612. * Sets the distance from the start point to the hit point
  86613. * @param distance
  86614. */
  86615. setHitDistance(distance: number): void;
  86616. /**
  86617. * Calculates the distance manually
  86618. */
  86619. calculateHitDistance(): void;
  86620. /**
  86621. * Resets all the values to default
  86622. * @param from The from point on world space
  86623. * @param to The to point on world space
  86624. */
  86625. reset(from?: Vector3, to?: Vector3): void;
  86626. }
  86627. /**
  86628. * Interface for the size containing width and height
  86629. */
  86630. interface IXYZ {
  86631. /**
  86632. * X
  86633. */
  86634. x: number;
  86635. /**
  86636. * Y
  86637. */
  86638. y: number;
  86639. /**
  86640. * Z
  86641. */
  86642. z: number;
  86643. }
  86644. }
  86645. declare module BABYLON {
  86646. /**
  86647. * Interface used to describe a physics joint
  86648. */
  86649. export interface PhysicsImpostorJoint {
  86650. /** Defines the main impostor to which the joint is linked */
  86651. mainImpostor: PhysicsImpostor;
  86652. /** Defines the impostor that is connected to the main impostor using this joint */
  86653. connectedImpostor: PhysicsImpostor;
  86654. /** Defines the joint itself */
  86655. joint: PhysicsJoint;
  86656. }
  86657. /** @hidden */
  86658. export interface IPhysicsEnginePlugin {
  86659. world: any;
  86660. name: string;
  86661. setGravity(gravity: Vector3): void;
  86662. setTimeStep(timeStep: number): void;
  86663. getTimeStep(): number;
  86664. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86665. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86666. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86667. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86668. removePhysicsBody(impostor: PhysicsImpostor): void;
  86669. generateJoint(joint: PhysicsImpostorJoint): void;
  86670. removeJoint(joint: PhysicsImpostorJoint): void;
  86671. isSupported(): boolean;
  86672. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86673. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86675. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86676. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86677. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86678. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86679. getBodyMass(impostor: PhysicsImpostor): number;
  86680. getBodyFriction(impostor: PhysicsImpostor): number;
  86681. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86682. getBodyRestitution(impostor: PhysicsImpostor): number;
  86683. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86684. getBodyPressure?(impostor: PhysicsImpostor): number;
  86685. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86686. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86687. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86688. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86689. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86690. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86691. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86692. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86693. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86694. sleepBody(impostor: PhysicsImpostor): void;
  86695. wakeUpBody(impostor: PhysicsImpostor): void;
  86696. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86697. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86698. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86699. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86700. getRadius(impostor: PhysicsImpostor): number;
  86701. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86702. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86703. dispose(): void;
  86704. }
  86705. /**
  86706. * Interface used to define a physics engine
  86707. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86708. */
  86709. export interface IPhysicsEngine {
  86710. /**
  86711. * Gets the gravity vector used by the simulation
  86712. */
  86713. gravity: Vector3;
  86714. /**
  86715. * Sets the gravity vector used by the simulation
  86716. * @param gravity defines the gravity vector to use
  86717. */
  86718. setGravity(gravity: Vector3): void;
  86719. /**
  86720. * Set the time step of the physics engine.
  86721. * Default is 1/60.
  86722. * To slow it down, enter 1/600 for example.
  86723. * To speed it up, 1/30
  86724. * @param newTimeStep the new timestep to apply to this world.
  86725. */
  86726. setTimeStep(newTimeStep: number): void;
  86727. /**
  86728. * Get the time step of the physics engine.
  86729. * @returns the current time step
  86730. */
  86731. getTimeStep(): number;
  86732. /**
  86733. * Release all resources
  86734. */
  86735. dispose(): void;
  86736. /**
  86737. * Gets the name of the current physics plugin
  86738. * @returns the name of the plugin
  86739. */
  86740. getPhysicsPluginName(): string;
  86741. /**
  86742. * Adding a new impostor for the impostor tracking.
  86743. * This will be done by the impostor itself.
  86744. * @param impostor the impostor to add
  86745. */
  86746. addImpostor(impostor: PhysicsImpostor): void;
  86747. /**
  86748. * Remove an impostor from the engine.
  86749. * This impostor and its mesh will not longer be updated by the physics engine.
  86750. * @param impostor the impostor to remove
  86751. */
  86752. removeImpostor(impostor: PhysicsImpostor): void;
  86753. /**
  86754. * Add a joint to the physics engine
  86755. * @param mainImpostor defines the main impostor to which the joint is added.
  86756. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86757. * @param joint defines the joint that will connect both impostors.
  86758. */
  86759. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86760. /**
  86761. * Removes a joint from the simulation
  86762. * @param mainImpostor defines the impostor used with the joint
  86763. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86764. * @param joint defines the joint to remove
  86765. */
  86766. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86767. /**
  86768. * Gets the current plugin used to run the simulation
  86769. * @returns current plugin
  86770. */
  86771. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86772. /**
  86773. * Gets the list of physic impostors
  86774. * @returns an array of PhysicsImpostor
  86775. */
  86776. getImpostors(): Array<PhysicsImpostor>;
  86777. /**
  86778. * Gets the impostor for a physics enabled object
  86779. * @param object defines the object impersonated by the impostor
  86780. * @returns the PhysicsImpostor or null if not found
  86781. */
  86782. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86783. /**
  86784. * Gets the impostor for a physics body object
  86785. * @param body defines physics body used by the impostor
  86786. * @returns the PhysicsImpostor or null if not found
  86787. */
  86788. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86789. /**
  86790. * Does a raycast in the physics world
  86791. * @param from when should the ray start?
  86792. * @param to when should the ray end?
  86793. * @returns PhysicsRaycastResult
  86794. */
  86795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86796. /**
  86797. * Called by the scene. No need to call it.
  86798. * @param delta defines the timespam between frames
  86799. */
  86800. _step(delta: number): void;
  86801. }
  86802. }
  86803. declare module BABYLON {
  86804. /**
  86805. * The interface for the physics imposter parameters
  86806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86807. */
  86808. export interface PhysicsImpostorParameters {
  86809. /**
  86810. * The mass of the physics imposter
  86811. */
  86812. mass: number;
  86813. /**
  86814. * The friction of the physics imposter
  86815. */
  86816. friction?: number;
  86817. /**
  86818. * The coefficient of restitution of the physics imposter
  86819. */
  86820. restitution?: number;
  86821. /**
  86822. * The native options of the physics imposter
  86823. */
  86824. nativeOptions?: any;
  86825. /**
  86826. * Specifies if the parent should be ignored
  86827. */
  86828. ignoreParent?: boolean;
  86829. /**
  86830. * Specifies if bi-directional transformations should be disabled
  86831. */
  86832. disableBidirectionalTransformation?: boolean;
  86833. /**
  86834. * The pressure inside the physics imposter, soft object only
  86835. */
  86836. pressure?: number;
  86837. /**
  86838. * The stiffness the physics imposter, soft object only
  86839. */
  86840. stiffness?: number;
  86841. /**
  86842. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86843. */
  86844. velocityIterations?: number;
  86845. /**
  86846. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86847. */
  86848. positionIterations?: number;
  86849. /**
  86850. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86851. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86852. * Add to fix multiple points
  86853. */
  86854. fixedPoints?: number;
  86855. /**
  86856. * The collision margin around a soft object
  86857. */
  86858. margin?: number;
  86859. /**
  86860. * The collision margin around a soft object
  86861. */
  86862. damping?: number;
  86863. /**
  86864. * The path for a rope based on an extrusion
  86865. */
  86866. path?: any;
  86867. /**
  86868. * The shape of an extrusion used for a rope based on an extrusion
  86869. */
  86870. shape?: any;
  86871. }
  86872. /**
  86873. * Interface for a physics-enabled object
  86874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86875. */
  86876. export interface IPhysicsEnabledObject {
  86877. /**
  86878. * The position of the physics-enabled object
  86879. */
  86880. position: Vector3;
  86881. /**
  86882. * The rotation of the physics-enabled object
  86883. */
  86884. rotationQuaternion: Nullable<Quaternion>;
  86885. /**
  86886. * The scale of the physics-enabled object
  86887. */
  86888. scaling: Vector3;
  86889. /**
  86890. * The rotation of the physics-enabled object
  86891. */
  86892. rotation?: Vector3;
  86893. /**
  86894. * The parent of the physics-enabled object
  86895. */
  86896. parent?: any;
  86897. /**
  86898. * The bounding info of the physics-enabled object
  86899. * @returns The bounding info of the physics-enabled object
  86900. */
  86901. getBoundingInfo(): BoundingInfo;
  86902. /**
  86903. * Computes the world matrix
  86904. * @param force Specifies if the world matrix should be computed by force
  86905. * @returns A world matrix
  86906. */
  86907. computeWorldMatrix(force: boolean): Matrix;
  86908. /**
  86909. * Gets the world matrix
  86910. * @returns A world matrix
  86911. */
  86912. getWorldMatrix?(): Matrix;
  86913. /**
  86914. * Gets the child meshes
  86915. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86916. * @returns An array of abstract meshes
  86917. */
  86918. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86919. /**
  86920. * Gets the vertex data
  86921. * @param kind The type of vertex data
  86922. * @returns A nullable array of numbers, or a float32 array
  86923. */
  86924. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86925. /**
  86926. * Gets the indices from the mesh
  86927. * @returns A nullable array of index arrays
  86928. */
  86929. getIndices?(): Nullable<IndicesArray>;
  86930. /**
  86931. * Gets the scene from the mesh
  86932. * @returns the indices array or null
  86933. */
  86934. getScene?(): Scene;
  86935. /**
  86936. * Gets the absolute position from the mesh
  86937. * @returns the absolute position
  86938. */
  86939. getAbsolutePosition(): Vector3;
  86940. /**
  86941. * Gets the absolute pivot point from the mesh
  86942. * @returns the absolute pivot point
  86943. */
  86944. getAbsolutePivotPoint(): Vector3;
  86945. /**
  86946. * Rotates the mesh
  86947. * @param axis The axis of rotation
  86948. * @param amount The amount of rotation
  86949. * @param space The space of the rotation
  86950. * @returns The rotation transform node
  86951. */
  86952. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86953. /**
  86954. * Translates the mesh
  86955. * @param axis The axis of translation
  86956. * @param distance The distance of translation
  86957. * @param space The space of the translation
  86958. * @returns The transform node
  86959. */
  86960. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86961. /**
  86962. * Sets the absolute position of the mesh
  86963. * @param absolutePosition The absolute position of the mesh
  86964. * @returns The transform node
  86965. */
  86966. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86967. /**
  86968. * Gets the class name of the mesh
  86969. * @returns The class name
  86970. */
  86971. getClassName(): string;
  86972. }
  86973. /**
  86974. * Represents a physics imposter
  86975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86976. */
  86977. export class PhysicsImpostor {
  86978. /**
  86979. * The physics-enabled object used as the physics imposter
  86980. */
  86981. object: IPhysicsEnabledObject;
  86982. /**
  86983. * The type of the physics imposter
  86984. */
  86985. type: number;
  86986. private _options;
  86987. private _scene?;
  86988. /**
  86989. * The default object size of the imposter
  86990. */
  86991. static DEFAULT_OBJECT_SIZE: Vector3;
  86992. /**
  86993. * The identity quaternion of the imposter
  86994. */
  86995. static IDENTITY_QUATERNION: Quaternion;
  86996. /** @hidden */
  86997. _pluginData: any;
  86998. private _physicsEngine;
  86999. private _physicsBody;
  87000. private _bodyUpdateRequired;
  87001. private _onBeforePhysicsStepCallbacks;
  87002. private _onAfterPhysicsStepCallbacks;
  87003. /** @hidden */
  87004. _onPhysicsCollideCallbacks: Array<{
  87005. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  87006. otherImpostors: Array<PhysicsImpostor>;
  87007. }>;
  87008. private _deltaPosition;
  87009. private _deltaRotation;
  87010. private _deltaRotationConjugated;
  87011. /** @hidden */
  87012. _isFromLine: boolean;
  87013. private _parent;
  87014. private _isDisposed;
  87015. private static _tmpVecs;
  87016. private static _tmpQuat;
  87017. /**
  87018. * Specifies if the physics imposter is disposed
  87019. */
  87020. readonly isDisposed: boolean;
  87021. /**
  87022. * Gets the mass of the physics imposter
  87023. */
  87024. mass: number;
  87025. /**
  87026. * Gets the coefficient of friction
  87027. */
  87028. /**
  87029. * Sets the coefficient of friction
  87030. */
  87031. friction: number;
  87032. /**
  87033. * Gets the coefficient of restitution
  87034. */
  87035. /**
  87036. * Sets the coefficient of restitution
  87037. */
  87038. restitution: number;
  87039. /**
  87040. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  87041. */
  87042. /**
  87043. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  87044. */
  87045. pressure: number;
  87046. /**
  87047. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87048. */
  87049. /**
  87050. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  87051. */
  87052. stiffness: number;
  87053. /**
  87054. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87055. */
  87056. /**
  87057. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  87058. */
  87059. velocityIterations: number;
  87060. /**
  87061. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87062. */
  87063. /**
  87064. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  87065. */
  87066. positionIterations: number;
  87067. /**
  87068. * The unique id of the physics imposter
  87069. * set by the physics engine when adding this impostor to the array
  87070. */
  87071. uniqueId: number;
  87072. /**
  87073. * @hidden
  87074. */
  87075. soft: boolean;
  87076. /**
  87077. * @hidden
  87078. */
  87079. segments: number;
  87080. private _joints;
  87081. /**
  87082. * Initializes the physics imposter
  87083. * @param object The physics-enabled object used as the physics imposter
  87084. * @param type The type of the physics imposter
  87085. * @param _options The options for the physics imposter
  87086. * @param _scene The Babylon scene
  87087. */
  87088. constructor(
  87089. /**
  87090. * The physics-enabled object used as the physics imposter
  87091. */
  87092. object: IPhysicsEnabledObject,
  87093. /**
  87094. * The type of the physics imposter
  87095. */
  87096. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  87097. /**
  87098. * This function will completly initialize this impostor.
  87099. * It will create a new body - but only if this mesh has no parent.
  87100. * If it has, this impostor will not be used other than to define the impostor
  87101. * of the child mesh.
  87102. * @hidden
  87103. */
  87104. _init(): void;
  87105. private _getPhysicsParent;
  87106. /**
  87107. * Should a new body be generated.
  87108. * @returns boolean specifying if body initialization is required
  87109. */
  87110. isBodyInitRequired(): boolean;
  87111. /**
  87112. * Sets the updated scaling
  87113. * @param updated Specifies if the scaling is updated
  87114. */
  87115. setScalingUpdated(): void;
  87116. /**
  87117. * Force a regeneration of this or the parent's impostor's body.
  87118. * Use under cautious - This will remove all joints already implemented.
  87119. */
  87120. forceUpdate(): void;
  87121. /**
  87122. * Gets the body that holds this impostor. Either its own, or its parent.
  87123. */
  87124. /**
  87125. * Set the physics body. Used mainly by the physics engine/plugin
  87126. */
  87127. physicsBody: any;
  87128. /**
  87129. * Get the parent of the physics imposter
  87130. * @returns Physics imposter or null
  87131. */
  87132. /**
  87133. * Sets the parent of the physics imposter
  87134. */
  87135. parent: Nullable<PhysicsImpostor>;
  87136. /**
  87137. * Resets the update flags
  87138. */
  87139. resetUpdateFlags(): void;
  87140. /**
  87141. * Gets the object extend size
  87142. * @returns the object extend size
  87143. */
  87144. getObjectExtendSize(): Vector3;
  87145. /**
  87146. * Gets the object center
  87147. * @returns The object center
  87148. */
  87149. getObjectCenter(): Vector3;
  87150. /**
  87151. * Get a specific parametes from the options parameter
  87152. * @param paramName The object parameter name
  87153. * @returns The object parameter
  87154. */
  87155. getParam(paramName: string): any;
  87156. /**
  87157. * Sets a specific parameter in the options given to the physics plugin
  87158. * @param paramName The parameter name
  87159. * @param value The value of the parameter
  87160. */
  87161. setParam(paramName: string, value: number): void;
  87162. /**
  87163. * Specifically change the body's mass option. Won't recreate the physics body object
  87164. * @param mass The mass of the physics imposter
  87165. */
  87166. setMass(mass: number): void;
  87167. /**
  87168. * Gets the linear velocity
  87169. * @returns linear velocity or null
  87170. */
  87171. getLinearVelocity(): Nullable<Vector3>;
  87172. /**
  87173. * Sets the linear velocity
  87174. * @param velocity linear velocity or null
  87175. */
  87176. setLinearVelocity(velocity: Nullable<Vector3>): void;
  87177. /**
  87178. * Gets the angular velocity
  87179. * @returns angular velocity or null
  87180. */
  87181. getAngularVelocity(): Nullable<Vector3>;
  87182. /**
  87183. * Sets the angular velocity
  87184. * @param velocity The velocity or null
  87185. */
  87186. setAngularVelocity(velocity: Nullable<Vector3>): void;
  87187. /**
  87188. * Execute a function with the physics plugin native code
  87189. * Provide a function the will have two variables - the world object and the physics body object
  87190. * @param func The function to execute with the physics plugin native code
  87191. */
  87192. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  87193. /**
  87194. * Register a function that will be executed before the physics world is stepping forward
  87195. * @param func The function to execute before the physics world is stepped forward
  87196. */
  87197. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87198. /**
  87199. * Unregister a function that will be executed before the physics world is stepping forward
  87200. * @param func The function to execute before the physics world is stepped forward
  87201. */
  87202. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87203. /**
  87204. * Register a function that will be executed after the physics step
  87205. * @param func The function to execute after physics step
  87206. */
  87207. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87208. /**
  87209. * Unregisters a function that will be executed after the physics step
  87210. * @param func The function to execute after physics step
  87211. */
  87212. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  87213. /**
  87214. * register a function that will be executed when this impostor collides against a different body
  87215. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  87216. * @param func Callback that is executed on collision
  87217. */
  87218. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  87219. /**
  87220. * Unregisters the physics imposter on contact
  87221. * @param collideAgainst The physics object to collide against
  87222. * @param func Callback to execute on collision
  87223. */
  87224. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  87225. private _tmpQuat;
  87226. private _tmpQuat2;
  87227. /**
  87228. * Get the parent rotation
  87229. * @returns The parent rotation
  87230. */
  87231. getParentsRotation(): Quaternion;
  87232. /**
  87233. * this function is executed by the physics engine.
  87234. */
  87235. beforeStep: () => void;
  87236. /**
  87237. * this function is executed by the physics engine
  87238. */
  87239. afterStep: () => void;
  87240. /**
  87241. * Legacy collision detection event support
  87242. */
  87243. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  87244. /**
  87245. * event and body object due to cannon's event-based architecture.
  87246. */
  87247. onCollide: (e: {
  87248. body: any;
  87249. }) => void;
  87250. /**
  87251. * Apply a force
  87252. * @param force The force to apply
  87253. * @param contactPoint The contact point for the force
  87254. * @returns The physics imposter
  87255. */
  87256. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87257. /**
  87258. * Apply an impulse
  87259. * @param force The impulse force
  87260. * @param contactPoint The contact point for the impulse force
  87261. * @returns The physics imposter
  87262. */
  87263. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  87264. /**
  87265. * A help function to create a joint
  87266. * @param otherImpostor A physics imposter used to create a joint
  87267. * @param jointType The type of joint
  87268. * @param jointData The data for the joint
  87269. * @returns The physics imposter
  87270. */
  87271. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  87272. /**
  87273. * Add a joint to this impostor with a different impostor
  87274. * @param otherImpostor A physics imposter used to add a joint
  87275. * @param joint The joint to add
  87276. * @returns The physics imposter
  87277. */
  87278. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  87279. /**
  87280. * Add an anchor to a cloth impostor
  87281. * @param otherImpostor rigid impostor to anchor to
  87282. * @param width ratio across width from 0 to 1
  87283. * @param height ratio up height from 0 to 1
  87284. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  87285. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  87286. * @returns impostor the soft imposter
  87287. */
  87288. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87289. /**
  87290. * Add a hook to a rope impostor
  87291. * @param otherImpostor rigid impostor to anchor to
  87292. * @param length ratio across rope from 0 to 1
  87293. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  87294. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  87295. * @returns impostor the rope imposter
  87296. */
  87297. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  87298. /**
  87299. * Will keep this body still, in a sleep mode.
  87300. * @returns the physics imposter
  87301. */
  87302. sleep(): PhysicsImpostor;
  87303. /**
  87304. * Wake the body up.
  87305. * @returns The physics imposter
  87306. */
  87307. wakeUp(): PhysicsImpostor;
  87308. /**
  87309. * Clones the physics imposter
  87310. * @param newObject The physics imposter clones to this physics-enabled object
  87311. * @returns A nullable physics imposter
  87312. */
  87313. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  87314. /**
  87315. * Disposes the physics imposter
  87316. */
  87317. dispose(): void;
  87318. /**
  87319. * Sets the delta position
  87320. * @param position The delta position amount
  87321. */
  87322. setDeltaPosition(position: Vector3): void;
  87323. /**
  87324. * Sets the delta rotation
  87325. * @param rotation The delta rotation amount
  87326. */
  87327. setDeltaRotation(rotation: Quaternion): void;
  87328. /**
  87329. * Gets the box size of the physics imposter and stores the result in the input parameter
  87330. * @param result Stores the box size
  87331. * @returns The physics imposter
  87332. */
  87333. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87334. /**
  87335. * Gets the radius of the physics imposter
  87336. * @returns Radius of the physics imposter
  87337. */
  87338. getRadius(): number;
  87339. /**
  87340. * Sync a bone with this impostor
  87341. * @param bone The bone to sync to the impostor.
  87342. * @param boneMesh The mesh that the bone is influencing.
  87343. * @param jointPivot The pivot of the joint / bone in local space.
  87344. * @param distToJoint Optional distance from the impostor to the joint.
  87345. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87346. */
  87347. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87348. /**
  87349. * Sync impostor to a bone
  87350. * @param bone The bone that the impostor will be synced to.
  87351. * @param boneMesh The mesh that the bone is influencing.
  87352. * @param jointPivot The pivot of the joint / bone in local space.
  87353. * @param distToJoint Optional distance from the impostor to the joint.
  87354. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87355. * @param boneAxis Optional vector3 axis the bone is aligned with
  87356. */
  87357. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87358. /**
  87359. * No-Imposter type
  87360. */
  87361. static NoImpostor: number;
  87362. /**
  87363. * Sphere-Imposter type
  87364. */
  87365. static SphereImpostor: number;
  87366. /**
  87367. * Box-Imposter type
  87368. */
  87369. static BoxImpostor: number;
  87370. /**
  87371. * Plane-Imposter type
  87372. */
  87373. static PlaneImpostor: number;
  87374. /**
  87375. * Mesh-imposter type
  87376. */
  87377. static MeshImpostor: number;
  87378. /**
  87379. * Capsule-Impostor type (Ammo.js plugin only)
  87380. */
  87381. static CapsuleImpostor: number;
  87382. /**
  87383. * Cylinder-Imposter type
  87384. */
  87385. static CylinderImpostor: number;
  87386. /**
  87387. * Particle-Imposter type
  87388. */
  87389. static ParticleImpostor: number;
  87390. /**
  87391. * Heightmap-Imposter type
  87392. */
  87393. static HeightmapImpostor: number;
  87394. /**
  87395. * ConvexHull-Impostor type (Ammo.js plugin only)
  87396. */
  87397. static ConvexHullImpostor: number;
  87398. /**
  87399. * Rope-Imposter type
  87400. */
  87401. static RopeImpostor: number;
  87402. /**
  87403. * Cloth-Imposter type
  87404. */
  87405. static ClothImpostor: number;
  87406. /**
  87407. * Softbody-Imposter type
  87408. */
  87409. static SoftbodyImpostor: number;
  87410. }
  87411. }
  87412. declare module BABYLON {
  87413. /**
  87414. * @hidden
  87415. **/
  87416. export class _CreationDataStorage {
  87417. closePath?: boolean;
  87418. closeArray?: boolean;
  87419. idx: number[];
  87420. dashSize: number;
  87421. gapSize: number;
  87422. path3D: Path3D;
  87423. pathArray: Vector3[][];
  87424. arc: number;
  87425. radius: number;
  87426. cap: number;
  87427. tessellation: number;
  87428. }
  87429. /**
  87430. * @hidden
  87431. **/
  87432. class _InstanceDataStorage {
  87433. visibleInstances: any;
  87434. batchCache: _InstancesBatch;
  87435. instancesBufferSize: number;
  87436. instancesBuffer: Nullable<Buffer>;
  87437. instancesData: Float32Array;
  87438. overridenInstanceCount: number;
  87439. isFrozen: boolean;
  87440. previousBatch: Nullable<_InstancesBatch>;
  87441. hardwareInstancedRendering: boolean;
  87442. sideOrientation: number;
  87443. }
  87444. /**
  87445. * @hidden
  87446. **/
  87447. export class _InstancesBatch {
  87448. mustReturn: boolean;
  87449. visibleInstances: Nullable<InstancedMesh[]>[];
  87450. renderSelf: boolean[];
  87451. hardwareInstancedRendering: boolean[];
  87452. }
  87453. /**
  87454. * Class used to represent renderable models
  87455. */
  87456. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87457. /**
  87458. * Mesh side orientation : usually the external or front surface
  87459. */
  87460. static readonly FRONTSIDE: number;
  87461. /**
  87462. * Mesh side orientation : usually the internal or back surface
  87463. */
  87464. static readonly BACKSIDE: number;
  87465. /**
  87466. * Mesh side orientation : both internal and external or front and back surfaces
  87467. */
  87468. static readonly DOUBLESIDE: number;
  87469. /**
  87470. * Mesh side orientation : by default, `FRONTSIDE`
  87471. */
  87472. static readonly DEFAULTSIDE: number;
  87473. /**
  87474. * Mesh cap setting : no cap
  87475. */
  87476. static readonly NO_CAP: number;
  87477. /**
  87478. * Mesh cap setting : one cap at the beginning of the mesh
  87479. */
  87480. static readonly CAP_START: number;
  87481. /**
  87482. * Mesh cap setting : one cap at the end of the mesh
  87483. */
  87484. static readonly CAP_END: number;
  87485. /**
  87486. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87487. */
  87488. static readonly CAP_ALL: number;
  87489. /**
  87490. * Mesh pattern setting : no flip or rotate
  87491. */
  87492. static readonly NO_FLIP: number;
  87493. /**
  87494. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87495. */
  87496. static readonly FLIP_TILE: number;
  87497. /**
  87498. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87499. */
  87500. static readonly ROTATE_TILE: number;
  87501. /**
  87502. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87503. */
  87504. static readonly FLIP_ROW: number;
  87505. /**
  87506. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87507. */
  87508. static readonly ROTATE_ROW: number;
  87509. /**
  87510. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87511. */
  87512. static readonly FLIP_N_ROTATE_TILE: number;
  87513. /**
  87514. * Mesh pattern setting : rotate pattern and rotate
  87515. */
  87516. static readonly FLIP_N_ROTATE_ROW: number;
  87517. /**
  87518. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87519. */
  87520. static readonly CENTER: number;
  87521. /**
  87522. * Mesh tile positioning : part tiles on left
  87523. */
  87524. static readonly LEFT: number;
  87525. /**
  87526. * Mesh tile positioning : part tiles on right
  87527. */
  87528. static readonly RIGHT: number;
  87529. /**
  87530. * Mesh tile positioning : part tiles on top
  87531. */
  87532. static readonly TOP: number;
  87533. /**
  87534. * Mesh tile positioning : part tiles on bottom
  87535. */
  87536. static readonly BOTTOM: number;
  87537. /**
  87538. * Gets the default side orientation.
  87539. * @param orientation the orientation to value to attempt to get
  87540. * @returns the default orientation
  87541. * @hidden
  87542. */
  87543. static _GetDefaultSideOrientation(orientation?: number): number;
  87544. private _internalMeshDataInfo;
  87545. /**
  87546. * An event triggered before rendering the mesh
  87547. */
  87548. readonly onBeforeRenderObservable: Observable<Mesh>;
  87549. /**
  87550. * An event triggered before binding the mesh
  87551. */
  87552. readonly onBeforeBindObservable: Observable<Mesh>;
  87553. /**
  87554. * An event triggered after rendering the mesh
  87555. */
  87556. readonly onAfterRenderObservable: Observable<Mesh>;
  87557. /**
  87558. * An event triggered before drawing the mesh
  87559. */
  87560. readonly onBeforeDrawObservable: Observable<Mesh>;
  87561. private _onBeforeDrawObserver;
  87562. /**
  87563. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87564. */
  87565. onBeforeDraw: () => void;
  87566. /**
  87567. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87568. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87569. */
  87570. delayLoadState: number;
  87571. /**
  87572. * Gets the list of instances created from this mesh
  87573. * it is not supposed to be modified manually.
  87574. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87575. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87576. */
  87577. instances: InstancedMesh[];
  87578. /**
  87579. * Gets the file containing delay loading data for this mesh
  87580. */
  87581. delayLoadingFile: string;
  87582. /** @hidden */
  87583. _binaryInfo: any;
  87584. /**
  87585. * User defined function used to change how LOD level selection is done
  87586. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87587. */
  87588. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87589. /**
  87590. * Gets or sets the morph target manager
  87591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87592. */
  87593. morphTargetManager: Nullable<MorphTargetManager>;
  87594. /** @hidden */
  87595. _creationDataStorage: Nullable<_CreationDataStorage>;
  87596. /** @hidden */
  87597. _geometry: Nullable<Geometry>;
  87598. /** @hidden */
  87599. _delayInfo: Array<string>;
  87600. /** @hidden */
  87601. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87602. /** @hidden */
  87603. _instanceDataStorage: _InstanceDataStorage;
  87604. private _effectiveMaterial;
  87605. /** @hidden */
  87606. _shouldGenerateFlatShading: boolean;
  87607. /** @hidden */
  87608. _originalBuilderSideOrientation: number;
  87609. /**
  87610. * Use this property to change the original side orientation defined at construction time
  87611. */
  87612. overrideMaterialSideOrientation: Nullable<number>;
  87613. /**
  87614. * Gets the source mesh (the one used to clone this one from)
  87615. */
  87616. readonly source: Nullable<Mesh>;
  87617. /**
  87618. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87619. */
  87620. isUnIndexed: boolean;
  87621. /**
  87622. * @constructor
  87623. * @param name The value used by scene.getMeshByName() to do a lookup.
  87624. * @param scene The scene to add this mesh to.
  87625. * @param parent The parent of this mesh, if it has one
  87626. * @param source An optional Mesh from which geometry is shared, cloned.
  87627. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87628. * When false, achieved by calling a clone(), also passing False.
  87629. * This will make creation of children, recursive.
  87630. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87631. */
  87632. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87633. /**
  87634. * Gets the class name
  87635. * @returns the string "Mesh".
  87636. */
  87637. getClassName(): string;
  87638. /** @hidden */
  87639. readonly _isMesh: boolean;
  87640. /**
  87641. * Returns a description of this mesh
  87642. * @param fullDetails define if full details about this mesh must be used
  87643. * @returns a descriptive string representing this mesh
  87644. */
  87645. toString(fullDetails?: boolean): string;
  87646. /** @hidden */
  87647. _unBindEffect(): void;
  87648. /**
  87649. * Gets a boolean indicating if this mesh has LOD
  87650. */
  87651. readonly hasLODLevels: boolean;
  87652. /**
  87653. * Gets the list of MeshLODLevel associated with the current mesh
  87654. * @returns an array of MeshLODLevel
  87655. */
  87656. getLODLevels(): MeshLODLevel[];
  87657. private _sortLODLevels;
  87658. /**
  87659. * Add a mesh as LOD level triggered at the given distance.
  87660. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87661. * @param distance The distance from the center of the object to show this level
  87662. * @param mesh The mesh to be added as LOD level (can be null)
  87663. * @return This mesh (for chaining)
  87664. */
  87665. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87666. /**
  87667. * Returns the LOD level mesh at the passed distance or null if not found.
  87668. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87669. * @param distance The distance from the center of the object to show this level
  87670. * @returns a Mesh or `null`
  87671. */
  87672. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87673. /**
  87674. * Remove a mesh from the LOD array
  87675. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87676. * @param mesh defines the mesh to be removed
  87677. * @return This mesh (for chaining)
  87678. */
  87679. removeLODLevel(mesh: Mesh): Mesh;
  87680. /**
  87681. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87682. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87683. * @param camera defines the camera to use to compute distance
  87684. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87685. * @return This mesh (for chaining)
  87686. */
  87687. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87688. /**
  87689. * Gets the mesh internal Geometry object
  87690. */
  87691. readonly geometry: Nullable<Geometry>;
  87692. /**
  87693. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87694. * @returns the total number of vertices
  87695. */
  87696. getTotalVertices(): number;
  87697. /**
  87698. * Returns the content of an associated vertex buffer
  87699. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87700. * - VertexBuffer.PositionKind
  87701. * - VertexBuffer.UVKind
  87702. * - VertexBuffer.UV2Kind
  87703. * - VertexBuffer.UV3Kind
  87704. * - VertexBuffer.UV4Kind
  87705. * - VertexBuffer.UV5Kind
  87706. * - VertexBuffer.UV6Kind
  87707. * - VertexBuffer.ColorKind
  87708. * - VertexBuffer.MatricesIndicesKind
  87709. * - VertexBuffer.MatricesIndicesExtraKind
  87710. * - VertexBuffer.MatricesWeightsKind
  87711. * - VertexBuffer.MatricesWeightsExtraKind
  87712. * @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
  87713. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87714. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87715. */
  87716. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87717. /**
  87718. * Returns the mesh VertexBuffer object from the requested `kind`
  87719. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87720. * - VertexBuffer.PositionKind
  87721. * - VertexBuffer.NormalKind
  87722. * - VertexBuffer.UVKind
  87723. * - VertexBuffer.UV2Kind
  87724. * - VertexBuffer.UV3Kind
  87725. * - VertexBuffer.UV4Kind
  87726. * - VertexBuffer.UV5Kind
  87727. * - VertexBuffer.UV6Kind
  87728. * - VertexBuffer.ColorKind
  87729. * - VertexBuffer.MatricesIndicesKind
  87730. * - VertexBuffer.MatricesIndicesExtraKind
  87731. * - VertexBuffer.MatricesWeightsKind
  87732. * - VertexBuffer.MatricesWeightsExtraKind
  87733. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87734. */
  87735. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87736. /**
  87737. * Tests if a specific vertex buffer is associated with this mesh
  87738. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87739. * - VertexBuffer.PositionKind
  87740. * - VertexBuffer.NormalKind
  87741. * - VertexBuffer.UVKind
  87742. * - VertexBuffer.UV2Kind
  87743. * - VertexBuffer.UV3Kind
  87744. * - VertexBuffer.UV4Kind
  87745. * - VertexBuffer.UV5Kind
  87746. * - VertexBuffer.UV6Kind
  87747. * - VertexBuffer.ColorKind
  87748. * - VertexBuffer.MatricesIndicesKind
  87749. * - VertexBuffer.MatricesIndicesExtraKind
  87750. * - VertexBuffer.MatricesWeightsKind
  87751. * - VertexBuffer.MatricesWeightsExtraKind
  87752. * @returns a boolean
  87753. */
  87754. isVerticesDataPresent(kind: string): boolean;
  87755. /**
  87756. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87757. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87758. * - VertexBuffer.PositionKind
  87759. * - VertexBuffer.UVKind
  87760. * - VertexBuffer.UV2Kind
  87761. * - VertexBuffer.UV3Kind
  87762. * - VertexBuffer.UV4Kind
  87763. * - VertexBuffer.UV5Kind
  87764. * - VertexBuffer.UV6Kind
  87765. * - VertexBuffer.ColorKind
  87766. * - VertexBuffer.MatricesIndicesKind
  87767. * - VertexBuffer.MatricesIndicesExtraKind
  87768. * - VertexBuffer.MatricesWeightsKind
  87769. * - VertexBuffer.MatricesWeightsExtraKind
  87770. * @returns a boolean
  87771. */
  87772. isVertexBufferUpdatable(kind: string): boolean;
  87773. /**
  87774. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87775. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87776. * - VertexBuffer.PositionKind
  87777. * - VertexBuffer.NormalKind
  87778. * - VertexBuffer.UVKind
  87779. * - VertexBuffer.UV2Kind
  87780. * - VertexBuffer.UV3Kind
  87781. * - VertexBuffer.UV4Kind
  87782. * - VertexBuffer.UV5Kind
  87783. * - VertexBuffer.UV6Kind
  87784. * - VertexBuffer.ColorKind
  87785. * - VertexBuffer.MatricesIndicesKind
  87786. * - VertexBuffer.MatricesIndicesExtraKind
  87787. * - VertexBuffer.MatricesWeightsKind
  87788. * - VertexBuffer.MatricesWeightsExtraKind
  87789. * @returns an array of strings
  87790. */
  87791. getVerticesDataKinds(): string[];
  87792. /**
  87793. * Returns a positive integer : the total number of indices in this mesh geometry.
  87794. * @returns the numner of indices or zero if the mesh has no geometry.
  87795. */
  87796. getTotalIndices(): number;
  87797. /**
  87798. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87799. * @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.
  87800. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87801. * @returns the indices array or an empty array if the mesh has no geometry
  87802. */
  87803. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87804. readonly isBlocked: boolean;
  87805. /**
  87806. * Determine if the current mesh is ready to be rendered
  87807. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87808. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87809. * @returns true if all associated assets are ready (material, textures, shaders)
  87810. */
  87811. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87812. /**
  87813. * 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.
  87814. */
  87815. readonly areNormalsFrozen: boolean;
  87816. /**
  87817. * 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.
  87818. * @returns the current mesh
  87819. */
  87820. freezeNormals(): Mesh;
  87821. /**
  87822. * 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
  87823. * @returns the current mesh
  87824. */
  87825. unfreezeNormals(): Mesh;
  87826. /**
  87827. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87828. */
  87829. overridenInstanceCount: number;
  87830. /** @hidden */
  87831. _preActivate(): Mesh;
  87832. /** @hidden */
  87833. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87834. /** @hidden */
  87835. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87836. /**
  87837. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87838. * This means the mesh underlying bounding box and sphere are recomputed.
  87839. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87840. * @returns the current mesh
  87841. */
  87842. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87843. /** @hidden */
  87844. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87845. /**
  87846. * This function will subdivide the mesh into multiple submeshes
  87847. * @param count defines the expected number of submeshes
  87848. */
  87849. subdivide(count: number): void;
  87850. /**
  87851. * Copy a FloatArray into a specific associated vertex buffer
  87852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87853. * - VertexBuffer.PositionKind
  87854. * - VertexBuffer.UVKind
  87855. * - VertexBuffer.UV2Kind
  87856. * - VertexBuffer.UV3Kind
  87857. * - VertexBuffer.UV4Kind
  87858. * - VertexBuffer.UV5Kind
  87859. * - VertexBuffer.UV6Kind
  87860. * - VertexBuffer.ColorKind
  87861. * - VertexBuffer.MatricesIndicesKind
  87862. * - VertexBuffer.MatricesIndicesExtraKind
  87863. * - VertexBuffer.MatricesWeightsKind
  87864. * - VertexBuffer.MatricesWeightsExtraKind
  87865. * @param data defines the data source
  87866. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87867. * @param stride defines the data stride size (can be null)
  87868. * @returns the current mesh
  87869. */
  87870. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87871. /**
  87872. * Flags an associated vertex buffer as updatable
  87873. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87874. * - VertexBuffer.PositionKind
  87875. * - VertexBuffer.UVKind
  87876. * - VertexBuffer.UV2Kind
  87877. * - VertexBuffer.UV3Kind
  87878. * - VertexBuffer.UV4Kind
  87879. * - VertexBuffer.UV5Kind
  87880. * - VertexBuffer.UV6Kind
  87881. * - VertexBuffer.ColorKind
  87882. * - VertexBuffer.MatricesIndicesKind
  87883. * - VertexBuffer.MatricesIndicesExtraKind
  87884. * - VertexBuffer.MatricesWeightsKind
  87885. * - VertexBuffer.MatricesWeightsExtraKind
  87886. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87887. */
  87888. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87889. /**
  87890. * Sets the mesh global Vertex Buffer
  87891. * @param buffer defines the buffer to use
  87892. * @returns the current mesh
  87893. */
  87894. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87895. /**
  87896. * Update a specific associated vertex buffer
  87897. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87898. * - VertexBuffer.PositionKind
  87899. * - VertexBuffer.UVKind
  87900. * - VertexBuffer.UV2Kind
  87901. * - VertexBuffer.UV3Kind
  87902. * - VertexBuffer.UV4Kind
  87903. * - VertexBuffer.UV5Kind
  87904. * - VertexBuffer.UV6Kind
  87905. * - VertexBuffer.ColorKind
  87906. * - VertexBuffer.MatricesIndicesKind
  87907. * - VertexBuffer.MatricesIndicesExtraKind
  87908. * - VertexBuffer.MatricesWeightsKind
  87909. * - VertexBuffer.MatricesWeightsExtraKind
  87910. * @param data defines the data source
  87911. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87912. * @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)
  87913. * @returns the current mesh
  87914. */
  87915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87916. /**
  87917. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87918. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87919. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87920. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87921. * @returns the current mesh
  87922. */
  87923. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87924. /**
  87925. * Creates a un-shared specific occurence of the geometry for the mesh.
  87926. * @returns the current mesh
  87927. */
  87928. makeGeometryUnique(): Mesh;
  87929. /**
  87930. * Set the index buffer of this mesh
  87931. * @param indices defines the source data
  87932. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87933. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87934. * @returns the current mesh
  87935. */
  87936. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87937. /**
  87938. * Update the current index buffer
  87939. * @param indices defines the source data
  87940. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87941. * @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)
  87942. * @returns the current mesh
  87943. */
  87944. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87945. /**
  87946. * Invert the geometry to move from a right handed system to a left handed one.
  87947. * @returns the current mesh
  87948. */
  87949. toLeftHanded(): Mesh;
  87950. /** @hidden */
  87951. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87952. /** @hidden */
  87953. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87954. /**
  87955. * Registers for this mesh a javascript function called just before the rendering process
  87956. * @param func defines the function to call before rendering this mesh
  87957. * @returns the current mesh
  87958. */
  87959. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87960. /**
  87961. * Disposes a previously registered javascript function called before the rendering
  87962. * @param func defines the function to remove
  87963. * @returns the current mesh
  87964. */
  87965. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87966. /**
  87967. * Registers for this mesh a javascript function called just after the rendering is complete
  87968. * @param func defines the function to call after rendering this mesh
  87969. * @returns the current mesh
  87970. */
  87971. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87972. /**
  87973. * Disposes a previously registered javascript function called after the rendering.
  87974. * @param func defines the function to remove
  87975. * @returns the current mesh
  87976. */
  87977. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87978. /** @hidden */
  87979. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87980. /** @hidden */
  87981. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87982. /** @hidden */
  87983. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87984. /** @hidden */
  87985. _rebuild(): void;
  87986. /** @hidden */
  87987. _freeze(): void;
  87988. /** @hidden */
  87989. _unFreeze(): void;
  87990. /**
  87991. * 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
  87992. * @param subMesh defines the subMesh to render
  87993. * @param enableAlphaMode defines if alpha mode can be changed
  87994. * @returns the current mesh
  87995. */
  87996. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87997. private _onBeforeDraw;
  87998. /**
  87999. * Renormalize the mesh and patch it up if there are no weights
  88000. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88001. * However in the case of zero weights then we set just a single influence to 1.
  88002. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88003. */
  88004. cleanMatrixWeights(): void;
  88005. private normalizeSkinFourWeights;
  88006. private normalizeSkinWeightsAndExtra;
  88007. /**
  88008. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88009. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88010. * the user know there was an issue with importing the mesh
  88011. * @returns a validation object with skinned, valid and report string
  88012. */
  88013. validateSkinning(): {
  88014. skinned: boolean;
  88015. valid: boolean;
  88016. report: string;
  88017. };
  88018. /** @hidden */
  88019. _checkDelayState(): Mesh;
  88020. private _queueLoad;
  88021. /**
  88022. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88023. * A mesh is in the frustum if its bounding box intersects the frustum
  88024. * @param frustumPlanes defines the frustum to test
  88025. * @returns true if the mesh is in the frustum planes
  88026. */
  88027. isInFrustum(frustumPlanes: Plane[]): boolean;
  88028. /**
  88029. * Sets the mesh material by the material or multiMaterial `id` property
  88030. * @param id is a string identifying the material or the multiMaterial
  88031. * @returns the current mesh
  88032. */
  88033. setMaterialByID(id: string): Mesh;
  88034. /**
  88035. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88036. * @returns an array of IAnimatable
  88037. */
  88038. getAnimatables(): IAnimatable[];
  88039. /**
  88040. * Modifies the mesh geometry according to the passed transformation matrix.
  88041. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88042. * The mesh normals are modified using the same transformation.
  88043. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88044. * @param transform defines the transform matrix to use
  88045. * @see http://doc.babylonjs.com/resources/baking_transformations
  88046. * @returns the current mesh
  88047. */
  88048. bakeTransformIntoVertices(transform: Matrix): Mesh;
  88049. /**
  88050. * Modifies the mesh geometry according to its own current World Matrix.
  88051. * The mesh World Matrix is then reset.
  88052. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88053. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88054. * @see http://doc.babylonjs.com/resources/baking_transformations
  88055. * @returns the current mesh
  88056. */
  88057. bakeCurrentTransformIntoVertices(): Mesh;
  88058. /** @hidden */
  88059. readonly _positions: Nullable<Vector3[]>;
  88060. /** @hidden */
  88061. _resetPointsArrayCache(): Mesh;
  88062. /** @hidden */
  88063. _generatePointsArray(): boolean;
  88064. /**
  88065. * Returns a new Mesh object generated from the current mesh properties.
  88066. * This method must not get confused with createInstance()
  88067. * @param name is a string, the name given to the new mesh
  88068. * @param newParent can be any Node object (default `null`)
  88069. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88070. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88071. * @returns a new mesh
  88072. */
  88073. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  88074. /**
  88075. * Releases resources associated with this mesh.
  88076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88078. */
  88079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88080. /**
  88081. * Modifies the mesh geometry according to a displacement map.
  88082. * 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.
  88083. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88084. * @param url is a string, the URL from the image file is to be downloaded.
  88085. * @param minHeight is the lower limit of the displacement.
  88086. * @param maxHeight is the upper limit of the displacement.
  88087. * @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.
  88088. * @param uvOffset is an optional vector2 used to offset UV.
  88089. * @param uvScale is an optional vector2 used to scale UV.
  88090. * @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.
  88091. * @returns the Mesh.
  88092. */
  88093. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88094. /**
  88095. * Modifies the mesh geometry according to a displacementMap buffer.
  88096. * 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.
  88097. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  88098. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  88099. * @param heightMapWidth is the width of the buffer image.
  88100. * @param heightMapHeight is the height of the buffer image.
  88101. * @param minHeight is the lower limit of the displacement.
  88102. * @param maxHeight is the upper limit of the displacement.
  88103. * @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.
  88104. * @param uvOffset is an optional vector2 used to offset UV.
  88105. * @param uvScale is an optional vector2 used to scale UV.
  88106. * @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.
  88107. * @returns the Mesh.
  88108. */
  88109. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  88110. /**
  88111. * Modify the mesh to get a flat shading rendering.
  88112. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  88113. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  88114. * @returns current mesh
  88115. */
  88116. convertToFlatShadedMesh(): Mesh;
  88117. /**
  88118. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  88119. * In other words, more vertices, no more indices and a single bigger VBO.
  88120. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  88121. * @returns current mesh
  88122. */
  88123. convertToUnIndexedMesh(): Mesh;
  88124. /**
  88125. * Inverses facet orientations.
  88126. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88127. * @param flipNormals will also inverts the normals
  88128. * @returns current mesh
  88129. */
  88130. flipFaces(flipNormals?: boolean): Mesh;
  88131. /**
  88132. * Increase the number of facets and hence vertices in a mesh
  88133. * Vertex normals are interpolated from existing vertex normals
  88134. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88135. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  88136. */
  88137. increaseVertices(numberPerEdge: number): void;
  88138. /**
  88139. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  88140. * This will undo any application of covertToFlatShadedMesh
  88141. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  88142. */
  88143. forceSharedVertices(): void;
  88144. /** @hidden */
  88145. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  88146. /** @hidden */
  88147. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  88148. /**
  88149. * Creates a new InstancedMesh object from the mesh model.
  88150. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88151. * @param name defines the name of the new instance
  88152. * @returns a new InstancedMesh
  88153. */
  88154. createInstance(name: string): InstancedMesh;
  88155. /**
  88156. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  88157. * After this call, all the mesh instances have the same submeshes than the current mesh.
  88158. * @returns the current mesh
  88159. */
  88160. synchronizeInstances(): Mesh;
  88161. /**
  88162. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  88163. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  88164. * This should be used together with the simplification to avoid disappearing triangles.
  88165. * @param successCallback an optional success callback to be called after the optimization finished.
  88166. * @returns the current mesh
  88167. */
  88168. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  88169. /**
  88170. * Serialize current mesh
  88171. * @param serializationObject defines the object which will receive the serialization data
  88172. */
  88173. serialize(serializationObject: any): void;
  88174. /** @hidden */
  88175. _syncGeometryWithMorphTargetManager(): void;
  88176. /** @hidden */
  88177. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  88178. /**
  88179. * Returns a new Mesh object parsed from the source provided.
  88180. * @param parsedMesh is the source
  88181. * @param scene defines the hosting scene
  88182. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  88183. * @returns a new Mesh
  88184. */
  88185. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  88186. /**
  88187. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  88188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88189. * @param name defines the name of the mesh to create
  88190. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  88191. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  88192. * @param closePath creates a seam between the first and the last points of each path of the path array
  88193. * @param offset is taken in account only if the `pathArray` is containing a single path
  88194. * @param scene defines the hosting scene
  88195. * @param updatable defines if the mesh must be flagged as updatable
  88196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88197. * @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)
  88198. * @returns a new Mesh
  88199. */
  88200. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88201. /**
  88202. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  88203. * @param name defines the name of the mesh to create
  88204. * @param radius sets the radius size (float) of the polygon (default 0.5)
  88205. * @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
  88206. * @param scene defines the hosting scene
  88207. * @param updatable defines if the mesh must be flagged as updatable
  88208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88209. * @returns a new Mesh
  88210. */
  88211. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88212. /**
  88213. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  88214. * @param name defines the name of the mesh to create
  88215. * @param size sets the size (float) of each box side (default 1)
  88216. * @param scene defines the hosting scene
  88217. * @param updatable defines if the mesh must be flagged as updatable
  88218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88219. * @returns a new Mesh
  88220. */
  88221. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  88222. /**
  88223. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  88224. * @param name defines the name of the mesh to create
  88225. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88226. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88227. * @param scene defines the hosting scene
  88228. * @param updatable defines if the mesh must be flagged as updatable
  88229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88230. * @returns a new Mesh
  88231. */
  88232. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88233. /**
  88234. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  88235. * @param name defines the name of the mesh to create
  88236. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  88237. * @param diameter sets the diameter size (float) of the sphere (default 1)
  88238. * @param scene defines the hosting scene
  88239. * @returns a new Mesh
  88240. */
  88241. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  88242. /**
  88243. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  88244. * @param name defines the name of the mesh to create
  88245. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  88246. * @param diameterTop set the top cap diameter (floats, default 1)
  88247. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  88248. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  88249. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  88250. * @param scene defines the hosting scene
  88251. * @param updatable defines if the mesh must be flagged as updatable
  88252. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88253. * @returns a new Mesh
  88254. */
  88255. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  88256. /**
  88257. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  88258. * @param name defines the name of the mesh to create
  88259. * @param diameter sets the diameter size (float) of the torus (default 1)
  88260. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  88261. * @param tessellation sets the number of torus sides (postive integer, default 16)
  88262. * @param scene defines the hosting scene
  88263. * @param updatable defines if the mesh must be flagged as updatable
  88264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88265. * @returns a new Mesh
  88266. */
  88267. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88268. /**
  88269. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  88270. * @param name defines the name of the mesh to create
  88271. * @param radius sets the global radius size (float) of the torus knot (default 2)
  88272. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  88273. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  88274. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  88275. * @param p the number of windings on X axis (positive integers, default 2)
  88276. * @param q the number of windings on Y axis (positive integers, default 3)
  88277. * @param scene defines the hosting scene
  88278. * @param updatable defines if the mesh must be flagged as updatable
  88279. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88280. * @returns a new Mesh
  88281. */
  88282. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88283. /**
  88284. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  88285. * @param name defines the name of the mesh to create
  88286. * @param points is an array successive Vector3
  88287. * @param scene defines the hosting scene
  88288. * @param updatable defines if the mesh must be flagged as updatable
  88289. * @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).
  88290. * @returns a new Mesh
  88291. */
  88292. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  88293. /**
  88294. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  88295. * @param name defines the name of the mesh to create
  88296. * @param points is an array successive Vector3
  88297. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  88298. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88299. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  88300. * @param scene defines the hosting scene
  88301. * @param updatable defines if the mesh must be flagged as updatable
  88302. * @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)
  88303. * @returns a new Mesh
  88304. */
  88305. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  88306. /**
  88307. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  88308. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  88309. * 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.
  88310. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88311. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88312. * Remember you can only change the shape positions, not their number when updating a polygon.
  88313. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  88314. * @param name defines the name of the mesh to create
  88315. * @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
  88316. * @param scene defines the hosting scene
  88317. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88318. * @param updatable defines if the mesh must be flagged as updatable
  88319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88320. * @param earcutInjection can be used to inject your own earcut reference
  88321. * @returns a new Mesh
  88322. */
  88323. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88324. /**
  88325. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88326. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88327. * @param name defines the name of the mesh to create
  88328. * @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
  88329. * @param depth defines the height of extrusion
  88330. * @param scene defines the hosting scene
  88331. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88332. * @param updatable defines if the mesh must be flagged as updatable
  88333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88334. * @param earcutInjection can be used to inject your own earcut reference
  88335. * @returns a new Mesh
  88336. */
  88337. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88338. /**
  88339. * Creates an extruded shape mesh.
  88340. * 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
  88341. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88342. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88343. * @param name defines the name of the mesh to create
  88344. * @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
  88345. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88346. * @param scale is the value to scale the shape
  88347. * @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
  88348. * @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
  88349. * @param scene defines the hosting scene
  88350. * @param updatable defines if the mesh must be flagged as updatable
  88351. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88352. * @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)
  88353. * @returns a new Mesh
  88354. */
  88355. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88356. /**
  88357. * Creates an custom extruded shape mesh.
  88358. * The custom extrusion is a parametric shape.
  88359. * It has no predefined shape. Its final shape will depend on the input parameters.
  88360. * Please consider using the same method from the MeshBuilder class instead
  88361. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88362. * @param name defines the name of the mesh to create
  88363. * @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
  88364. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88365. * @param scaleFunction is a custom Javascript function called on each path point
  88366. * @param rotationFunction is a custom Javascript function called on each path point
  88367. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88368. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88369. * @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
  88370. * @param scene defines the hosting scene
  88371. * @param updatable defines if the mesh must be flagged as updatable
  88372. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88373. * @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)
  88374. * @returns a new Mesh
  88375. */
  88376. 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;
  88377. /**
  88378. * Creates lathe mesh.
  88379. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88380. * Please consider using the same method from the MeshBuilder class instead
  88381. * @param name defines the name of the mesh to create
  88382. * @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
  88383. * @param radius is the radius value of the lathe
  88384. * @param tessellation is the side number of the lathe.
  88385. * @param scene defines the hosting scene
  88386. * @param updatable defines if the mesh must be flagged as updatable
  88387. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88388. * @returns a new Mesh
  88389. */
  88390. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88391. /**
  88392. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88393. * @param name defines the name of the mesh to create
  88394. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88395. * @param scene defines the hosting scene
  88396. * @param updatable defines if the mesh must be flagged as updatable
  88397. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88398. * @returns a new Mesh
  88399. */
  88400. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88401. /**
  88402. * Creates a ground mesh.
  88403. * Please consider using the same method from the MeshBuilder class instead
  88404. * @param name defines the name of the mesh to create
  88405. * @param width set the width of the ground
  88406. * @param height set the height of the ground
  88407. * @param subdivisions sets the number of subdivisions per side
  88408. * @param scene defines the hosting scene
  88409. * @param updatable defines if the mesh must be flagged as updatable
  88410. * @returns a new Mesh
  88411. */
  88412. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88413. /**
  88414. * Creates a tiled ground mesh.
  88415. * Please consider using the same method from the MeshBuilder class instead
  88416. * @param name defines the name of the mesh to create
  88417. * @param xmin set the ground minimum X coordinate
  88418. * @param zmin set the ground minimum Y coordinate
  88419. * @param xmax set the ground maximum X coordinate
  88420. * @param zmax set the ground maximum Z coordinate
  88421. * @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
  88422. * @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
  88423. * @param scene defines the hosting scene
  88424. * @param updatable defines if the mesh must be flagged as updatable
  88425. * @returns a new Mesh
  88426. */
  88427. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88428. w: number;
  88429. h: number;
  88430. }, precision: {
  88431. w: number;
  88432. h: number;
  88433. }, scene: Scene, updatable?: boolean): Mesh;
  88434. /**
  88435. * Creates a ground mesh from a height map.
  88436. * Please consider using the same method from the MeshBuilder class instead
  88437. * @see http://doc.babylonjs.com/babylon101/height_map
  88438. * @param name defines the name of the mesh to create
  88439. * @param url sets the URL of the height map image resource
  88440. * @param width set the ground width size
  88441. * @param height set the ground height size
  88442. * @param subdivisions sets the number of subdivision per side
  88443. * @param minHeight is the minimum altitude on the ground
  88444. * @param maxHeight is the maximum altitude on the ground
  88445. * @param scene defines the hosting scene
  88446. * @param updatable defines if the mesh must be flagged as updatable
  88447. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88448. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88449. * @returns a new Mesh
  88450. */
  88451. 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;
  88452. /**
  88453. * Creates a tube mesh.
  88454. * The tube is a parametric shape.
  88455. * It has no predefined shape. Its final shape will depend on the input parameters.
  88456. * Please consider using the same method from the MeshBuilder class instead
  88457. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88458. * @param name defines the name of the mesh to create
  88459. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88460. * @param radius sets the tube radius size
  88461. * @param tessellation is the number of sides on the tubular surface
  88462. * @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
  88463. * @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
  88464. * @param scene defines the hosting scene
  88465. * @param updatable defines if the mesh must be flagged as updatable
  88466. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88467. * @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)
  88468. * @returns a new Mesh
  88469. */
  88470. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88471. (i: number, distance: number): number;
  88472. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88473. /**
  88474. * Creates a polyhedron mesh.
  88475. * Please consider using the same method from the MeshBuilder class instead.
  88476. * * 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
  88477. * * The parameter `size` (positive float, default 1) sets the polygon size
  88478. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88479. * * 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`
  88480. * * 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
  88481. * * 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)`)
  88482. * * 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
  88483. * * 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
  88484. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88485. * * If you create a double-sided mesh, you can choose what parts of 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
  88486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88487. * @param name defines the name of the mesh to create
  88488. * @param options defines the options used to create the mesh
  88489. * @param scene defines the hosting scene
  88490. * @returns a new Mesh
  88491. */
  88492. static CreatePolyhedron(name: string, options: {
  88493. type?: number;
  88494. size?: number;
  88495. sizeX?: number;
  88496. sizeY?: number;
  88497. sizeZ?: number;
  88498. custom?: any;
  88499. faceUV?: Vector4[];
  88500. faceColors?: Color4[];
  88501. updatable?: boolean;
  88502. sideOrientation?: number;
  88503. }, scene: Scene): Mesh;
  88504. /**
  88505. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88506. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88507. * * 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`)
  88508. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88509. * * 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
  88510. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88511. * * If you create a double-sided mesh, you can choose what parts of 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
  88512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88513. * @param name defines the name of the mesh
  88514. * @param options defines the options used to create the mesh
  88515. * @param scene defines the hosting scene
  88516. * @returns a new Mesh
  88517. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88518. */
  88519. static CreateIcoSphere(name: string, options: {
  88520. radius?: number;
  88521. flat?: boolean;
  88522. subdivisions?: number;
  88523. sideOrientation?: number;
  88524. updatable?: boolean;
  88525. }, scene: Scene): Mesh;
  88526. /**
  88527. * Creates a decal mesh.
  88528. * Please consider using the same method from the MeshBuilder class instead.
  88529. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88530. * @param name defines the name of the mesh
  88531. * @param sourceMesh defines the mesh receiving the decal
  88532. * @param position sets the position of the decal in world coordinates
  88533. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88534. * @param size sets the decal scaling
  88535. * @param angle sets the angle to rotate the decal
  88536. * @returns a new Mesh
  88537. */
  88538. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88539. /**
  88540. * Prepare internal position array for software CPU skinning
  88541. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88542. */
  88543. setPositionsForCPUSkinning(): Float32Array;
  88544. /**
  88545. * Prepare internal normal array for software CPU skinning
  88546. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88547. */
  88548. setNormalsForCPUSkinning(): Float32Array;
  88549. /**
  88550. * Updates the vertex buffer by applying transformation from the bones
  88551. * @param skeleton defines the skeleton to apply to current mesh
  88552. * @returns the current mesh
  88553. */
  88554. applySkeleton(skeleton: Skeleton): Mesh;
  88555. /**
  88556. * 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
  88557. * @param meshes defines the list of meshes to scan
  88558. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88559. */
  88560. static MinMax(meshes: AbstractMesh[]): {
  88561. min: Vector3;
  88562. max: Vector3;
  88563. };
  88564. /**
  88565. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88566. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88567. * @returns a vector3
  88568. */
  88569. static Center(meshesOrMinMaxVector: {
  88570. min: Vector3;
  88571. max: Vector3;
  88572. } | AbstractMesh[]): Vector3;
  88573. /**
  88574. * Merge the array of meshes into a single mesh for performance reasons.
  88575. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88576. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88577. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88578. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88579. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88580. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88581. * @returns a new mesh
  88582. */
  88583. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88584. /** @hidden */
  88585. addInstance(instance: InstancedMesh): void;
  88586. /** @hidden */
  88587. removeInstance(instance: InstancedMesh): void;
  88588. }
  88589. }
  88590. declare module BABYLON {
  88591. /**
  88592. * This is the base class of all the camera used in the application.
  88593. * @see http://doc.babylonjs.com/features/cameras
  88594. */
  88595. export class Camera extends Node {
  88596. /** @hidden */
  88597. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88598. /**
  88599. * This is the default projection mode used by the cameras.
  88600. * It helps recreating a feeling of perspective and better appreciate depth.
  88601. * This is the best way to simulate real life cameras.
  88602. */
  88603. static readonly PERSPECTIVE_CAMERA: number;
  88604. /**
  88605. * This helps creating camera with an orthographic mode.
  88606. * 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.
  88607. */
  88608. static readonly ORTHOGRAPHIC_CAMERA: number;
  88609. /**
  88610. * This is the default FOV mode for perspective cameras.
  88611. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88612. */
  88613. static readonly FOVMODE_VERTICAL_FIXED: number;
  88614. /**
  88615. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88616. */
  88617. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88618. /**
  88619. * This specifies ther is no need for a camera rig.
  88620. * Basically only one eye is rendered corresponding to the camera.
  88621. */
  88622. static readonly RIG_MODE_NONE: number;
  88623. /**
  88624. * Simulates a camera Rig with one blue eye and one red eye.
  88625. * This can be use with 3d blue and red glasses.
  88626. */
  88627. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88628. /**
  88629. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88630. */
  88631. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88632. /**
  88633. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88634. */
  88635. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88636. /**
  88637. * Defines that both eyes of the camera will be rendered over under each other.
  88638. */
  88639. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88640. /**
  88641. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88642. */
  88643. static readonly RIG_MODE_VR: number;
  88644. /**
  88645. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88646. */
  88647. static readonly RIG_MODE_WEBVR: number;
  88648. /**
  88649. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88650. */
  88651. static readonly RIG_MODE_CUSTOM: number;
  88652. /**
  88653. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88654. */
  88655. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88656. /**
  88657. * Define the input manager associated with the camera.
  88658. */
  88659. inputs: CameraInputsManager<Camera>;
  88660. /** @hidden */
  88661. _position: Vector3;
  88662. /**
  88663. * Define the current local position of the camera in the scene
  88664. */
  88665. position: Vector3;
  88666. /**
  88667. * The vector the camera should consider as up.
  88668. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88669. */
  88670. upVector: Vector3;
  88671. /**
  88672. * Define the current limit on the left side for an orthographic camera
  88673. * In scene unit
  88674. */
  88675. orthoLeft: Nullable<number>;
  88676. /**
  88677. * Define the current limit on the right side for an orthographic camera
  88678. * In scene unit
  88679. */
  88680. orthoRight: Nullable<number>;
  88681. /**
  88682. * Define the current limit on the bottom side for an orthographic camera
  88683. * In scene unit
  88684. */
  88685. orthoBottom: Nullable<number>;
  88686. /**
  88687. * Define the current limit on the top side for an orthographic camera
  88688. * In scene unit
  88689. */
  88690. orthoTop: Nullable<number>;
  88691. /**
  88692. * Field Of View is set in Radians. (default is 0.8)
  88693. */
  88694. fov: number;
  88695. /**
  88696. * Define the minimum distance the camera can see from.
  88697. * This is important to note that the depth buffer are not infinite and the closer it starts
  88698. * the more your scene might encounter depth fighting issue.
  88699. */
  88700. minZ: number;
  88701. /**
  88702. * Define the maximum distance the camera can see to.
  88703. * This is important to note that the depth buffer are not infinite and the further it end
  88704. * the more your scene might encounter depth fighting issue.
  88705. */
  88706. maxZ: number;
  88707. /**
  88708. * Define the default inertia of the camera.
  88709. * This helps giving a smooth feeling to the camera movement.
  88710. */
  88711. inertia: number;
  88712. /**
  88713. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88714. */
  88715. mode: number;
  88716. /**
  88717. * Define wether the camera is intermediate.
  88718. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88719. */
  88720. isIntermediate: boolean;
  88721. /**
  88722. * Define the viewport of the camera.
  88723. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88724. */
  88725. viewport: Viewport;
  88726. /**
  88727. * Restricts the camera to viewing objects with the same layerMask.
  88728. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88729. */
  88730. layerMask: number;
  88731. /**
  88732. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88733. */
  88734. fovMode: number;
  88735. /**
  88736. * Rig mode of the camera.
  88737. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88738. * This is normally controlled byt the camera themselves as internal use.
  88739. */
  88740. cameraRigMode: number;
  88741. /**
  88742. * Defines the distance between both "eyes" in case of a RIG
  88743. */
  88744. interaxialDistance: number;
  88745. /**
  88746. * Defines if stereoscopic rendering is done side by side or over under.
  88747. */
  88748. isStereoscopicSideBySide: boolean;
  88749. /**
  88750. * 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
  88751. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88752. * else in the scene. (Eg. security camera)
  88753. *
  88754. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  88755. */
  88756. customRenderTargets: RenderTargetTexture[];
  88757. /**
  88758. * When set, the camera will render to this render target instead of the default canvas
  88759. *
  88760. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88761. */
  88762. outputRenderTarget: Nullable<RenderTargetTexture>;
  88763. /**
  88764. * Observable triggered when the camera view matrix has changed.
  88765. */
  88766. onViewMatrixChangedObservable: Observable<Camera>;
  88767. /**
  88768. * Observable triggered when the camera Projection matrix has changed.
  88769. */
  88770. onProjectionMatrixChangedObservable: Observable<Camera>;
  88771. /**
  88772. * Observable triggered when the inputs have been processed.
  88773. */
  88774. onAfterCheckInputsObservable: Observable<Camera>;
  88775. /**
  88776. * Observable triggered when reset has been called and applied to the camera.
  88777. */
  88778. onRestoreStateObservable: Observable<Camera>;
  88779. /** @hidden */
  88780. _cameraRigParams: any;
  88781. /** @hidden */
  88782. _rigCameras: Camera[];
  88783. /** @hidden */
  88784. _rigPostProcess: Nullable<PostProcess>;
  88785. protected _webvrViewMatrix: Matrix;
  88786. /** @hidden */
  88787. _skipRendering: boolean;
  88788. /** @hidden */
  88789. _projectionMatrix: Matrix;
  88790. /** @hidden */
  88791. _postProcesses: Nullable<PostProcess>[];
  88792. /** @hidden */
  88793. _activeMeshes: SmartArray<AbstractMesh>;
  88794. protected _globalPosition: Vector3;
  88795. /** @hidden */
  88796. _computedViewMatrix: Matrix;
  88797. private _doNotComputeProjectionMatrix;
  88798. private _transformMatrix;
  88799. private _frustumPlanes;
  88800. private _refreshFrustumPlanes;
  88801. private _storedFov;
  88802. private _stateStored;
  88803. /**
  88804. * Instantiates a new camera object.
  88805. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88806. * @see http://doc.babylonjs.com/features/cameras
  88807. * @param name Defines the name of the camera in the scene
  88808. * @param position Defines the position of the camera
  88809. * @param scene Defines the scene the camera belongs too
  88810. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88811. */
  88812. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88813. /**
  88814. * Store current camera state (fov, position, etc..)
  88815. * @returns the camera
  88816. */
  88817. storeState(): Camera;
  88818. /**
  88819. * Restores the camera state values if it has been stored. You must call storeState() first
  88820. */
  88821. protected _restoreStateValues(): boolean;
  88822. /**
  88823. * Restored camera state. You must call storeState() first.
  88824. * @returns true if restored and false otherwise
  88825. */
  88826. restoreState(): boolean;
  88827. /**
  88828. * Gets the class name of the camera.
  88829. * @returns the class name
  88830. */
  88831. getClassName(): string;
  88832. /** @hidden */
  88833. readonly _isCamera: boolean;
  88834. /**
  88835. * Gets a string representation of the camera useful for debug purpose.
  88836. * @param fullDetails Defines that a more verboe level of logging is required
  88837. * @returns the string representation
  88838. */
  88839. toString(fullDetails?: boolean): string;
  88840. /**
  88841. * Gets the current world space position of the camera.
  88842. */
  88843. readonly globalPosition: Vector3;
  88844. /**
  88845. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88846. * @returns the active meshe list
  88847. */
  88848. getActiveMeshes(): SmartArray<AbstractMesh>;
  88849. /**
  88850. * Check wether a mesh is part of the current active mesh list of the camera
  88851. * @param mesh Defines the mesh to check
  88852. * @returns true if active, false otherwise
  88853. */
  88854. isActiveMesh(mesh: Mesh): boolean;
  88855. /**
  88856. * Is this camera ready to be used/rendered
  88857. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88858. * @return true if the camera is ready
  88859. */
  88860. isReady(completeCheck?: boolean): boolean;
  88861. /** @hidden */
  88862. _initCache(): void;
  88863. /** @hidden */
  88864. _updateCache(ignoreParentClass?: boolean): void;
  88865. /** @hidden */
  88866. _isSynchronized(): boolean;
  88867. /** @hidden */
  88868. _isSynchronizedViewMatrix(): boolean;
  88869. /** @hidden */
  88870. _isSynchronizedProjectionMatrix(): boolean;
  88871. /**
  88872. * Attach the input controls to a specific dom element to get the input from.
  88873. * @param element Defines the element the controls should be listened from
  88874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88875. */
  88876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88877. /**
  88878. * Detach the current controls from the specified dom element.
  88879. * @param element Defines the element to stop listening the inputs from
  88880. */
  88881. detachControl(element: HTMLElement): void;
  88882. /**
  88883. * Update the camera state according to the different inputs gathered during the frame.
  88884. */
  88885. update(): void;
  88886. /** @hidden */
  88887. _checkInputs(): void;
  88888. /** @hidden */
  88889. readonly rigCameras: Camera[];
  88890. /**
  88891. * Gets the post process used by the rig cameras
  88892. */
  88893. readonly rigPostProcess: Nullable<PostProcess>;
  88894. /**
  88895. * Internal, gets the first post proces.
  88896. * @returns the first post process to be run on this camera.
  88897. */
  88898. _getFirstPostProcess(): Nullable<PostProcess>;
  88899. private _cascadePostProcessesToRigCams;
  88900. /**
  88901. * Attach a post process to the camera.
  88902. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88903. * @param postProcess The post process to attach to the camera
  88904. * @param insertAt The position of the post process in case several of them are in use in the scene
  88905. * @returns the position the post process has been inserted at
  88906. */
  88907. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88908. /**
  88909. * Detach a post process to the camera.
  88910. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88911. * @param postProcess The post process to detach from the camera
  88912. */
  88913. detachPostProcess(postProcess: PostProcess): void;
  88914. /**
  88915. * Gets the current world matrix of the camera
  88916. */
  88917. getWorldMatrix(): Matrix;
  88918. /** @hidden */
  88919. _getViewMatrix(): Matrix;
  88920. /**
  88921. * Gets the current view matrix of the camera.
  88922. * @param force forces the camera to recompute the matrix without looking at the cached state
  88923. * @returns the view matrix
  88924. */
  88925. getViewMatrix(force?: boolean): Matrix;
  88926. /**
  88927. * Freeze the projection matrix.
  88928. * It will prevent the cache check of the camera projection compute and can speed up perf
  88929. * if no parameter of the camera are meant to change
  88930. * @param projection Defines manually a projection if necessary
  88931. */
  88932. freezeProjectionMatrix(projection?: Matrix): void;
  88933. /**
  88934. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88935. */
  88936. unfreezeProjectionMatrix(): void;
  88937. /**
  88938. * Gets the current projection matrix of the camera.
  88939. * @param force forces the camera to recompute the matrix without looking at the cached state
  88940. * @returns the projection matrix
  88941. */
  88942. getProjectionMatrix(force?: boolean): Matrix;
  88943. /**
  88944. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88945. * @returns a Matrix
  88946. */
  88947. getTransformationMatrix(): Matrix;
  88948. private _updateFrustumPlanes;
  88949. /**
  88950. * Checks if a cullable object (mesh...) is in the camera frustum
  88951. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88952. * @param target The object to check
  88953. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88954. * @returns true if the object is in frustum otherwise false
  88955. */
  88956. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88957. /**
  88958. * Checks if a cullable object (mesh...) is in the camera frustum
  88959. * Unlike isInFrustum this cheks the full bounding box
  88960. * @param target The object to check
  88961. * @returns true if the object is in frustum otherwise false
  88962. */
  88963. isCompletelyInFrustum(target: ICullable): boolean;
  88964. /**
  88965. * Gets a ray in the forward direction from the camera.
  88966. * @param length Defines the length of the ray to create
  88967. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88968. * @param origin Defines the start point of the ray which defaults to the camera position
  88969. * @returns the forward ray
  88970. */
  88971. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88972. /**
  88973. * Releases resources associated with this node.
  88974. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88975. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88976. */
  88977. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88978. /** @hidden */
  88979. _isLeftCamera: boolean;
  88980. /**
  88981. * Gets the left camera of a rig setup in case of Rigged Camera
  88982. */
  88983. readonly isLeftCamera: boolean;
  88984. /** @hidden */
  88985. _isRightCamera: boolean;
  88986. /**
  88987. * Gets the right camera of a rig setup in case of Rigged Camera
  88988. */
  88989. readonly isRightCamera: boolean;
  88990. /**
  88991. * Gets the left camera of a rig setup in case of Rigged Camera
  88992. */
  88993. readonly leftCamera: Nullable<FreeCamera>;
  88994. /**
  88995. * Gets the right camera of a rig setup in case of Rigged Camera
  88996. */
  88997. readonly rightCamera: Nullable<FreeCamera>;
  88998. /**
  88999. * Gets the left camera target of a rig setup in case of Rigged Camera
  89000. * @returns the target position
  89001. */
  89002. getLeftTarget(): Nullable<Vector3>;
  89003. /**
  89004. * Gets the right camera target of a rig setup in case of Rigged Camera
  89005. * @returns the target position
  89006. */
  89007. getRightTarget(): Nullable<Vector3>;
  89008. /**
  89009. * @hidden
  89010. */
  89011. setCameraRigMode(mode: number, rigParams: any): void;
  89012. /** @hidden */
  89013. static _setStereoscopicRigMode(camera: Camera): void;
  89014. /** @hidden */
  89015. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89016. /** @hidden */
  89017. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89018. /** @hidden */
  89019. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89020. /** @hidden */
  89021. _getVRProjectionMatrix(): Matrix;
  89022. protected _updateCameraRotationMatrix(): void;
  89023. protected _updateWebVRCameraRotationMatrix(): void;
  89024. /**
  89025. * This function MUST be overwritten by the different WebVR cameras available.
  89026. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89027. * @hidden
  89028. */
  89029. _getWebVRProjectionMatrix(): Matrix;
  89030. /**
  89031. * This function MUST be overwritten by the different WebVR cameras available.
  89032. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89033. * @hidden
  89034. */
  89035. _getWebVRViewMatrix(): Matrix;
  89036. /** @hidden */
  89037. setCameraRigParameter(name: string, value: any): void;
  89038. /**
  89039. * needs to be overridden by children so sub has required properties to be copied
  89040. * @hidden
  89041. */
  89042. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89043. /**
  89044. * May need to be overridden by children
  89045. * @hidden
  89046. */
  89047. _updateRigCameras(): void;
  89048. /** @hidden */
  89049. _setupInputs(): void;
  89050. /**
  89051. * Serialiaze the camera setup to a json represention
  89052. * @returns the JSON representation
  89053. */
  89054. serialize(): any;
  89055. /**
  89056. * Clones the current camera.
  89057. * @param name The cloned camera name
  89058. * @returns the cloned camera
  89059. */
  89060. clone(name: string): Camera;
  89061. /**
  89062. * Gets the direction of the camera relative to a given local axis.
  89063. * @param localAxis Defines the reference axis to provide a relative direction.
  89064. * @return the direction
  89065. */
  89066. getDirection(localAxis: Vector3): Vector3;
  89067. /**
  89068. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89069. * @param localAxis Defines the reference axis to provide a relative direction.
  89070. * @param result Defines the vector to store the result in
  89071. */
  89072. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89073. /**
  89074. * Gets a camera constructor for a given camera type
  89075. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89076. * @param name The name of the camera the result will be able to instantiate
  89077. * @param scene The scene the result will construct the camera in
  89078. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89079. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89080. * @returns a factory method to construc the camera
  89081. */
  89082. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89083. /**
  89084. * Compute the world matrix of the camera.
  89085. * @returns the camera workd matrix
  89086. */
  89087. computeWorldMatrix(): Matrix;
  89088. /**
  89089. * Parse a JSON and creates the camera from the parsed information
  89090. * @param parsedCamera The JSON to parse
  89091. * @param scene The scene to instantiate the camera in
  89092. * @returns the newly constructed camera
  89093. */
  89094. static Parse(parsedCamera: any, scene: Scene): Camera;
  89095. }
  89096. }
  89097. declare module BABYLON {
  89098. /**
  89099. * Class containing static functions to help procedurally build meshes
  89100. */
  89101. export class DiscBuilder {
  89102. /**
  89103. * Creates a plane polygonal mesh. By default, this is a disc
  89104. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  89105. * * 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
  89106. * * 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
  89107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  89109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89110. * @param name defines the name of the mesh
  89111. * @param options defines the options used to create the mesh
  89112. * @param scene defines the hosting scene
  89113. * @returns the plane polygonal mesh
  89114. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  89115. */
  89116. static CreateDisc(name: string, options: {
  89117. radius?: number;
  89118. tessellation?: number;
  89119. arc?: number;
  89120. updatable?: boolean;
  89121. sideOrientation?: number;
  89122. frontUVs?: Vector4;
  89123. backUVs?: Vector4;
  89124. }, scene?: Nullable<Scene>): Mesh;
  89125. }
  89126. }
  89127. declare module BABYLON {
  89128. /**
  89129. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  89130. *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.
  89131. * The SPS is also a particle system. It provides some methods to manage the particles.
  89132. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  89133. *
  89134. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  89135. */
  89136. export class SolidParticleSystem implements IDisposable {
  89137. /**
  89138. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  89139. * Example : var p = SPS.particles[i];
  89140. */
  89141. particles: SolidParticle[];
  89142. /**
  89143. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  89144. */
  89145. nbParticles: number;
  89146. /**
  89147. * If the particles must ever face the camera (default false). Useful for planar particles.
  89148. */
  89149. billboard: boolean;
  89150. /**
  89151. * Recompute normals when adding a shape
  89152. */
  89153. recomputeNormals: boolean;
  89154. /**
  89155. * This a counter ofr your own usage. It's not set by any SPS functions.
  89156. */
  89157. counter: number;
  89158. /**
  89159. * The SPS name. This name is also given to the underlying mesh.
  89160. */
  89161. name: string;
  89162. /**
  89163. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  89164. */
  89165. mesh: Mesh;
  89166. /**
  89167. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  89168. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  89169. */
  89170. vars: any;
  89171. /**
  89172. * This array is populated when the SPS is set as 'pickable'.
  89173. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  89174. * Each element of this array is an object `{idx: int, faceId: int}`.
  89175. * `idx` is the picked particle index in the `SPS.particles` array
  89176. * `faceId` is the picked face index counted within this particle.
  89177. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  89178. */
  89179. pickedParticles: {
  89180. idx: number;
  89181. faceId: number;
  89182. }[];
  89183. /**
  89184. * This array is populated when `enableDepthSort` is set to true.
  89185. * Each element of this array is an instance of the class DepthSortedParticle.
  89186. */
  89187. depthSortedParticles: DepthSortedParticle[];
  89188. /**
  89189. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  89190. * @hidden
  89191. */
  89192. _bSphereOnly: boolean;
  89193. /**
  89194. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  89195. * @hidden
  89196. */
  89197. _bSphereRadiusFactor: number;
  89198. private _scene;
  89199. private _positions;
  89200. private _indices;
  89201. private _normals;
  89202. private _colors;
  89203. private _uvs;
  89204. private _indices32;
  89205. private _positions32;
  89206. private _normals32;
  89207. private _fixedNormal32;
  89208. private _colors32;
  89209. private _uvs32;
  89210. private _index;
  89211. private _updatable;
  89212. private _pickable;
  89213. private _isVisibilityBoxLocked;
  89214. private _alwaysVisible;
  89215. private _depthSort;
  89216. private _shapeCounter;
  89217. private _copy;
  89218. private _color;
  89219. private _computeParticleColor;
  89220. private _computeParticleTexture;
  89221. private _computeParticleRotation;
  89222. private _computeParticleVertex;
  89223. private _computeBoundingBox;
  89224. private _depthSortParticles;
  89225. private _camera;
  89226. private _mustUnrotateFixedNormals;
  89227. private _particlesIntersect;
  89228. private _needs32Bits;
  89229. /**
  89230. * Creates a SPS (Solid Particle System) object.
  89231. * @param name (String) is the SPS name, this will be the underlying mesh name.
  89232. * @param scene (Scene) is the scene in which the SPS is added.
  89233. * @param options defines the options of the sps e.g.
  89234. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  89235. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  89236. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  89237. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  89238. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  89239. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  89240. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  89241. */
  89242. constructor(name: string, scene: Scene, options?: {
  89243. updatable?: boolean;
  89244. isPickable?: boolean;
  89245. enableDepthSort?: boolean;
  89246. particleIntersection?: boolean;
  89247. boundingSphereOnly?: boolean;
  89248. bSphereRadiusFactor?: number;
  89249. });
  89250. /**
  89251. * Builds the SPS underlying mesh. Returns a standard Mesh.
  89252. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  89253. * @returns the created mesh
  89254. */
  89255. buildMesh(): Mesh;
  89256. /**
  89257. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  89258. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  89259. * Thus the particles generated from `digest()` have their property `position` set yet.
  89260. * @param mesh ( Mesh ) is the mesh to be digested
  89261. * @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
  89262. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  89263. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  89264. * @returns the current SPS
  89265. */
  89266. digest(mesh: Mesh, options?: {
  89267. facetNb?: number;
  89268. number?: number;
  89269. delta?: number;
  89270. }): SolidParticleSystem;
  89271. private _unrotateFixedNormals;
  89272. private _resetCopy;
  89273. private _meshBuilder;
  89274. private _posToShape;
  89275. private _uvsToShapeUV;
  89276. private _addParticle;
  89277. /**
  89278. * Adds some particles to the SPS from the model shape. Returns the shape id.
  89279. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  89280. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  89281. * @param nb (positive integer) the number of particles to be created from this model
  89282. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  89283. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  89284. * @returns the number of shapes in the system
  89285. */
  89286. addShape(mesh: Mesh, nb: number, options?: {
  89287. positionFunction?: any;
  89288. vertexFunction?: any;
  89289. }): number;
  89290. private _rebuildParticle;
  89291. /**
  89292. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  89293. * @returns the SPS.
  89294. */
  89295. rebuildMesh(): SolidParticleSystem;
  89296. /**
  89297. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  89298. * This method calls `updateParticle()` for each particle of the SPS.
  89299. * For an animated SPS, it is usually called within the render loop.
  89300. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  89301. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  89302. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  89303. * @returns the SPS.
  89304. */
  89305. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  89306. /**
  89307. * Disposes the SPS.
  89308. */
  89309. dispose(): void;
  89310. /**
  89311. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  89312. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89313. * @returns the SPS.
  89314. */
  89315. refreshVisibleSize(): SolidParticleSystem;
  89316. /**
  89317. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  89318. * @param size the size (float) of the visibility box
  89319. * note : this doesn't lock the SPS mesh bounding box.
  89320. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89321. */
  89322. setVisibilityBox(size: number): void;
  89323. /**
  89324. * Gets whether the SPS as always visible or not
  89325. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89326. */
  89327. /**
  89328. * Sets the SPS as always visible or not
  89329. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89330. */
  89331. isAlwaysVisible: boolean;
  89332. /**
  89333. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89334. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89335. */
  89336. /**
  89337. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89338. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89339. */
  89340. isVisibilityBoxLocked: boolean;
  89341. /**
  89342. * Tells to `setParticles()` to compute the particle rotations or not.
  89343. * Default value : true. The SPS is faster when it's set to false.
  89344. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89345. */
  89346. /**
  89347. * Gets if `setParticles()` computes the particle rotations or not.
  89348. * Default value : true. The SPS is faster when it's set to false.
  89349. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89350. */
  89351. computeParticleRotation: boolean;
  89352. /**
  89353. * Tells to `setParticles()` to compute the particle colors or not.
  89354. * Default value : true. The SPS is faster when it's set to false.
  89355. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89356. */
  89357. /**
  89358. * Gets if `setParticles()` computes the particle colors or not.
  89359. * Default value : true. The SPS is faster when it's set to false.
  89360. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89361. */
  89362. computeParticleColor: boolean;
  89363. /**
  89364. * Gets if `setParticles()` computes the particle textures or not.
  89365. * Default value : true. The SPS is faster when it's set to false.
  89366. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89367. */
  89368. computeParticleTexture: boolean;
  89369. /**
  89370. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89371. * Default value : false. The SPS is faster when it's set to false.
  89372. * Note : the particle custom vertex positions aren't stored values.
  89373. */
  89374. /**
  89375. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89376. * Default value : false. The SPS is faster when it's set to false.
  89377. * Note : the particle custom vertex positions aren't stored values.
  89378. */
  89379. computeParticleVertex: boolean;
  89380. /**
  89381. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89382. */
  89383. /**
  89384. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89385. */
  89386. computeBoundingBox: boolean;
  89387. /**
  89388. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89389. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89390. * Default : `true`
  89391. */
  89392. /**
  89393. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89394. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89395. * Default : `true`
  89396. */
  89397. depthSortParticles: boolean;
  89398. /**
  89399. * This function does nothing. It may be overwritten to set all the particle first values.
  89400. * The SPS doesn't call this function, you may have to call it by your own.
  89401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89402. */
  89403. initParticles(): void;
  89404. /**
  89405. * This function does nothing. It may be overwritten to recycle a particle.
  89406. * The SPS doesn't call this function, you may have to call it by your own.
  89407. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89408. * @param particle The particle to recycle
  89409. * @returns the recycled particle
  89410. */
  89411. recycleParticle(particle: SolidParticle): SolidParticle;
  89412. /**
  89413. * Updates a particle : this function should be overwritten by the user.
  89414. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89415. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89416. * @example : just set a particle position or velocity and recycle conditions
  89417. * @param particle The particle to update
  89418. * @returns the updated particle
  89419. */
  89420. updateParticle(particle: SolidParticle): SolidParticle;
  89421. /**
  89422. * Updates a vertex of a particle : it can be overwritten by the user.
  89423. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89424. * @param particle the current particle
  89425. * @param vertex the current index of the current particle
  89426. * @param pt the index of the current vertex in the particle shape
  89427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89428. * @example : just set a vertex particle position
  89429. * @returns the updated vertex
  89430. */
  89431. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89432. /**
  89433. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89434. * This does nothing and may be overwritten by the user.
  89435. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89436. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89437. * @param update the boolean update value actually passed to setParticles()
  89438. */
  89439. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89440. /**
  89441. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89442. * This will be passed three parameters.
  89443. * This does nothing and may be overwritten by the user.
  89444. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89445. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89446. * @param update the boolean update value actually passed to setParticles()
  89447. */
  89448. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89449. }
  89450. }
  89451. declare module BABYLON {
  89452. /**
  89453. * Represents one particle of a solid particle system.
  89454. */
  89455. export class SolidParticle {
  89456. /**
  89457. * particle global index
  89458. */
  89459. idx: number;
  89460. /**
  89461. * The color of the particle
  89462. */
  89463. color: Nullable<Color4>;
  89464. /**
  89465. * The world space position of the particle.
  89466. */
  89467. position: Vector3;
  89468. /**
  89469. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89470. */
  89471. rotation: Vector3;
  89472. /**
  89473. * The world space rotation quaternion of the particle.
  89474. */
  89475. rotationQuaternion: Nullable<Quaternion>;
  89476. /**
  89477. * The scaling of the particle.
  89478. */
  89479. scaling: Vector3;
  89480. /**
  89481. * The uvs of the particle.
  89482. */
  89483. uvs: Vector4;
  89484. /**
  89485. * The current speed of the particle.
  89486. */
  89487. velocity: Vector3;
  89488. /**
  89489. * The pivot point in the particle local space.
  89490. */
  89491. pivot: Vector3;
  89492. /**
  89493. * Must the particle be translated from its pivot point in its local space ?
  89494. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89495. * Default : false
  89496. */
  89497. translateFromPivot: boolean;
  89498. /**
  89499. * Is the particle active or not ?
  89500. */
  89501. alive: boolean;
  89502. /**
  89503. * Is the particle visible or not ?
  89504. */
  89505. isVisible: boolean;
  89506. /**
  89507. * Index of this particle in the global "positions" array (Internal use)
  89508. * @hidden
  89509. */
  89510. _pos: number;
  89511. /**
  89512. * @hidden Index of this particle in the global "indices" array (Internal use)
  89513. */
  89514. _ind: number;
  89515. /**
  89516. * @hidden ModelShape of this particle (Internal use)
  89517. */
  89518. _model: ModelShape;
  89519. /**
  89520. * ModelShape id of this particle
  89521. */
  89522. shapeId: number;
  89523. /**
  89524. * Index of the particle in its shape id (Internal use)
  89525. */
  89526. idxInShape: number;
  89527. /**
  89528. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89529. */
  89530. _modelBoundingInfo: BoundingInfo;
  89531. /**
  89532. * @hidden Particle BoundingInfo object (Internal use)
  89533. */
  89534. _boundingInfo: BoundingInfo;
  89535. /**
  89536. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89537. */
  89538. _sps: SolidParticleSystem;
  89539. /**
  89540. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89541. */
  89542. _stillInvisible: boolean;
  89543. /**
  89544. * @hidden Last computed particle rotation matrix
  89545. */
  89546. _rotationMatrix: number[];
  89547. /**
  89548. * Parent particle Id, if any.
  89549. * Default null.
  89550. */
  89551. parentId: Nullable<number>;
  89552. /**
  89553. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89554. * The possible values are :
  89555. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89556. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89558. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89559. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89560. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89561. * */
  89562. cullingStrategy: number;
  89563. /**
  89564. * @hidden Internal global position in the SPS.
  89565. */
  89566. _globalPosition: Vector3;
  89567. /**
  89568. * Creates a Solid Particle object.
  89569. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89570. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89571. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89572. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89573. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89574. * @param shapeId (integer) is the model shape identifier in the SPS.
  89575. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89576. * @param sps defines the sps it is associated to
  89577. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89578. */
  89579. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89580. /**
  89581. * Legacy support, changed scale to scaling
  89582. */
  89583. /**
  89584. * Legacy support, changed scale to scaling
  89585. */
  89586. scale: Vector3;
  89587. /**
  89588. * Legacy support, changed quaternion to rotationQuaternion
  89589. */
  89590. /**
  89591. * Legacy support, changed quaternion to rotationQuaternion
  89592. */
  89593. quaternion: Nullable<Quaternion>;
  89594. /**
  89595. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89596. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89597. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89598. * @returns true if it intersects
  89599. */
  89600. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89601. /**
  89602. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89603. * A particle is in the frustum if its bounding box intersects the frustum
  89604. * @param frustumPlanes defines the frustum to test
  89605. * @returns true if the particle is in the frustum planes
  89606. */
  89607. isInFrustum(frustumPlanes: Plane[]): boolean;
  89608. /**
  89609. * get the rotation matrix of the particle
  89610. * @hidden
  89611. */
  89612. getRotationMatrix(m: Matrix): void;
  89613. }
  89614. /**
  89615. * Represents the shape of the model used by one particle of a solid particle system.
  89616. * SPS internal tool, don't use it manually.
  89617. */
  89618. export class ModelShape {
  89619. /**
  89620. * The shape id
  89621. * @hidden
  89622. */
  89623. shapeID: number;
  89624. /**
  89625. * flat array of model positions (internal use)
  89626. * @hidden
  89627. */
  89628. _shape: Vector3[];
  89629. /**
  89630. * flat array of model UVs (internal use)
  89631. * @hidden
  89632. */
  89633. _shapeUV: number[];
  89634. /**
  89635. * length of the shape in the model indices array (internal use)
  89636. * @hidden
  89637. */
  89638. _indicesLength: number;
  89639. /**
  89640. * Custom position function (internal use)
  89641. * @hidden
  89642. */
  89643. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89644. /**
  89645. * Custom vertex function (internal use)
  89646. * @hidden
  89647. */
  89648. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89649. /**
  89650. * 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.
  89651. * SPS internal tool, don't use it manually.
  89652. * @hidden
  89653. */
  89654. 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>);
  89655. }
  89656. /**
  89657. * Represents a Depth Sorted Particle in the solid particle system.
  89658. */
  89659. export class DepthSortedParticle {
  89660. /**
  89661. * Index of the particle in the "indices" array
  89662. */
  89663. ind: number;
  89664. /**
  89665. * Length of the particle shape in the "indices" array
  89666. */
  89667. indicesLength: number;
  89668. /**
  89669. * Squared distance from the particle to the camera
  89670. */
  89671. sqDistance: number;
  89672. }
  89673. }
  89674. declare module BABYLON {
  89675. /**
  89676. * @hidden
  89677. */
  89678. export class _MeshCollisionData {
  89679. _checkCollisions: boolean;
  89680. _collisionMask: number;
  89681. _collisionGroup: number;
  89682. _collider: Nullable<Collider>;
  89683. _oldPositionForCollisions: Vector3;
  89684. _diffPositionForCollisions: Vector3;
  89685. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89686. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89687. }
  89688. }
  89689. declare module BABYLON {
  89690. /** @hidden */
  89691. class _FacetDataStorage {
  89692. facetPositions: Vector3[];
  89693. facetNormals: Vector3[];
  89694. facetPartitioning: number[][];
  89695. facetNb: number;
  89696. partitioningSubdivisions: number;
  89697. partitioningBBoxRatio: number;
  89698. facetDataEnabled: boolean;
  89699. facetParameters: any;
  89700. bbSize: Vector3;
  89701. subDiv: {
  89702. max: number;
  89703. X: number;
  89704. Y: number;
  89705. Z: number;
  89706. };
  89707. facetDepthSort: boolean;
  89708. facetDepthSortEnabled: boolean;
  89709. depthSortedIndices: IndicesArray;
  89710. depthSortedFacets: {
  89711. ind: number;
  89712. sqDistance: number;
  89713. }[];
  89714. facetDepthSortFunction: (f1: {
  89715. ind: number;
  89716. sqDistance: number;
  89717. }, f2: {
  89718. ind: number;
  89719. sqDistance: number;
  89720. }) => number;
  89721. facetDepthSortFrom: Vector3;
  89722. facetDepthSortOrigin: Vector3;
  89723. invertedMatrix: Matrix;
  89724. }
  89725. /**
  89726. * @hidden
  89727. **/
  89728. class _InternalAbstractMeshDataInfo {
  89729. _hasVertexAlpha: boolean;
  89730. _useVertexColors: boolean;
  89731. _numBoneInfluencers: number;
  89732. _applyFog: boolean;
  89733. _receiveShadows: boolean;
  89734. _facetData: _FacetDataStorage;
  89735. _visibility: number;
  89736. _skeleton: Nullable<Skeleton>;
  89737. _layerMask: number;
  89738. _computeBonesUsingShaders: boolean;
  89739. _isActive: boolean;
  89740. _onlyForInstances: boolean;
  89741. _isActiveIntermediate: boolean;
  89742. _onlyForInstancesIntermediate: boolean;
  89743. }
  89744. /**
  89745. * Class used to store all common mesh properties
  89746. */
  89747. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89748. /** No occlusion */
  89749. static OCCLUSION_TYPE_NONE: number;
  89750. /** Occlusion set to optimisitic */
  89751. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89752. /** Occlusion set to strict */
  89753. static OCCLUSION_TYPE_STRICT: number;
  89754. /** Use an accurante occlusion algorithm */
  89755. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89756. /** Use a conservative occlusion algorithm */
  89757. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89758. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89759. * Test order :
  89760. * Is the bounding sphere outside the frustum ?
  89761. * If not, are the bounding box vertices outside the frustum ?
  89762. * It not, then the cullable object is in the frustum.
  89763. */
  89764. static readonly CULLINGSTRATEGY_STANDARD: number;
  89765. /** Culling strategy : Bounding Sphere Only.
  89766. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89767. * It's also less accurate than the standard because some not visible objects can still be selected.
  89768. * Test : is the bounding sphere outside the frustum ?
  89769. * If not, then the cullable object is in the frustum.
  89770. */
  89771. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89772. /** Culling strategy : Optimistic Inclusion.
  89773. * This in an inclusion test first, then the standard exclusion test.
  89774. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89775. * 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.
  89776. * Anyway, it's as accurate as the standard strategy.
  89777. * Test :
  89778. * Is the cullable object bounding sphere center in the frustum ?
  89779. * If not, apply the default culling strategy.
  89780. */
  89781. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89782. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89783. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89784. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89785. * 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.
  89786. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89787. * Test :
  89788. * Is the cullable object bounding sphere center in the frustum ?
  89789. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89790. */
  89791. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89792. /**
  89793. * No billboard
  89794. */
  89795. static readonly BILLBOARDMODE_NONE: number;
  89796. /** Billboard on X axis */
  89797. static readonly BILLBOARDMODE_X: number;
  89798. /** Billboard on Y axis */
  89799. static readonly BILLBOARDMODE_Y: number;
  89800. /** Billboard on Z axis */
  89801. static readonly BILLBOARDMODE_Z: number;
  89802. /** Billboard on all axes */
  89803. static readonly BILLBOARDMODE_ALL: number;
  89804. /** Billboard on using position instead of orientation */
  89805. static readonly BILLBOARDMODE_USE_POSITION: number;
  89806. /** @hidden */
  89807. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89808. /**
  89809. * The culling strategy to use to check whether the mesh must be rendered or not.
  89810. * This value can be changed at any time and will be used on the next render mesh selection.
  89811. * The possible values are :
  89812. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89813. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89814. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89815. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89816. * Please read each static variable documentation to get details about the culling process.
  89817. * */
  89818. cullingStrategy: number;
  89819. /**
  89820. * Gets the number of facets in the mesh
  89821. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89822. */
  89823. readonly facetNb: number;
  89824. /**
  89825. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89826. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89827. */
  89828. partitioningSubdivisions: number;
  89829. /**
  89830. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89831. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89833. */
  89834. partitioningBBoxRatio: number;
  89835. /**
  89836. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89837. * Works only for updatable meshes.
  89838. * Doesn't work with multi-materials
  89839. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89840. */
  89841. mustDepthSortFacets: boolean;
  89842. /**
  89843. * The location (Vector3) where the facet depth sort must be computed from.
  89844. * By default, the active camera position.
  89845. * Used only when facet depth sort is enabled
  89846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89847. */
  89848. facetDepthSortFrom: Vector3;
  89849. /**
  89850. * gets a boolean indicating if facetData is enabled
  89851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89852. */
  89853. readonly isFacetDataEnabled: boolean;
  89854. /** @hidden */
  89855. _updateNonUniformScalingState(value: boolean): boolean;
  89856. /**
  89857. * An event triggered when this mesh collides with another one
  89858. */
  89859. onCollideObservable: Observable<AbstractMesh>;
  89860. /** Set a function to call when this mesh collides with another one */
  89861. onCollide: () => void;
  89862. /**
  89863. * An event triggered when the collision's position changes
  89864. */
  89865. onCollisionPositionChangeObservable: Observable<Vector3>;
  89866. /** Set a function to call when the collision's position changes */
  89867. onCollisionPositionChange: () => void;
  89868. /**
  89869. * An event triggered when material is changed
  89870. */
  89871. onMaterialChangedObservable: Observable<AbstractMesh>;
  89872. /**
  89873. * Gets or sets the orientation for POV movement & rotation
  89874. */
  89875. definedFacingForward: boolean;
  89876. /** @hidden */
  89877. _occlusionQuery: Nullable<WebGLQuery>;
  89878. /** @hidden */
  89879. _renderingGroup: Nullable<RenderingGroup>;
  89880. /**
  89881. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89882. */
  89883. /**
  89884. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89885. */
  89886. visibility: number;
  89887. /** Gets or sets the alpha index used to sort transparent meshes
  89888. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89889. */
  89890. alphaIndex: number;
  89891. /**
  89892. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89893. */
  89894. isVisible: boolean;
  89895. /**
  89896. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89897. */
  89898. isPickable: boolean;
  89899. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89900. showSubMeshesBoundingBox: boolean;
  89901. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89902. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89903. */
  89904. isBlocker: boolean;
  89905. /**
  89906. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89907. */
  89908. enablePointerMoveEvents: boolean;
  89909. /**
  89910. * Specifies the rendering group id for this mesh (0 by default)
  89911. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89912. */
  89913. renderingGroupId: number;
  89914. private _material;
  89915. /** Gets or sets current material */
  89916. material: Nullable<Material>;
  89917. /**
  89918. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89919. * @see http://doc.babylonjs.com/babylon101/shadows
  89920. */
  89921. receiveShadows: boolean;
  89922. /** Defines color to use when rendering outline */
  89923. outlineColor: Color3;
  89924. /** Define width to use when rendering outline */
  89925. outlineWidth: number;
  89926. /** Defines color to use when rendering overlay */
  89927. overlayColor: Color3;
  89928. /** Defines alpha to use when rendering overlay */
  89929. overlayAlpha: number;
  89930. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89931. hasVertexAlpha: boolean;
  89932. /** 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) */
  89933. useVertexColors: boolean;
  89934. /**
  89935. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89936. */
  89937. computeBonesUsingShaders: boolean;
  89938. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89939. numBoneInfluencers: number;
  89940. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89941. applyFog: boolean;
  89942. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89943. useOctreeForRenderingSelection: boolean;
  89944. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89945. useOctreeForPicking: boolean;
  89946. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89947. useOctreeForCollisions: boolean;
  89948. /**
  89949. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89950. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89951. */
  89952. layerMask: number;
  89953. /**
  89954. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89955. */
  89956. alwaysSelectAsActiveMesh: boolean;
  89957. /**
  89958. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89959. */
  89960. doNotSyncBoundingInfo: boolean;
  89961. /**
  89962. * Gets or sets the current action manager
  89963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89964. */
  89965. actionManager: Nullable<AbstractActionManager>;
  89966. private _meshCollisionData;
  89967. /**
  89968. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89969. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89970. */
  89971. ellipsoid: Vector3;
  89972. /**
  89973. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89974. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89975. */
  89976. ellipsoidOffset: Vector3;
  89977. /**
  89978. * Gets or sets a collision mask used to mask collisions (default is -1).
  89979. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89980. */
  89981. collisionMask: number;
  89982. /**
  89983. * Gets or sets the current collision group mask (-1 by default).
  89984. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89985. */
  89986. collisionGroup: number;
  89987. /**
  89988. * Defines edge width used when edgesRenderer is enabled
  89989. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89990. */
  89991. edgesWidth: number;
  89992. /**
  89993. * Defines edge color used when edgesRenderer is enabled
  89994. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89995. */
  89996. edgesColor: Color4;
  89997. /** @hidden */
  89998. _edgesRenderer: Nullable<IEdgesRenderer>;
  89999. /** @hidden */
  90000. _masterMesh: Nullable<AbstractMesh>;
  90001. /** @hidden */
  90002. _boundingInfo: Nullable<BoundingInfo>;
  90003. /** @hidden */
  90004. _renderId: number;
  90005. /**
  90006. * Gets or sets the list of subMeshes
  90007. * @see http://doc.babylonjs.com/how_to/multi_materials
  90008. */
  90009. subMeshes: SubMesh[];
  90010. /** @hidden */
  90011. _intersectionsInProgress: AbstractMesh[];
  90012. /** @hidden */
  90013. _unIndexed: boolean;
  90014. /** @hidden */
  90015. _lightSources: Light[];
  90016. /** Gets the list of lights affecting that mesh */
  90017. readonly lightSources: Light[];
  90018. /** @hidden */
  90019. readonly _positions: Nullable<Vector3[]>;
  90020. /** @hidden */
  90021. _waitingData: {
  90022. lods: Nullable<any>;
  90023. actions: Nullable<any>;
  90024. freezeWorldMatrix: Nullable<boolean>;
  90025. };
  90026. /** @hidden */
  90027. _bonesTransformMatrices: Nullable<Float32Array>;
  90028. /** @hidden */
  90029. _transformMatrixTexture: Nullable<RawTexture>;
  90030. /**
  90031. * Gets or sets a skeleton to apply skining transformations
  90032. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  90033. */
  90034. skeleton: Nullable<Skeleton>;
  90035. /**
  90036. * An event triggered when the mesh is rebuilt.
  90037. */
  90038. onRebuildObservable: Observable<AbstractMesh>;
  90039. /**
  90040. * Creates a new AbstractMesh
  90041. * @param name defines the name of the mesh
  90042. * @param scene defines the hosting scene
  90043. */
  90044. constructor(name: string, scene?: Nullable<Scene>);
  90045. /**
  90046. * Returns the string "AbstractMesh"
  90047. * @returns "AbstractMesh"
  90048. */
  90049. getClassName(): string;
  90050. /**
  90051. * Gets a string representation of the current mesh
  90052. * @param fullDetails defines a boolean indicating if full details must be included
  90053. * @returns a string representation of the current mesh
  90054. */
  90055. toString(fullDetails?: boolean): string;
  90056. /**
  90057. * @hidden
  90058. */
  90059. protected _getEffectiveParent(): Nullable<Node>;
  90060. /** @hidden */
  90061. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90062. /** @hidden */
  90063. _rebuild(): void;
  90064. /** @hidden */
  90065. _resyncLightSources(): void;
  90066. /** @hidden */
  90067. _resyncLighSource(light: Light): void;
  90068. /** @hidden */
  90069. _unBindEffect(): void;
  90070. /** @hidden */
  90071. _removeLightSource(light: Light): void;
  90072. private _markSubMeshesAsDirty;
  90073. /** @hidden */
  90074. _markSubMeshesAsLightDirty(): void;
  90075. /** @hidden */
  90076. _markSubMeshesAsAttributesDirty(): void;
  90077. /** @hidden */
  90078. _markSubMeshesAsMiscDirty(): void;
  90079. /**
  90080. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  90081. */
  90082. scaling: Vector3;
  90083. /**
  90084. * Returns true if the mesh is blocked. Implemented by child classes
  90085. */
  90086. readonly isBlocked: boolean;
  90087. /**
  90088. * Returns the mesh itself by default. Implemented by child classes
  90089. * @param camera defines the camera to use to pick the right LOD level
  90090. * @returns the currentAbstractMesh
  90091. */
  90092. getLOD(camera: Camera): Nullable<AbstractMesh>;
  90093. /**
  90094. * Returns 0 by default. Implemented by child classes
  90095. * @returns an integer
  90096. */
  90097. getTotalVertices(): number;
  90098. /**
  90099. * Returns a positive integer : the total number of indices in this mesh geometry.
  90100. * @returns the numner of indices or zero if the mesh has no geometry.
  90101. */
  90102. getTotalIndices(): number;
  90103. /**
  90104. * Returns null by default. Implemented by child classes
  90105. * @returns null
  90106. */
  90107. getIndices(): Nullable<IndicesArray>;
  90108. /**
  90109. * Returns the array of the requested vertex data kind. Implemented by child classes
  90110. * @param kind defines the vertex data kind to use
  90111. * @returns null
  90112. */
  90113. getVerticesData(kind: string): Nullable<FloatArray>;
  90114. /**
  90115. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90116. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90117. * Note that a new underlying VertexBuffer object is created each call.
  90118. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90119. * @param kind defines vertex data kind:
  90120. * * VertexBuffer.PositionKind
  90121. * * VertexBuffer.UVKind
  90122. * * VertexBuffer.UV2Kind
  90123. * * VertexBuffer.UV3Kind
  90124. * * VertexBuffer.UV4Kind
  90125. * * VertexBuffer.UV5Kind
  90126. * * VertexBuffer.UV6Kind
  90127. * * VertexBuffer.ColorKind
  90128. * * VertexBuffer.MatricesIndicesKind
  90129. * * VertexBuffer.MatricesIndicesExtraKind
  90130. * * VertexBuffer.MatricesWeightsKind
  90131. * * VertexBuffer.MatricesWeightsExtraKind
  90132. * @param data defines the data source
  90133. * @param updatable defines if the data must be flagged as updatable (or static)
  90134. * @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
  90135. * @returns the current mesh
  90136. */
  90137. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90138. /**
  90139. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90140. * If the mesh has no geometry, it is simply returned as it is.
  90141. * @param kind defines vertex data kind:
  90142. * * VertexBuffer.PositionKind
  90143. * * VertexBuffer.UVKind
  90144. * * VertexBuffer.UV2Kind
  90145. * * VertexBuffer.UV3Kind
  90146. * * VertexBuffer.UV4Kind
  90147. * * VertexBuffer.UV5Kind
  90148. * * VertexBuffer.UV6Kind
  90149. * * VertexBuffer.ColorKind
  90150. * * VertexBuffer.MatricesIndicesKind
  90151. * * VertexBuffer.MatricesIndicesExtraKind
  90152. * * VertexBuffer.MatricesWeightsKind
  90153. * * VertexBuffer.MatricesWeightsExtraKind
  90154. * @param data defines the data source
  90155. * @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
  90156. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  90157. * @returns the current mesh
  90158. */
  90159. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90160. /**
  90161. * Sets the mesh indices,
  90162. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90163. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  90164. * @param totalVertices Defines the total number of vertices
  90165. * @returns the current mesh
  90166. */
  90167. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  90168. /**
  90169. * Gets a boolean indicating if specific vertex data is present
  90170. * @param kind defines the vertex data kind to use
  90171. * @returns true is data kind is present
  90172. */
  90173. isVerticesDataPresent(kind: string): boolean;
  90174. /**
  90175. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  90176. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  90177. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  90178. * @returns a BoundingInfo
  90179. */
  90180. getBoundingInfo(): BoundingInfo;
  90181. /**
  90182. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  90183. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  90184. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  90185. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  90186. * @returns the current mesh
  90187. */
  90188. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  90189. /**
  90190. * Overwrite the current bounding info
  90191. * @param boundingInfo defines the new bounding info
  90192. * @returns the current mesh
  90193. */
  90194. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  90195. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  90196. readonly useBones: boolean;
  90197. /** @hidden */
  90198. _preActivate(): void;
  90199. /** @hidden */
  90200. _preActivateForIntermediateRendering(renderId: number): void;
  90201. /** @hidden */
  90202. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90203. /** @hidden */
  90204. _postActivate(): void;
  90205. /** @hidden */
  90206. _freeze(): void;
  90207. /** @hidden */
  90208. _unFreeze(): void;
  90209. /**
  90210. * Gets the current world matrix
  90211. * @returns a Matrix
  90212. */
  90213. getWorldMatrix(): Matrix;
  90214. /** @hidden */
  90215. _getWorldMatrixDeterminant(): number;
  90216. /**
  90217. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  90218. */
  90219. readonly isAnInstance: boolean;
  90220. /**
  90221. * Perform relative position change from the point of view of behind the front of the mesh.
  90222. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90223. * Supports definition of mesh facing forward or backward
  90224. * @param amountRight defines the distance on the right axis
  90225. * @param amountUp defines the distance on the up axis
  90226. * @param amountForward defines the distance on the forward axis
  90227. * @returns the current mesh
  90228. */
  90229. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  90230. /**
  90231. * Calculate relative position change from the point of view of behind the front of the mesh.
  90232. * This is performed taking into account the meshes current rotation, so you do not have to care.
  90233. * Supports definition of mesh facing forward or backward
  90234. * @param amountRight defines the distance on the right axis
  90235. * @param amountUp defines the distance on the up axis
  90236. * @param amountForward defines the distance on the forward axis
  90237. * @returns the new displacement vector
  90238. */
  90239. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  90240. /**
  90241. * Perform relative rotation change from the point of view of behind the front of the mesh.
  90242. * Supports definition of mesh facing forward or backward
  90243. * @param flipBack defines the flip
  90244. * @param twirlClockwise defines the twirl
  90245. * @param tiltRight defines the tilt
  90246. * @returns the current mesh
  90247. */
  90248. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  90249. /**
  90250. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  90251. * Supports definition of mesh facing forward or backward.
  90252. * @param flipBack defines the flip
  90253. * @param twirlClockwise defines the twirl
  90254. * @param tiltRight defines the tilt
  90255. * @returns the new rotation vector
  90256. */
  90257. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  90258. /**
  90259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90260. * This means the mesh underlying bounding box and sphere are recomputed.
  90261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90262. * @returns the current mesh
  90263. */
  90264. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  90265. /** @hidden */
  90266. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  90267. /** @hidden */
  90268. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  90269. /** @hidden */
  90270. _updateBoundingInfo(): AbstractMesh;
  90271. /** @hidden */
  90272. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  90273. /** @hidden */
  90274. protected _afterComputeWorldMatrix(): void;
  90275. /** @hidden */
  90276. readonly _effectiveMesh: AbstractMesh;
  90277. /**
  90278. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90279. * A mesh is in the frustum if its bounding box intersects the frustum
  90280. * @param frustumPlanes defines the frustum to test
  90281. * @returns true if the mesh is in the frustum planes
  90282. */
  90283. isInFrustum(frustumPlanes: Plane[]): boolean;
  90284. /**
  90285. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  90286. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  90287. * @param frustumPlanes defines the frustum to test
  90288. * @returns true if the mesh is completely in the frustum planes
  90289. */
  90290. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  90291. /**
  90292. * True if the mesh intersects another mesh or a SolidParticle object
  90293. * @param mesh defines a target mesh or SolidParticle to test
  90294. * @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)
  90295. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  90296. * @returns true if there is an intersection
  90297. */
  90298. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  90299. /**
  90300. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  90301. * @param point defines the point to test
  90302. * @returns true if there is an intersection
  90303. */
  90304. intersectsPoint(point: Vector3): boolean;
  90305. /**
  90306. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  90307. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90308. */
  90309. checkCollisions: boolean;
  90310. /**
  90311. * Gets Collider object used to compute collisions (not physics)
  90312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90313. */
  90314. readonly collider: Nullable<Collider>;
  90315. /**
  90316. * Move the mesh using collision engine
  90317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90318. * @param displacement defines the requested displacement vector
  90319. * @returns the current mesh
  90320. */
  90321. moveWithCollisions(displacement: Vector3): AbstractMesh;
  90322. private _onCollisionPositionChange;
  90323. /** @hidden */
  90324. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90325. /** @hidden */
  90326. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90327. /** @hidden */
  90328. _checkCollision(collider: Collider): AbstractMesh;
  90329. /** @hidden */
  90330. _generatePointsArray(): boolean;
  90331. /**
  90332. * Checks if the passed Ray intersects with the mesh
  90333. * @param ray defines the ray to use
  90334. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90335. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90336. * @returns the picking info
  90337. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90338. */
  90339. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90340. /**
  90341. * Clones the current mesh
  90342. * @param name defines the mesh name
  90343. * @param newParent defines the new mesh parent
  90344. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90345. * @returns the new mesh
  90346. */
  90347. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90348. /**
  90349. * Disposes all the submeshes of the current meshnp
  90350. * @returns the current mesh
  90351. */
  90352. releaseSubMeshes(): AbstractMesh;
  90353. /**
  90354. * Releases resources associated with this abstract mesh.
  90355. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90356. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90357. */
  90358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90359. /**
  90360. * Adds the passed mesh as a child to the current mesh
  90361. * @param mesh defines the child mesh
  90362. * @returns the current mesh
  90363. */
  90364. addChild(mesh: AbstractMesh): AbstractMesh;
  90365. /**
  90366. * Removes the passed mesh from the current mesh children list
  90367. * @param mesh defines the child mesh
  90368. * @returns the current mesh
  90369. */
  90370. removeChild(mesh: AbstractMesh): AbstractMesh;
  90371. /** @hidden */
  90372. private _initFacetData;
  90373. /**
  90374. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90375. * This method can be called within the render loop.
  90376. * 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
  90377. * @returns the current mesh
  90378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90379. */
  90380. updateFacetData(): AbstractMesh;
  90381. /**
  90382. * Returns the facetLocalNormals array.
  90383. * The normals are expressed in the mesh local spac
  90384. * @returns an array of Vector3
  90385. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90386. */
  90387. getFacetLocalNormals(): Vector3[];
  90388. /**
  90389. * Returns the facetLocalPositions array.
  90390. * The facet positions are expressed in the mesh local space
  90391. * @returns an array of Vector3
  90392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90393. */
  90394. getFacetLocalPositions(): Vector3[];
  90395. /**
  90396. * Returns the facetLocalPartioning array
  90397. * @returns an array of array of numbers
  90398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90399. */
  90400. getFacetLocalPartitioning(): number[][];
  90401. /**
  90402. * Returns the i-th facet position in the world system.
  90403. * This method allocates a new Vector3 per call
  90404. * @param i defines the facet index
  90405. * @returns a new Vector3
  90406. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90407. */
  90408. getFacetPosition(i: number): Vector3;
  90409. /**
  90410. * Sets the reference Vector3 with the i-th facet position in the world system
  90411. * @param i defines the facet index
  90412. * @param ref defines the target vector
  90413. * @returns the current mesh
  90414. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90415. */
  90416. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90417. /**
  90418. * Returns the i-th facet normal in the world system.
  90419. * This method allocates a new Vector3 per call
  90420. * @param i defines the facet index
  90421. * @returns a new Vector3
  90422. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90423. */
  90424. getFacetNormal(i: number): Vector3;
  90425. /**
  90426. * Sets the reference Vector3 with the i-th facet normal in the world system
  90427. * @param i defines the facet index
  90428. * @param ref defines the target vector
  90429. * @returns the current mesh
  90430. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90431. */
  90432. getFacetNormalToRef(i: number, ref: Vector3): this;
  90433. /**
  90434. * 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)
  90435. * @param x defines x coordinate
  90436. * @param y defines y coordinate
  90437. * @param z defines z coordinate
  90438. * @returns the array of facet indexes
  90439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90440. */
  90441. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90442. /**
  90443. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90444. * @param projected sets as the (x,y,z) world projection on the facet
  90445. * @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
  90446. * @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
  90447. * @param x defines x coordinate
  90448. * @param y defines y coordinate
  90449. * @param z defines z coordinate
  90450. * @returns the face index if found (or null instead)
  90451. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90452. */
  90453. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90454. /**
  90455. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90456. * @param projected sets as the (x,y,z) local projection on the facet
  90457. * @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
  90458. * @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
  90459. * @param x defines x coordinate
  90460. * @param y defines y coordinate
  90461. * @param z defines z coordinate
  90462. * @returns the face index if found (or null instead)
  90463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90464. */
  90465. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90466. /**
  90467. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90468. * @returns the parameters
  90469. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90470. */
  90471. getFacetDataParameters(): any;
  90472. /**
  90473. * Disables the feature FacetData and frees the related memory
  90474. * @returns the current mesh
  90475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90476. */
  90477. disableFacetData(): AbstractMesh;
  90478. /**
  90479. * Updates the AbstractMesh indices array
  90480. * @param indices defines the data source
  90481. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90482. * @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)
  90483. * @returns the current mesh
  90484. */
  90485. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90486. /**
  90487. * Creates new normals data for the mesh
  90488. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90489. * @returns the current mesh
  90490. */
  90491. createNormals(updatable: boolean): AbstractMesh;
  90492. /**
  90493. * Align the mesh with a normal
  90494. * @param normal defines the normal to use
  90495. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90496. * @returns the current mesh
  90497. */
  90498. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90499. /** @hidden */
  90500. _checkOcclusionQuery(): boolean;
  90501. /**
  90502. * Disables the mesh edge rendering mode
  90503. * @returns the currentAbstractMesh
  90504. */
  90505. disableEdgesRendering(): AbstractMesh;
  90506. /**
  90507. * Enables the edge rendering mode on the mesh.
  90508. * This mode makes the mesh edges visible
  90509. * @param epsilon defines the maximal distance between two angles to detect a face
  90510. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90511. * @returns the currentAbstractMesh
  90512. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90513. */
  90514. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90515. }
  90516. }
  90517. declare module BABYLON {
  90518. /**
  90519. * Interface used to define ActionEvent
  90520. */
  90521. export interface IActionEvent {
  90522. /** The mesh or sprite that triggered the action */
  90523. source: any;
  90524. /** The X mouse cursor position at the time of the event */
  90525. pointerX: number;
  90526. /** The Y mouse cursor position at the time of the event */
  90527. pointerY: number;
  90528. /** The mesh that is currently pointed at (can be null) */
  90529. meshUnderPointer: Nullable<AbstractMesh>;
  90530. /** the original (browser) event that triggered the ActionEvent */
  90531. sourceEvent?: any;
  90532. /** additional data for the event */
  90533. additionalData?: any;
  90534. }
  90535. /**
  90536. * ActionEvent is the event being sent when an action is triggered.
  90537. */
  90538. export class ActionEvent implements IActionEvent {
  90539. /** The mesh or sprite that triggered the action */
  90540. source: any;
  90541. /** The X mouse cursor position at the time of the event */
  90542. pointerX: number;
  90543. /** The Y mouse cursor position at the time of the event */
  90544. pointerY: number;
  90545. /** The mesh that is currently pointed at (can be null) */
  90546. meshUnderPointer: Nullable<AbstractMesh>;
  90547. /** the original (browser) event that triggered the ActionEvent */
  90548. sourceEvent?: any;
  90549. /** additional data for the event */
  90550. additionalData?: any;
  90551. /**
  90552. * Creates a new ActionEvent
  90553. * @param source The mesh or sprite that triggered the action
  90554. * @param pointerX The X mouse cursor position at the time of the event
  90555. * @param pointerY The Y mouse cursor position at the time of the event
  90556. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90557. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90558. * @param additionalData additional data for the event
  90559. */
  90560. constructor(
  90561. /** The mesh or sprite that triggered the action */
  90562. source: any,
  90563. /** The X mouse cursor position at the time of the event */
  90564. pointerX: number,
  90565. /** The Y mouse cursor position at the time of the event */
  90566. pointerY: number,
  90567. /** The mesh that is currently pointed at (can be null) */
  90568. meshUnderPointer: Nullable<AbstractMesh>,
  90569. /** the original (browser) event that triggered the ActionEvent */
  90570. sourceEvent?: any,
  90571. /** additional data for the event */
  90572. additionalData?: any);
  90573. /**
  90574. * Helper function to auto-create an ActionEvent from a source mesh.
  90575. * @param source The source mesh that triggered the event
  90576. * @param evt The original (browser) event
  90577. * @param additionalData additional data for the event
  90578. * @returns the new ActionEvent
  90579. */
  90580. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90581. /**
  90582. * Helper function to auto-create an ActionEvent from a source sprite
  90583. * @param source The source sprite that triggered the event
  90584. * @param scene Scene associated with the sprite
  90585. * @param evt The original (browser) event
  90586. * @param additionalData additional data for the event
  90587. * @returns the new ActionEvent
  90588. */
  90589. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90590. /**
  90591. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90592. * @param scene the scene where the event occurred
  90593. * @param evt The original (browser) event
  90594. * @returns the new ActionEvent
  90595. */
  90596. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90597. /**
  90598. * Helper function to auto-create an ActionEvent from a primitive
  90599. * @param prim defines the target primitive
  90600. * @param pointerPos defines the pointer position
  90601. * @param evt The original (browser) event
  90602. * @param additionalData additional data for the event
  90603. * @returns the new ActionEvent
  90604. */
  90605. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90606. }
  90607. }
  90608. declare module BABYLON {
  90609. /**
  90610. * Abstract class used to decouple action Manager from scene and meshes.
  90611. * Do not instantiate.
  90612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90613. */
  90614. export abstract class AbstractActionManager implements IDisposable {
  90615. /** Gets the list of active triggers */
  90616. static Triggers: {
  90617. [key: string]: number;
  90618. };
  90619. /** Gets the cursor to use when hovering items */
  90620. hoverCursor: string;
  90621. /** Gets the list of actions */
  90622. actions: IAction[];
  90623. /**
  90624. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90625. */
  90626. isRecursive: boolean;
  90627. /**
  90628. * Releases all associated resources
  90629. */
  90630. abstract dispose(): void;
  90631. /**
  90632. * Does this action manager has pointer triggers
  90633. */
  90634. abstract readonly hasPointerTriggers: boolean;
  90635. /**
  90636. * Does this action manager has pick triggers
  90637. */
  90638. abstract readonly hasPickTriggers: boolean;
  90639. /**
  90640. * Process a specific trigger
  90641. * @param trigger defines the trigger to process
  90642. * @param evt defines the event details to be processed
  90643. */
  90644. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90645. /**
  90646. * Does this action manager handles actions of any of the given triggers
  90647. * @param triggers defines the triggers to be tested
  90648. * @return a boolean indicating whether one (or more) of the triggers is handled
  90649. */
  90650. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90651. /**
  90652. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90653. * speed.
  90654. * @param triggerA defines the trigger to be tested
  90655. * @param triggerB defines the trigger to be tested
  90656. * @return a boolean indicating whether one (or more) of the triggers is handled
  90657. */
  90658. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90659. /**
  90660. * Does this action manager handles actions of a given trigger
  90661. * @param trigger defines the trigger to be tested
  90662. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90663. * @return whether the trigger is handled
  90664. */
  90665. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90666. /**
  90667. * Serialize this manager to a JSON object
  90668. * @param name defines the property name to store this manager
  90669. * @returns a JSON representation of this manager
  90670. */
  90671. abstract serialize(name: string): any;
  90672. /**
  90673. * Registers an action to this action manager
  90674. * @param action defines the action to be registered
  90675. * @return the action amended (prepared) after registration
  90676. */
  90677. abstract registerAction(action: IAction): Nullable<IAction>;
  90678. /**
  90679. * Unregisters an action to this action manager
  90680. * @param action defines the action to be unregistered
  90681. * @return a boolean indicating whether the action has been unregistered
  90682. */
  90683. abstract unregisterAction(action: IAction): Boolean;
  90684. /**
  90685. * Does exist one action manager with at least one trigger
  90686. **/
  90687. static readonly HasTriggers: boolean;
  90688. /**
  90689. * Does exist one action manager with at least one pick trigger
  90690. **/
  90691. static readonly HasPickTriggers: boolean;
  90692. /**
  90693. * Does exist one action manager that handles actions of a given trigger
  90694. * @param trigger defines the trigger to be tested
  90695. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90696. **/
  90697. static HasSpecificTrigger(trigger: number): boolean;
  90698. }
  90699. }
  90700. declare module BABYLON {
  90701. /**
  90702. * Defines how a node can be built from a string name.
  90703. */
  90704. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90705. /**
  90706. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90707. */
  90708. export class Node implements IBehaviorAware<Node> {
  90709. /** @hidden */
  90710. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90711. private static _NodeConstructors;
  90712. /**
  90713. * Add a new node constructor
  90714. * @param type defines the type name of the node to construct
  90715. * @param constructorFunc defines the constructor function
  90716. */
  90717. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90718. /**
  90719. * Returns a node constructor based on type name
  90720. * @param type defines the type name
  90721. * @param name defines the new node name
  90722. * @param scene defines the hosting scene
  90723. * @param options defines optional options to transmit to constructors
  90724. * @returns the new constructor or null
  90725. */
  90726. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90727. /**
  90728. * Gets or sets the name of the node
  90729. */
  90730. name: string;
  90731. /**
  90732. * Gets or sets the id of the node
  90733. */
  90734. id: string;
  90735. /**
  90736. * Gets or sets the unique id of the node
  90737. */
  90738. uniqueId: number;
  90739. /**
  90740. * Gets or sets a string used to store user defined state for the node
  90741. */
  90742. state: string;
  90743. /**
  90744. * Gets or sets an object used to store user defined information for the node
  90745. */
  90746. metadata: any;
  90747. /**
  90748. * For internal use only. Please do not use.
  90749. */
  90750. reservedDataStore: any;
  90751. /**
  90752. * List of inspectable custom properties (used by the Inspector)
  90753. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90754. */
  90755. inspectableCustomProperties: IInspectable[];
  90756. /**
  90757. * Gets or sets a boolean used to define if the node must be serialized
  90758. */
  90759. doNotSerialize: boolean;
  90760. /** @hidden */
  90761. _isDisposed: boolean;
  90762. /**
  90763. * Gets a list of Animations associated with the node
  90764. */
  90765. animations: Animation[];
  90766. protected _ranges: {
  90767. [name: string]: Nullable<AnimationRange>;
  90768. };
  90769. /**
  90770. * Callback raised when the node is ready to be used
  90771. */
  90772. onReady: Nullable<(node: Node) => void>;
  90773. private _isEnabled;
  90774. private _isParentEnabled;
  90775. private _isReady;
  90776. /** @hidden */
  90777. _currentRenderId: number;
  90778. private _parentUpdateId;
  90779. /** @hidden */
  90780. _childUpdateId: number;
  90781. /** @hidden */
  90782. _waitingParentId: Nullable<string>;
  90783. /** @hidden */
  90784. _scene: Scene;
  90785. /** @hidden */
  90786. _cache: any;
  90787. private _parentNode;
  90788. private _children;
  90789. /** @hidden */
  90790. _worldMatrix: Matrix;
  90791. /** @hidden */
  90792. _worldMatrixDeterminant: number;
  90793. /** @hidden */
  90794. _worldMatrixDeterminantIsDirty: boolean;
  90795. /** @hidden */
  90796. private _sceneRootNodesIndex;
  90797. /**
  90798. * Gets a boolean indicating if the node has been disposed
  90799. * @returns true if the node was disposed
  90800. */
  90801. isDisposed(): boolean;
  90802. /**
  90803. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90804. * @see https://doc.babylonjs.com/how_to/parenting
  90805. */
  90806. parent: Nullable<Node>;
  90807. private addToSceneRootNodes;
  90808. private removeFromSceneRootNodes;
  90809. private _animationPropertiesOverride;
  90810. /**
  90811. * Gets or sets the animation properties override
  90812. */
  90813. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90814. /**
  90815. * Gets a string idenfifying the name of the class
  90816. * @returns "Node" string
  90817. */
  90818. getClassName(): string;
  90819. /** @hidden */
  90820. readonly _isNode: boolean;
  90821. /**
  90822. * An event triggered when the mesh is disposed
  90823. */
  90824. onDisposeObservable: Observable<Node>;
  90825. private _onDisposeObserver;
  90826. /**
  90827. * Sets a callback that will be raised when the node will be disposed
  90828. */
  90829. onDispose: () => void;
  90830. /**
  90831. * Creates a new Node
  90832. * @param name the name and id to be given to this node
  90833. * @param scene the scene this node will be added to
  90834. * @param addToRootNodes the node will be added to scene.rootNodes
  90835. */
  90836. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90837. /**
  90838. * Gets the scene of the node
  90839. * @returns a scene
  90840. */
  90841. getScene(): Scene;
  90842. /**
  90843. * Gets the engine of the node
  90844. * @returns a Engine
  90845. */
  90846. getEngine(): Engine;
  90847. private _behaviors;
  90848. /**
  90849. * Attach a behavior to the node
  90850. * @see http://doc.babylonjs.com/features/behaviour
  90851. * @param behavior defines the behavior to attach
  90852. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90853. * @returns the current Node
  90854. */
  90855. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90856. /**
  90857. * Remove an attached behavior
  90858. * @see http://doc.babylonjs.com/features/behaviour
  90859. * @param behavior defines the behavior to attach
  90860. * @returns the current Node
  90861. */
  90862. removeBehavior(behavior: Behavior<Node>): Node;
  90863. /**
  90864. * Gets the list of attached behaviors
  90865. * @see http://doc.babylonjs.com/features/behaviour
  90866. */
  90867. readonly behaviors: Behavior<Node>[];
  90868. /**
  90869. * Gets an attached behavior by name
  90870. * @param name defines the name of the behavior to look for
  90871. * @see http://doc.babylonjs.com/features/behaviour
  90872. * @returns null if behavior was not found else the requested behavior
  90873. */
  90874. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90875. /**
  90876. * Returns the latest update of the World matrix
  90877. * @returns a Matrix
  90878. */
  90879. getWorldMatrix(): Matrix;
  90880. /** @hidden */
  90881. _getWorldMatrixDeterminant(): number;
  90882. /**
  90883. * Returns directly the latest state of the mesh World matrix.
  90884. * A Matrix is returned.
  90885. */
  90886. readonly worldMatrixFromCache: Matrix;
  90887. /** @hidden */
  90888. _initCache(): void;
  90889. /** @hidden */
  90890. updateCache(force?: boolean): void;
  90891. /** @hidden */
  90892. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90893. /** @hidden */
  90894. _updateCache(ignoreParentClass?: boolean): void;
  90895. /** @hidden */
  90896. _isSynchronized(): boolean;
  90897. /** @hidden */
  90898. _markSyncedWithParent(): void;
  90899. /** @hidden */
  90900. isSynchronizedWithParent(): boolean;
  90901. /** @hidden */
  90902. isSynchronized(): boolean;
  90903. /**
  90904. * Is this node ready to be used/rendered
  90905. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90906. * @return true if the node is ready
  90907. */
  90908. isReady(completeCheck?: boolean): boolean;
  90909. /**
  90910. * Is this node enabled?
  90911. * 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
  90912. * @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
  90913. * @return whether this node (and its parent) is enabled
  90914. */
  90915. isEnabled(checkAncestors?: boolean): boolean;
  90916. /** @hidden */
  90917. protected _syncParentEnabledState(): void;
  90918. /**
  90919. * Set the enabled state of this node
  90920. * @param value defines the new enabled state
  90921. */
  90922. setEnabled(value: boolean): void;
  90923. /**
  90924. * Is this node a descendant of the given node?
  90925. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90926. * @param ancestor defines the parent node to inspect
  90927. * @returns a boolean indicating if this node is a descendant of the given node
  90928. */
  90929. isDescendantOf(ancestor: Node): boolean;
  90930. /** @hidden */
  90931. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90932. /**
  90933. * Will return all nodes that have this node as ascendant
  90934. * @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
  90935. * @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
  90936. * @return all children nodes of all types
  90937. */
  90938. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90939. /**
  90940. * Get all child-meshes of this node
  90941. * @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)
  90942. * @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
  90943. * @returns an array of AbstractMesh
  90944. */
  90945. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90946. /**
  90947. * Get all direct children of this node
  90948. * @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
  90949. * @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)
  90950. * @returns an array of Node
  90951. */
  90952. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90953. /** @hidden */
  90954. _setReady(state: boolean): void;
  90955. /**
  90956. * Get an animation by name
  90957. * @param name defines the name of the animation to look for
  90958. * @returns null if not found else the requested animation
  90959. */
  90960. getAnimationByName(name: string): Nullable<Animation>;
  90961. /**
  90962. * Creates an animation range for this node
  90963. * @param name defines the name of the range
  90964. * @param from defines the starting key
  90965. * @param to defines the end key
  90966. */
  90967. createAnimationRange(name: string, from: number, to: number): void;
  90968. /**
  90969. * Delete a specific animation range
  90970. * @param name defines the name of the range to delete
  90971. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90972. */
  90973. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90974. /**
  90975. * Get an animation range by name
  90976. * @param name defines the name of the animation range to look for
  90977. * @returns null if not found else the requested animation range
  90978. */
  90979. getAnimationRange(name: string): Nullable<AnimationRange>;
  90980. /**
  90981. * Gets the list of all animation ranges defined on this node
  90982. * @returns an array
  90983. */
  90984. getAnimationRanges(): Nullable<AnimationRange>[];
  90985. /**
  90986. * Will start the animation sequence
  90987. * @param name defines the range frames for animation sequence
  90988. * @param loop defines if the animation should loop (false by default)
  90989. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90990. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90991. * @returns the object created for this animation. If range does not exist, it will return null
  90992. */
  90993. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90994. /**
  90995. * Serialize animation ranges into a JSON compatible object
  90996. * @returns serialization object
  90997. */
  90998. serializeAnimationRanges(): any;
  90999. /**
  91000. * Computes the world matrix of the node
  91001. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91002. * @returns the world matrix
  91003. */
  91004. computeWorldMatrix(force?: boolean): Matrix;
  91005. /**
  91006. * Releases resources associated with this node.
  91007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91009. */
  91010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91011. /**
  91012. * Parse animation range data from a serialization object and store them into a given node
  91013. * @param node defines where to store the animation ranges
  91014. * @param parsedNode defines the serialization object to read data from
  91015. * @param scene defines the hosting scene
  91016. */
  91017. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  91018. /**
  91019. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  91020. * @param includeDescendants Include bounding info from descendants as well (true by default)
  91021. * @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
  91022. * @returns the new bounding vectors
  91023. */
  91024. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  91025. min: Vector3;
  91026. max: Vector3;
  91027. };
  91028. }
  91029. }
  91030. declare module BABYLON {
  91031. /**
  91032. * @hidden
  91033. */
  91034. export class _IAnimationState {
  91035. key: number;
  91036. repeatCount: number;
  91037. workValue?: any;
  91038. loopMode?: number;
  91039. offsetValue?: any;
  91040. highLimitValue?: any;
  91041. }
  91042. /**
  91043. * Class used to store any kind of animation
  91044. */
  91045. export class Animation {
  91046. /**Name of the animation */
  91047. name: string;
  91048. /**Property to animate */
  91049. targetProperty: string;
  91050. /**The frames per second of the animation */
  91051. framePerSecond: number;
  91052. /**The data type of the animation */
  91053. dataType: number;
  91054. /**The loop mode of the animation */
  91055. loopMode?: number | undefined;
  91056. /**Specifies if blending should be enabled */
  91057. enableBlending?: boolean | undefined;
  91058. /**
  91059. * Use matrix interpolation instead of using direct key value when animating matrices
  91060. */
  91061. static AllowMatricesInterpolation: boolean;
  91062. /**
  91063. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  91064. */
  91065. static AllowMatrixDecomposeForInterpolation: boolean;
  91066. /**
  91067. * Stores the key frames of the animation
  91068. */
  91069. private _keys;
  91070. /**
  91071. * Stores the easing function of the animation
  91072. */
  91073. private _easingFunction;
  91074. /**
  91075. * @hidden Internal use only
  91076. */
  91077. _runtimeAnimations: RuntimeAnimation[];
  91078. /**
  91079. * The set of event that will be linked to this animation
  91080. */
  91081. private _events;
  91082. /**
  91083. * Stores an array of target property paths
  91084. */
  91085. targetPropertyPath: string[];
  91086. /**
  91087. * Stores the blending speed of the animation
  91088. */
  91089. blendingSpeed: number;
  91090. /**
  91091. * Stores the animation ranges for the animation
  91092. */
  91093. private _ranges;
  91094. /**
  91095. * @hidden Internal use
  91096. */
  91097. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  91098. /**
  91099. * Sets up an animation
  91100. * @param property The property to animate
  91101. * @param animationType The animation type to apply
  91102. * @param framePerSecond The frames per second of the animation
  91103. * @param easingFunction The easing function used in the animation
  91104. * @returns The created animation
  91105. */
  91106. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  91107. /**
  91108. * Create and start an animation on a node
  91109. * @param name defines the name of the global animation that will be run on all nodes
  91110. * @param node defines the root node where the animation will take place
  91111. * @param targetProperty defines property to animate
  91112. * @param framePerSecond defines the number of frame per second yo use
  91113. * @param totalFrame defines the number of frames in total
  91114. * @param from defines the initial value
  91115. * @param to defines the final value
  91116. * @param loopMode defines which loop mode you want to use (off by default)
  91117. * @param easingFunction defines the easing function to use (linear by default)
  91118. * @param onAnimationEnd defines the callback to call when animation end
  91119. * @returns the animatable created for this animation
  91120. */
  91121. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91122. /**
  91123. * Create and start an animation on a node and its descendants
  91124. * @param name defines the name of the global animation that will be run on all nodes
  91125. * @param node defines the root node where the animation will take place
  91126. * @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
  91127. * @param targetProperty defines property to animate
  91128. * @param framePerSecond defines the number of frame per second to use
  91129. * @param totalFrame defines the number of frames in total
  91130. * @param from defines the initial value
  91131. * @param to defines the final value
  91132. * @param loopMode defines which loop mode you want to use (off by default)
  91133. * @param easingFunction defines the easing function to use (linear by default)
  91134. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  91135. * @returns the list of animatables created for all nodes
  91136. * @example https://www.babylonjs-playground.com/#MH0VLI
  91137. */
  91138. 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[]>;
  91139. /**
  91140. * Creates a new animation, merges it with the existing animations and starts it
  91141. * @param name Name of the animation
  91142. * @param node Node which contains the scene that begins the animations
  91143. * @param targetProperty Specifies which property to animate
  91144. * @param framePerSecond The frames per second of the animation
  91145. * @param totalFrame The total number of frames
  91146. * @param from The frame at the beginning of the animation
  91147. * @param to The frame at the end of the animation
  91148. * @param loopMode Specifies the loop mode of the animation
  91149. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  91150. * @param onAnimationEnd Callback to run once the animation is complete
  91151. * @returns Nullable animation
  91152. */
  91153. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  91154. /**
  91155. * Transition property of an host to the target Value
  91156. * @param property The property to transition
  91157. * @param targetValue The target Value of the property
  91158. * @param host The object where the property to animate belongs
  91159. * @param scene Scene used to run the animation
  91160. * @param frameRate Framerate (in frame/s) to use
  91161. * @param transition The transition type we want to use
  91162. * @param duration The duration of the animation, in milliseconds
  91163. * @param onAnimationEnd Callback trigger at the end of the animation
  91164. * @returns Nullable animation
  91165. */
  91166. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  91167. /**
  91168. * Return the array of runtime animations currently using this animation
  91169. */
  91170. readonly runtimeAnimations: RuntimeAnimation[];
  91171. /**
  91172. * Specifies if any of the runtime animations are currently running
  91173. */
  91174. readonly hasRunningRuntimeAnimations: boolean;
  91175. /**
  91176. * Initializes the animation
  91177. * @param name Name of the animation
  91178. * @param targetProperty Property to animate
  91179. * @param framePerSecond The frames per second of the animation
  91180. * @param dataType The data type of the animation
  91181. * @param loopMode The loop mode of the animation
  91182. * @param enableBlending Specifies if blending should be enabled
  91183. */
  91184. constructor(
  91185. /**Name of the animation */
  91186. name: string,
  91187. /**Property to animate */
  91188. targetProperty: string,
  91189. /**The frames per second of the animation */
  91190. framePerSecond: number,
  91191. /**The data type of the animation */
  91192. dataType: number,
  91193. /**The loop mode of the animation */
  91194. loopMode?: number | undefined,
  91195. /**Specifies if blending should be enabled */
  91196. enableBlending?: boolean | undefined);
  91197. /**
  91198. * Converts the animation to a string
  91199. * @param fullDetails support for multiple levels of logging within scene loading
  91200. * @returns String form of the animation
  91201. */
  91202. toString(fullDetails?: boolean): string;
  91203. /**
  91204. * Add an event to this animation
  91205. * @param event Event to add
  91206. */
  91207. addEvent(event: AnimationEvent): void;
  91208. /**
  91209. * Remove all events found at the given frame
  91210. * @param frame The frame to remove events from
  91211. */
  91212. removeEvents(frame: number): void;
  91213. /**
  91214. * Retrieves all the events from the animation
  91215. * @returns Events from the animation
  91216. */
  91217. getEvents(): AnimationEvent[];
  91218. /**
  91219. * Creates an animation range
  91220. * @param name Name of the animation range
  91221. * @param from Starting frame of the animation range
  91222. * @param to Ending frame of the animation
  91223. */
  91224. createRange(name: string, from: number, to: number): void;
  91225. /**
  91226. * Deletes an animation range by name
  91227. * @param name Name of the animation range to delete
  91228. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  91229. */
  91230. deleteRange(name: string, deleteFrames?: boolean): void;
  91231. /**
  91232. * Gets the animation range by name, or null if not defined
  91233. * @param name Name of the animation range
  91234. * @returns Nullable animation range
  91235. */
  91236. getRange(name: string): Nullable<AnimationRange>;
  91237. /**
  91238. * Gets the key frames from the animation
  91239. * @returns The key frames of the animation
  91240. */
  91241. getKeys(): Array<IAnimationKey>;
  91242. /**
  91243. * Gets the highest frame rate of the animation
  91244. * @returns Highest frame rate of the animation
  91245. */
  91246. getHighestFrame(): number;
  91247. /**
  91248. * Gets the easing function of the animation
  91249. * @returns Easing function of the animation
  91250. */
  91251. getEasingFunction(): IEasingFunction;
  91252. /**
  91253. * Sets the easing function of the animation
  91254. * @param easingFunction A custom mathematical formula for animation
  91255. */
  91256. setEasingFunction(easingFunction: EasingFunction): void;
  91257. /**
  91258. * Interpolates a scalar linearly
  91259. * @param startValue Start value of the animation curve
  91260. * @param endValue End value of the animation curve
  91261. * @param gradient Scalar amount to interpolate
  91262. * @returns Interpolated scalar value
  91263. */
  91264. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  91265. /**
  91266. * Interpolates a scalar cubically
  91267. * @param startValue Start value of the animation curve
  91268. * @param outTangent End tangent of the animation
  91269. * @param endValue End value of the animation curve
  91270. * @param inTangent Start tangent of the animation curve
  91271. * @param gradient Scalar amount to interpolate
  91272. * @returns Interpolated scalar value
  91273. */
  91274. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  91275. /**
  91276. * Interpolates a quaternion using a spherical linear interpolation
  91277. * @param startValue Start value of the animation curve
  91278. * @param endValue End value of the animation curve
  91279. * @param gradient Scalar amount to interpolate
  91280. * @returns Interpolated quaternion value
  91281. */
  91282. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  91283. /**
  91284. * Interpolates a quaternion cubically
  91285. * @param startValue Start value of the animation curve
  91286. * @param outTangent End tangent of the animation curve
  91287. * @param endValue End value of the animation curve
  91288. * @param inTangent Start tangent of the animation curve
  91289. * @param gradient Scalar amount to interpolate
  91290. * @returns Interpolated quaternion value
  91291. */
  91292. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  91293. /**
  91294. * Interpolates a Vector3 linearl
  91295. * @param startValue Start value of the animation curve
  91296. * @param endValue End value of the animation curve
  91297. * @param gradient Scalar amount to interpolate
  91298. * @returns Interpolated scalar value
  91299. */
  91300. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  91301. /**
  91302. * Interpolates a Vector3 cubically
  91303. * @param startValue Start value of the animation curve
  91304. * @param outTangent End tangent of the animation
  91305. * @param endValue End value of the animation curve
  91306. * @param inTangent Start tangent of the animation curve
  91307. * @param gradient Scalar amount to interpolate
  91308. * @returns InterpolatedVector3 value
  91309. */
  91310. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  91311. /**
  91312. * Interpolates a Vector2 linearly
  91313. * @param startValue Start value of the animation curve
  91314. * @param endValue End value of the animation curve
  91315. * @param gradient Scalar amount to interpolate
  91316. * @returns Interpolated Vector2 value
  91317. */
  91318. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  91319. /**
  91320. * Interpolates a Vector2 cubically
  91321. * @param startValue Start value of the animation curve
  91322. * @param outTangent End tangent of the animation
  91323. * @param endValue End value of the animation curve
  91324. * @param inTangent Start tangent of the animation curve
  91325. * @param gradient Scalar amount to interpolate
  91326. * @returns Interpolated Vector2 value
  91327. */
  91328. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91329. /**
  91330. * Interpolates a size linearly
  91331. * @param startValue Start value of the animation curve
  91332. * @param endValue End value of the animation curve
  91333. * @param gradient Scalar amount to interpolate
  91334. * @returns Interpolated Size value
  91335. */
  91336. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91337. /**
  91338. * Interpolates a Color3 linearly
  91339. * @param startValue Start value of the animation curve
  91340. * @param endValue End value of the animation curve
  91341. * @param gradient Scalar amount to interpolate
  91342. * @returns Interpolated Color3 value
  91343. */
  91344. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91345. /**
  91346. * @hidden Internal use only
  91347. */
  91348. _getKeyValue(value: any): any;
  91349. /**
  91350. * @hidden Internal use only
  91351. */
  91352. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91353. /**
  91354. * Defines the function to use to interpolate matrices
  91355. * @param startValue defines the start matrix
  91356. * @param endValue defines the end matrix
  91357. * @param gradient defines the gradient between both matrices
  91358. * @param result defines an optional target matrix where to store the interpolation
  91359. * @returns the interpolated matrix
  91360. */
  91361. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91362. /**
  91363. * Makes a copy of the animation
  91364. * @returns Cloned animation
  91365. */
  91366. clone(): Animation;
  91367. /**
  91368. * Sets the key frames of the animation
  91369. * @param values The animation key frames to set
  91370. */
  91371. setKeys(values: Array<IAnimationKey>): void;
  91372. /**
  91373. * Serializes the animation to an object
  91374. * @returns Serialized object
  91375. */
  91376. serialize(): any;
  91377. /**
  91378. * Float animation type
  91379. */
  91380. private static _ANIMATIONTYPE_FLOAT;
  91381. /**
  91382. * Vector3 animation type
  91383. */
  91384. private static _ANIMATIONTYPE_VECTOR3;
  91385. /**
  91386. * Quaternion animation type
  91387. */
  91388. private static _ANIMATIONTYPE_QUATERNION;
  91389. /**
  91390. * Matrix animation type
  91391. */
  91392. private static _ANIMATIONTYPE_MATRIX;
  91393. /**
  91394. * Color3 animation type
  91395. */
  91396. private static _ANIMATIONTYPE_COLOR3;
  91397. /**
  91398. * Vector2 animation type
  91399. */
  91400. private static _ANIMATIONTYPE_VECTOR2;
  91401. /**
  91402. * Size animation type
  91403. */
  91404. private static _ANIMATIONTYPE_SIZE;
  91405. /**
  91406. * Relative Loop Mode
  91407. */
  91408. private static _ANIMATIONLOOPMODE_RELATIVE;
  91409. /**
  91410. * Cycle Loop Mode
  91411. */
  91412. private static _ANIMATIONLOOPMODE_CYCLE;
  91413. /**
  91414. * Constant Loop Mode
  91415. */
  91416. private static _ANIMATIONLOOPMODE_CONSTANT;
  91417. /**
  91418. * Get the float animation type
  91419. */
  91420. static readonly ANIMATIONTYPE_FLOAT: number;
  91421. /**
  91422. * Get the Vector3 animation type
  91423. */
  91424. static readonly ANIMATIONTYPE_VECTOR3: number;
  91425. /**
  91426. * Get the Vector2 animation type
  91427. */
  91428. static readonly ANIMATIONTYPE_VECTOR2: number;
  91429. /**
  91430. * Get the Size animation type
  91431. */
  91432. static readonly ANIMATIONTYPE_SIZE: number;
  91433. /**
  91434. * Get the Quaternion animation type
  91435. */
  91436. static readonly ANIMATIONTYPE_QUATERNION: number;
  91437. /**
  91438. * Get the Matrix animation type
  91439. */
  91440. static readonly ANIMATIONTYPE_MATRIX: number;
  91441. /**
  91442. * Get the Color3 animation type
  91443. */
  91444. static readonly ANIMATIONTYPE_COLOR3: number;
  91445. /**
  91446. * Get the Relative Loop Mode
  91447. */
  91448. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91449. /**
  91450. * Get the Cycle Loop Mode
  91451. */
  91452. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91453. /**
  91454. * Get the Constant Loop Mode
  91455. */
  91456. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91457. /** @hidden */
  91458. static _UniversalLerp(left: any, right: any, amount: number): any;
  91459. /**
  91460. * Parses an animation object and creates an animation
  91461. * @param parsedAnimation Parsed animation object
  91462. * @returns Animation object
  91463. */
  91464. static Parse(parsedAnimation: any): Animation;
  91465. /**
  91466. * Appends the serialized animations from the source animations
  91467. * @param source Source containing the animations
  91468. * @param destination Target to store the animations
  91469. */
  91470. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91471. }
  91472. }
  91473. declare module BABYLON {
  91474. /**
  91475. * Interface containing an array of animations
  91476. */
  91477. export interface IAnimatable {
  91478. /**
  91479. * Array of animations
  91480. */
  91481. animations: Nullable<Array<Animation>>;
  91482. }
  91483. }
  91484. declare module BABYLON {
  91485. /**
  91486. * This represents all the required information to add a fresnel effect on a material:
  91487. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91488. */
  91489. export class FresnelParameters {
  91490. private _isEnabled;
  91491. /**
  91492. * Define if the fresnel effect is enable or not.
  91493. */
  91494. isEnabled: boolean;
  91495. /**
  91496. * Define the color used on edges (grazing angle)
  91497. */
  91498. leftColor: Color3;
  91499. /**
  91500. * Define the color used on center
  91501. */
  91502. rightColor: Color3;
  91503. /**
  91504. * Define bias applied to computed fresnel term
  91505. */
  91506. bias: number;
  91507. /**
  91508. * Defined the power exponent applied to fresnel term
  91509. */
  91510. power: number;
  91511. /**
  91512. * Clones the current fresnel and its valuues
  91513. * @returns a clone fresnel configuration
  91514. */
  91515. clone(): FresnelParameters;
  91516. /**
  91517. * Serializes the current fresnel parameters to a JSON representation.
  91518. * @return the JSON serialization
  91519. */
  91520. serialize(): any;
  91521. /**
  91522. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91523. * @param parsedFresnelParameters Define the JSON representation
  91524. * @returns the parsed parameters
  91525. */
  91526. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91527. }
  91528. }
  91529. declare module BABYLON {
  91530. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91531. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91532. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91533. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91534. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91535. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91536. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91537. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91538. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91539. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91540. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91541. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91542. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91543. /**
  91544. * Decorator used to define property that can be serialized as reference to a camera
  91545. * @param sourceName defines the name of the property to decorate
  91546. */
  91547. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91548. /**
  91549. * Class used to help serialization objects
  91550. */
  91551. export class SerializationHelper {
  91552. /** @hidden */
  91553. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91554. /** @hidden */
  91555. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91556. /** @hidden */
  91557. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91558. /** @hidden */
  91559. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91560. /**
  91561. * Appends the serialized animations from the source animations
  91562. * @param source Source containing the animations
  91563. * @param destination Target to store the animations
  91564. */
  91565. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91566. /**
  91567. * Static function used to serialized a specific entity
  91568. * @param entity defines the entity to serialize
  91569. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91570. * @returns a JSON compatible object representing the serialization of the entity
  91571. */
  91572. static Serialize<T>(entity: T, serializationObject?: any): any;
  91573. /**
  91574. * Creates a new entity from a serialization data object
  91575. * @param creationFunction defines a function used to instanciated the new entity
  91576. * @param source defines the source serialization data
  91577. * @param scene defines the hosting scene
  91578. * @param rootUrl defines the root url for resources
  91579. * @returns a new entity
  91580. */
  91581. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91582. /**
  91583. * Clones an object
  91584. * @param creationFunction defines the function used to instanciate the new object
  91585. * @param source defines the source object
  91586. * @returns the cloned object
  91587. */
  91588. static Clone<T>(creationFunction: () => T, source: T): T;
  91589. /**
  91590. * Instanciates a new object based on a source one (some data will be shared between both object)
  91591. * @param creationFunction defines the function used to instanciate the new object
  91592. * @param source defines the source object
  91593. * @returns the new object
  91594. */
  91595. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91596. }
  91597. }
  91598. declare module BABYLON {
  91599. /**
  91600. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91601. */
  91602. export interface CubeMapInfo {
  91603. /**
  91604. * The pixel array for the front face.
  91605. * This is stored in format, left to right, up to down format.
  91606. */
  91607. front: Nullable<ArrayBufferView>;
  91608. /**
  91609. * The pixel array for the back face.
  91610. * This is stored in format, left to right, up to down format.
  91611. */
  91612. back: Nullable<ArrayBufferView>;
  91613. /**
  91614. * The pixel array for the left face.
  91615. * This is stored in format, left to right, up to down format.
  91616. */
  91617. left: Nullable<ArrayBufferView>;
  91618. /**
  91619. * The pixel array for the right face.
  91620. * This is stored in format, left to right, up to down format.
  91621. */
  91622. right: Nullable<ArrayBufferView>;
  91623. /**
  91624. * The pixel array for the up face.
  91625. * This is stored in format, left to right, up to down format.
  91626. */
  91627. up: Nullable<ArrayBufferView>;
  91628. /**
  91629. * The pixel array for the down face.
  91630. * This is stored in format, left to right, up to down format.
  91631. */
  91632. down: Nullable<ArrayBufferView>;
  91633. /**
  91634. * The size of the cubemap stored.
  91635. *
  91636. * Each faces will be size * size pixels.
  91637. */
  91638. size: number;
  91639. /**
  91640. * The format of the texture.
  91641. *
  91642. * RGBA, RGB.
  91643. */
  91644. format: number;
  91645. /**
  91646. * The type of the texture data.
  91647. *
  91648. * UNSIGNED_INT, FLOAT.
  91649. */
  91650. type: number;
  91651. /**
  91652. * Specifies whether the texture is in gamma space.
  91653. */
  91654. gammaSpace: boolean;
  91655. }
  91656. /**
  91657. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91658. */
  91659. export class PanoramaToCubeMapTools {
  91660. private static FACE_FRONT;
  91661. private static FACE_BACK;
  91662. private static FACE_RIGHT;
  91663. private static FACE_LEFT;
  91664. private static FACE_DOWN;
  91665. private static FACE_UP;
  91666. /**
  91667. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91668. *
  91669. * @param float32Array The source data.
  91670. * @param inputWidth The width of the input panorama.
  91671. * @param inputHeight The height of the input panorama.
  91672. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91673. * @return The cubemap data
  91674. */
  91675. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91676. private static CreateCubemapTexture;
  91677. private static CalcProjectionSpherical;
  91678. }
  91679. }
  91680. declare module BABYLON {
  91681. /**
  91682. * Helper class dealing with the extraction of spherical polynomial dataArray
  91683. * from a cube map.
  91684. */
  91685. export class CubeMapToSphericalPolynomialTools {
  91686. private static FileFaces;
  91687. /**
  91688. * Converts a texture to the according Spherical Polynomial data.
  91689. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91690. *
  91691. * @param texture The texture to extract the information from.
  91692. * @return The Spherical Polynomial data.
  91693. */
  91694. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91695. /**
  91696. * Converts a cubemap to the according Spherical Polynomial data.
  91697. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91698. *
  91699. * @param cubeInfo The Cube map to extract the information from.
  91700. * @return The Spherical Polynomial data.
  91701. */
  91702. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91703. }
  91704. }
  91705. declare module BABYLON {
  91706. /**
  91707. * Class used to manipulate GUIDs
  91708. */
  91709. export class GUID {
  91710. /**
  91711. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91712. * Be aware Math.random() could cause collisions, but:
  91713. * "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"
  91714. * @returns a pseudo random id
  91715. */
  91716. static RandomId(): string;
  91717. }
  91718. }
  91719. declare module BABYLON {
  91720. /**
  91721. * Base class of all the textures in babylon.
  91722. * It groups all the common properties the materials, post process, lights... might need
  91723. * in order to make a correct use of the texture.
  91724. */
  91725. export class BaseTexture implements IAnimatable {
  91726. /**
  91727. * Default anisotropic filtering level for the application.
  91728. * It is set to 4 as a good tradeoff between perf and quality.
  91729. */
  91730. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91731. /**
  91732. * Gets or sets the unique id of the texture
  91733. */
  91734. uniqueId: number;
  91735. /**
  91736. * Define the name of the texture.
  91737. */
  91738. name: string;
  91739. /**
  91740. * Gets or sets an object used to store user defined information.
  91741. */
  91742. metadata: any;
  91743. /**
  91744. * For internal use only. Please do not use.
  91745. */
  91746. reservedDataStore: any;
  91747. private _hasAlpha;
  91748. /**
  91749. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91750. */
  91751. hasAlpha: boolean;
  91752. /**
  91753. * Defines if the alpha value should be determined via the rgb values.
  91754. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91755. */
  91756. getAlphaFromRGB: boolean;
  91757. /**
  91758. * Intensity or strength of the texture.
  91759. * It is commonly used by materials to fine tune the intensity of the texture
  91760. */
  91761. level: number;
  91762. /**
  91763. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91764. * This is part of the texture as textures usually maps to one uv set.
  91765. */
  91766. coordinatesIndex: number;
  91767. private _coordinatesMode;
  91768. /**
  91769. * How a texture is mapped.
  91770. *
  91771. * | Value | Type | Description |
  91772. * | ----- | ----------------------------------- | ----------- |
  91773. * | 0 | EXPLICIT_MODE | |
  91774. * | 1 | SPHERICAL_MODE | |
  91775. * | 2 | PLANAR_MODE | |
  91776. * | 3 | CUBIC_MODE | |
  91777. * | 4 | PROJECTION_MODE | |
  91778. * | 5 | SKYBOX_MODE | |
  91779. * | 6 | INVCUBIC_MODE | |
  91780. * | 7 | EQUIRECTANGULAR_MODE | |
  91781. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91782. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91783. */
  91784. coordinatesMode: number;
  91785. /**
  91786. * | Value | Type | Description |
  91787. * | ----- | ------------------ | ----------- |
  91788. * | 0 | CLAMP_ADDRESSMODE | |
  91789. * | 1 | WRAP_ADDRESSMODE | |
  91790. * | 2 | MIRROR_ADDRESSMODE | |
  91791. */
  91792. wrapU: number;
  91793. /**
  91794. * | Value | Type | Description |
  91795. * | ----- | ------------------ | ----------- |
  91796. * | 0 | CLAMP_ADDRESSMODE | |
  91797. * | 1 | WRAP_ADDRESSMODE | |
  91798. * | 2 | MIRROR_ADDRESSMODE | |
  91799. */
  91800. wrapV: number;
  91801. /**
  91802. * | Value | Type | Description |
  91803. * | ----- | ------------------ | ----------- |
  91804. * | 0 | CLAMP_ADDRESSMODE | |
  91805. * | 1 | WRAP_ADDRESSMODE | |
  91806. * | 2 | MIRROR_ADDRESSMODE | |
  91807. */
  91808. wrapR: number;
  91809. /**
  91810. * With compliant hardware and browser (supporting anisotropic filtering)
  91811. * this defines the level of anisotropic filtering in the texture.
  91812. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91813. */
  91814. anisotropicFilteringLevel: number;
  91815. /**
  91816. * Define if the texture is a cube texture or if false a 2d texture.
  91817. */
  91818. isCube: boolean;
  91819. /**
  91820. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91821. */
  91822. is3D: boolean;
  91823. /**
  91824. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91825. * HDR texture are usually stored in linear space.
  91826. * This only impacts the PBR and Background materials
  91827. */
  91828. gammaSpace: boolean;
  91829. /**
  91830. * Gets whether or not the texture contains RGBD data.
  91831. */
  91832. readonly isRGBD: boolean;
  91833. /**
  91834. * Is Z inverted in the texture (useful in a cube texture).
  91835. */
  91836. invertZ: boolean;
  91837. /**
  91838. * Are mip maps generated for this texture or not.
  91839. */
  91840. readonly noMipmap: boolean;
  91841. /**
  91842. * @hidden
  91843. */
  91844. lodLevelInAlpha: boolean;
  91845. /**
  91846. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91847. */
  91848. lodGenerationOffset: number;
  91849. /**
  91850. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91851. */
  91852. lodGenerationScale: number;
  91853. /**
  91854. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91855. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91856. * average roughness values.
  91857. */
  91858. linearSpecularLOD: boolean;
  91859. /**
  91860. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91861. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91862. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91863. */
  91864. irradianceTexture: Nullable<BaseTexture>;
  91865. /**
  91866. * Define if the texture is a render target.
  91867. */
  91868. isRenderTarget: boolean;
  91869. /**
  91870. * Define the unique id of the texture in the scene.
  91871. */
  91872. readonly uid: string;
  91873. /**
  91874. * Return a string representation of the texture.
  91875. * @returns the texture as a string
  91876. */
  91877. toString(): string;
  91878. /**
  91879. * Get the class name of the texture.
  91880. * @returns "BaseTexture"
  91881. */
  91882. getClassName(): string;
  91883. /**
  91884. * Define the list of animation attached to the texture.
  91885. */
  91886. animations: Animation[];
  91887. /**
  91888. * An event triggered when the texture is disposed.
  91889. */
  91890. onDisposeObservable: Observable<BaseTexture>;
  91891. private _onDisposeObserver;
  91892. /**
  91893. * Callback triggered when the texture has been disposed.
  91894. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91895. */
  91896. onDispose: () => void;
  91897. /**
  91898. * Define the current state of the loading sequence when in delayed load mode.
  91899. */
  91900. delayLoadState: number;
  91901. private _scene;
  91902. /** @hidden */
  91903. _texture: Nullable<InternalTexture>;
  91904. private _uid;
  91905. /**
  91906. * Define if the texture is preventinga material to render or not.
  91907. * If not and the texture is not ready, the engine will use a default black texture instead.
  91908. */
  91909. readonly isBlocking: boolean;
  91910. /**
  91911. * Instantiates a new BaseTexture.
  91912. * Base class of all the textures in babylon.
  91913. * It groups all the common properties the materials, post process, lights... might need
  91914. * in order to make a correct use of the texture.
  91915. * @param scene Define the scene the texture blongs to
  91916. */
  91917. constructor(scene: Nullable<Scene>);
  91918. /**
  91919. * Get the scene the texture belongs to.
  91920. * @returns the scene or null if undefined
  91921. */
  91922. getScene(): Nullable<Scene>;
  91923. /**
  91924. * Get the texture transform matrix used to offset tile the texture for istance.
  91925. * @returns the transformation matrix
  91926. */
  91927. getTextureMatrix(): Matrix;
  91928. /**
  91929. * Get the texture reflection matrix used to rotate/transform the reflection.
  91930. * @returns the reflection matrix
  91931. */
  91932. getReflectionTextureMatrix(): Matrix;
  91933. /**
  91934. * Get the underlying lower level texture from Babylon.
  91935. * @returns the insternal texture
  91936. */
  91937. getInternalTexture(): Nullable<InternalTexture>;
  91938. /**
  91939. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91940. * @returns true if ready or not blocking
  91941. */
  91942. isReadyOrNotBlocking(): boolean;
  91943. /**
  91944. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91945. * @returns true if fully ready
  91946. */
  91947. isReady(): boolean;
  91948. private _cachedSize;
  91949. /**
  91950. * Get the size of the texture.
  91951. * @returns the texture size.
  91952. */
  91953. getSize(): ISize;
  91954. /**
  91955. * Get the base size of the texture.
  91956. * It can be different from the size if the texture has been resized for POT for instance
  91957. * @returns the base size
  91958. */
  91959. getBaseSize(): ISize;
  91960. /**
  91961. * Update the sampling mode of the texture.
  91962. * Default is Trilinear mode.
  91963. *
  91964. * | Value | Type | Description |
  91965. * | ----- | ------------------ | ----------- |
  91966. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91967. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91968. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91969. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91970. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91971. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91972. * | 7 | NEAREST_LINEAR | |
  91973. * | 8 | NEAREST_NEAREST | |
  91974. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91975. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91976. * | 11 | LINEAR_LINEAR | |
  91977. * | 12 | LINEAR_NEAREST | |
  91978. *
  91979. * > _mag_: magnification filter (close to the viewer)
  91980. * > _min_: minification filter (far from the viewer)
  91981. * > _mip_: filter used between mip map levels
  91982. *@param samplingMode Define the new sampling mode of the texture
  91983. */
  91984. updateSamplingMode(samplingMode: number): void;
  91985. /**
  91986. * Scales the texture if is `canRescale()`
  91987. * @param ratio the resize factor we want to use to rescale
  91988. */
  91989. scale(ratio: number): void;
  91990. /**
  91991. * Get if the texture can rescale.
  91992. */
  91993. readonly canRescale: boolean;
  91994. /** @hidden */
  91995. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91996. /** @hidden */
  91997. _rebuild(): void;
  91998. /**
  91999. * Triggers the load sequence in delayed load mode.
  92000. */
  92001. delayLoad(): void;
  92002. /**
  92003. * Clones the texture.
  92004. * @returns the cloned texture
  92005. */
  92006. clone(): Nullable<BaseTexture>;
  92007. /**
  92008. * Get the texture underlying type (INT, FLOAT...)
  92009. */
  92010. readonly textureType: number;
  92011. /**
  92012. * Get the texture underlying format (RGB, RGBA...)
  92013. */
  92014. readonly textureFormat: number;
  92015. /**
  92016. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  92017. * This will returns an RGBA array buffer containing either in values (0-255) or
  92018. * float values (0-1) depending of the underlying buffer type.
  92019. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92020. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92021. * @param buffer defines a user defined buffer to fill with data (can be null)
  92022. * @returns The Array buffer containing the pixels data.
  92023. */
  92024. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  92025. /**
  92026. * Release and destroy the underlying lower level texture aka internalTexture.
  92027. */
  92028. releaseInternalTexture(): void;
  92029. /**
  92030. * Get the polynomial representation of the texture data.
  92031. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  92032. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  92033. */
  92034. sphericalPolynomial: Nullable<SphericalPolynomial>;
  92035. /** @hidden */
  92036. readonly _lodTextureHigh: Nullable<BaseTexture>;
  92037. /** @hidden */
  92038. readonly _lodTextureMid: Nullable<BaseTexture>;
  92039. /** @hidden */
  92040. readonly _lodTextureLow: Nullable<BaseTexture>;
  92041. /**
  92042. * Dispose the texture and release its associated resources.
  92043. */
  92044. dispose(): void;
  92045. /**
  92046. * Serialize the texture into a JSON representation that can be parsed later on.
  92047. * @returns the JSON representation of the texture
  92048. */
  92049. serialize(): any;
  92050. /**
  92051. * Helper function to be called back once a list of texture contains only ready textures.
  92052. * @param textures Define the list of textures to wait for
  92053. * @param callback Define the callback triggered once the entire list will be ready
  92054. */
  92055. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  92056. }
  92057. }
  92058. declare module BABYLON {
  92059. /**
  92060. * Class used to store data associated with WebGL texture data for the engine
  92061. * This class should not be used directly
  92062. */
  92063. export class InternalTexture {
  92064. /** @hidden */
  92065. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  92066. /**
  92067. * The source of the texture data is unknown
  92068. */
  92069. static DATASOURCE_UNKNOWN: number;
  92070. /**
  92071. * Texture data comes from an URL
  92072. */
  92073. static DATASOURCE_URL: number;
  92074. /**
  92075. * Texture data is only used for temporary storage
  92076. */
  92077. static DATASOURCE_TEMP: number;
  92078. /**
  92079. * Texture data comes from raw data (ArrayBuffer)
  92080. */
  92081. static DATASOURCE_RAW: number;
  92082. /**
  92083. * Texture content is dynamic (video or dynamic texture)
  92084. */
  92085. static DATASOURCE_DYNAMIC: number;
  92086. /**
  92087. * Texture content is generated by rendering to it
  92088. */
  92089. static DATASOURCE_RENDERTARGET: number;
  92090. /**
  92091. * Texture content is part of a multi render target process
  92092. */
  92093. static DATASOURCE_MULTIRENDERTARGET: number;
  92094. /**
  92095. * Texture data comes from a cube data file
  92096. */
  92097. static DATASOURCE_CUBE: number;
  92098. /**
  92099. * Texture data comes from a raw cube data
  92100. */
  92101. static DATASOURCE_CUBERAW: number;
  92102. /**
  92103. * Texture data come from a prefiltered cube data file
  92104. */
  92105. static DATASOURCE_CUBEPREFILTERED: number;
  92106. /**
  92107. * Texture content is raw 3D data
  92108. */
  92109. static DATASOURCE_RAW3D: number;
  92110. /**
  92111. * Texture content is a depth texture
  92112. */
  92113. static DATASOURCE_DEPTHTEXTURE: number;
  92114. /**
  92115. * Texture data comes from a raw cube data encoded with RGBD
  92116. */
  92117. static DATASOURCE_CUBERAW_RGBD: number;
  92118. /**
  92119. * Defines if the texture is ready
  92120. */
  92121. isReady: boolean;
  92122. /**
  92123. * Defines if the texture is a cube texture
  92124. */
  92125. isCube: boolean;
  92126. /**
  92127. * Defines if the texture contains 3D data
  92128. */
  92129. is3D: boolean;
  92130. /**
  92131. * Defines if the texture contains multiview data
  92132. */
  92133. isMultiview: boolean;
  92134. /**
  92135. * Gets the URL used to load this texture
  92136. */
  92137. url: string;
  92138. /**
  92139. * Gets the sampling mode of the texture
  92140. */
  92141. samplingMode: number;
  92142. /**
  92143. * Gets a boolean indicating if the texture needs mipmaps generation
  92144. */
  92145. generateMipMaps: boolean;
  92146. /**
  92147. * Gets the number of samples used by the texture (WebGL2+ only)
  92148. */
  92149. samples: number;
  92150. /**
  92151. * Gets the type of the texture (int, float...)
  92152. */
  92153. type: number;
  92154. /**
  92155. * Gets the format of the texture (RGB, RGBA...)
  92156. */
  92157. format: number;
  92158. /**
  92159. * Observable called when the texture is loaded
  92160. */
  92161. onLoadedObservable: Observable<InternalTexture>;
  92162. /**
  92163. * Gets the width of the texture
  92164. */
  92165. width: number;
  92166. /**
  92167. * Gets the height of the texture
  92168. */
  92169. height: number;
  92170. /**
  92171. * Gets the depth of the texture
  92172. */
  92173. depth: number;
  92174. /**
  92175. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  92176. */
  92177. baseWidth: number;
  92178. /**
  92179. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  92180. */
  92181. baseHeight: number;
  92182. /**
  92183. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  92184. */
  92185. baseDepth: number;
  92186. /**
  92187. * Gets a boolean indicating if the texture is inverted on Y axis
  92188. */
  92189. invertY: boolean;
  92190. /** @hidden */
  92191. _invertVScale: boolean;
  92192. /** @hidden */
  92193. _associatedChannel: number;
  92194. /** @hidden */
  92195. _dataSource: number;
  92196. /** @hidden */
  92197. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  92198. /** @hidden */
  92199. _bufferView: Nullable<ArrayBufferView>;
  92200. /** @hidden */
  92201. _bufferViewArray: Nullable<ArrayBufferView[]>;
  92202. /** @hidden */
  92203. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  92204. /** @hidden */
  92205. _size: number;
  92206. /** @hidden */
  92207. _extension: string;
  92208. /** @hidden */
  92209. _files: Nullable<string[]>;
  92210. /** @hidden */
  92211. _workingCanvas: Nullable<HTMLCanvasElement>;
  92212. /** @hidden */
  92213. _workingContext: Nullable<CanvasRenderingContext2D>;
  92214. /** @hidden */
  92215. _framebuffer: Nullable<WebGLFramebuffer>;
  92216. /** @hidden */
  92217. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  92218. /** @hidden */
  92219. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  92220. /** @hidden */
  92221. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  92222. /** @hidden */
  92223. _attachments: Nullable<number[]>;
  92224. /** @hidden */
  92225. _cachedCoordinatesMode: Nullable<number>;
  92226. /** @hidden */
  92227. _cachedWrapU: Nullable<number>;
  92228. /** @hidden */
  92229. _cachedWrapV: Nullable<number>;
  92230. /** @hidden */
  92231. _cachedWrapR: Nullable<number>;
  92232. /** @hidden */
  92233. _cachedAnisotropicFilteringLevel: Nullable<number>;
  92234. /** @hidden */
  92235. _isDisabled: boolean;
  92236. /** @hidden */
  92237. _compression: Nullable<string>;
  92238. /** @hidden */
  92239. _generateStencilBuffer: boolean;
  92240. /** @hidden */
  92241. _generateDepthBuffer: boolean;
  92242. /** @hidden */
  92243. _comparisonFunction: number;
  92244. /** @hidden */
  92245. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  92246. /** @hidden */
  92247. _lodGenerationScale: number;
  92248. /** @hidden */
  92249. _lodGenerationOffset: number;
  92250. /** @hidden */
  92251. _colorTextureArray: Nullable<WebGLTexture>;
  92252. /** @hidden */
  92253. _depthStencilTextureArray: Nullable<WebGLTexture>;
  92254. /** @hidden */
  92255. _lodTextureHigh: Nullable<BaseTexture>;
  92256. /** @hidden */
  92257. _lodTextureMid: Nullable<BaseTexture>;
  92258. /** @hidden */
  92259. _lodTextureLow: Nullable<BaseTexture>;
  92260. /** @hidden */
  92261. _isRGBD: boolean;
  92262. /** @hidden */
  92263. _linearSpecularLOD: boolean;
  92264. /** @hidden */
  92265. _irradianceTexture: Nullable<BaseTexture>;
  92266. /** @hidden */
  92267. _webGLTexture: Nullable<WebGLTexture>;
  92268. /** @hidden */
  92269. _references: number;
  92270. private _engine;
  92271. /**
  92272. * Gets the Engine the texture belongs to.
  92273. * @returns The babylon engine
  92274. */
  92275. getEngine(): Engine;
  92276. /**
  92277. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  92278. */
  92279. readonly dataSource: number;
  92280. /**
  92281. * Creates a new InternalTexture
  92282. * @param engine defines the engine to use
  92283. * @param dataSource defines the type of data that will be used
  92284. * @param delayAllocation if the texture allocation should be delayed (default: false)
  92285. */
  92286. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  92287. /**
  92288. * Increments the number of references (ie. the number of Texture that point to it)
  92289. */
  92290. incrementReferences(): void;
  92291. /**
  92292. * Change the size of the texture (not the size of the content)
  92293. * @param width defines the new width
  92294. * @param height defines the new height
  92295. * @param depth defines the new depth (1 by default)
  92296. */
  92297. updateSize(width: int, height: int, depth?: int): void;
  92298. /** @hidden */
  92299. _rebuild(): void;
  92300. /** @hidden */
  92301. _swapAndDie(target: InternalTexture): void;
  92302. /**
  92303. * Dispose the current allocated resources
  92304. */
  92305. dispose(): void;
  92306. }
  92307. }
  92308. declare module BABYLON {
  92309. /**
  92310. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  92311. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  92312. */
  92313. export class EffectFallbacks {
  92314. private _defines;
  92315. private _currentRank;
  92316. private _maxRank;
  92317. private _mesh;
  92318. /**
  92319. * Removes the fallback from the bound mesh.
  92320. */
  92321. unBindMesh(): void;
  92322. /**
  92323. * Adds a fallback on the specified property.
  92324. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92325. * @param define The name of the define in the shader
  92326. */
  92327. addFallback(rank: number, define: string): void;
  92328. /**
  92329. * Sets the mesh to use CPU skinning when needing to fallback.
  92330. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92331. * @param mesh The mesh to use the fallbacks.
  92332. */
  92333. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92334. /**
  92335. * Checks to see if more fallbacks are still availible.
  92336. */
  92337. readonly isMoreFallbacks: boolean;
  92338. /**
  92339. * Removes the defines that should be removed when falling back.
  92340. * @param currentDefines defines the current define statements for the shader.
  92341. * @param effect defines the current effect we try to compile
  92342. * @returns The resulting defines with defines of the current rank removed.
  92343. */
  92344. reduce(currentDefines: string, effect: Effect): string;
  92345. }
  92346. /**
  92347. * Options to be used when creating an effect.
  92348. */
  92349. export class EffectCreationOptions {
  92350. /**
  92351. * Atrributes that will be used in the shader.
  92352. */
  92353. attributes: string[];
  92354. /**
  92355. * Uniform varible names that will be set in the shader.
  92356. */
  92357. uniformsNames: string[];
  92358. /**
  92359. * Uniform buffer varible names that will be set in the shader.
  92360. */
  92361. uniformBuffersNames: string[];
  92362. /**
  92363. * Sampler texture variable names that will be set in the shader.
  92364. */
  92365. samplers: string[];
  92366. /**
  92367. * Define statements that will be set in the shader.
  92368. */
  92369. defines: any;
  92370. /**
  92371. * Possible fallbacks for this effect to improve performance when needed.
  92372. */
  92373. fallbacks: Nullable<EffectFallbacks>;
  92374. /**
  92375. * Callback that will be called when the shader is compiled.
  92376. */
  92377. onCompiled: Nullable<(effect: Effect) => void>;
  92378. /**
  92379. * Callback that will be called if an error occurs during shader compilation.
  92380. */
  92381. onError: Nullable<(effect: Effect, errors: string) => void>;
  92382. /**
  92383. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92384. */
  92385. indexParameters: any;
  92386. /**
  92387. * Max number of lights that can be used in the shader.
  92388. */
  92389. maxSimultaneousLights: number;
  92390. /**
  92391. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92392. */
  92393. transformFeedbackVaryings: Nullable<string[]>;
  92394. }
  92395. /**
  92396. * Effect containing vertex and fragment shader that can be executed on an object.
  92397. */
  92398. export class Effect implements IDisposable {
  92399. /**
  92400. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92401. */
  92402. static ShadersRepository: string;
  92403. /**
  92404. * Name of the effect.
  92405. */
  92406. name: any;
  92407. /**
  92408. * String container all the define statements that should be set on the shader.
  92409. */
  92410. defines: string;
  92411. /**
  92412. * Callback that will be called when the shader is compiled.
  92413. */
  92414. onCompiled: Nullable<(effect: Effect) => void>;
  92415. /**
  92416. * Callback that will be called if an error occurs during shader compilation.
  92417. */
  92418. onError: Nullable<(effect: Effect, errors: string) => void>;
  92419. /**
  92420. * Callback that will be called when effect is bound.
  92421. */
  92422. onBind: Nullable<(effect: Effect) => void>;
  92423. /**
  92424. * Unique ID of the effect.
  92425. */
  92426. uniqueId: number;
  92427. /**
  92428. * Observable that will be called when the shader is compiled.
  92429. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92430. */
  92431. onCompileObservable: Observable<Effect>;
  92432. /**
  92433. * Observable that will be called if an error occurs during shader compilation.
  92434. */
  92435. onErrorObservable: Observable<Effect>;
  92436. /** @hidden */
  92437. _onBindObservable: Nullable<Observable<Effect>>;
  92438. /**
  92439. * Observable that will be called when effect is bound.
  92440. */
  92441. readonly onBindObservable: Observable<Effect>;
  92442. /** @hidden */
  92443. _bonesComputationForcedToCPU: boolean;
  92444. private static _uniqueIdSeed;
  92445. private _engine;
  92446. private _uniformBuffersNames;
  92447. private _uniformsNames;
  92448. private _samplerList;
  92449. private _samplers;
  92450. private _isReady;
  92451. private _compilationError;
  92452. private _attributesNames;
  92453. private _attributes;
  92454. private _uniforms;
  92455. /**
  92456. * Key for the effect.
  92457. * @hidden
  92458. */
  92459. _key: string;
  92460. private _indexParameters;
  92461. private _fallbacks;
  92462. private _vertexSourceCode;
  92463. private _fragmentSourceCode;
  92464. private _vertexSourceCodeOverride;
  92465. private _fragmentSourceCodeOverride;
  92466. private _transformFeedbackVaryings;
  92467. /**
  92468. * Compiled shader to webGL program.
  92469. * @hidden
  92470. */
  92471. _pipelineContext: Nullable<IPipelineContext>;
  92472. private _valueCache;
  92473. private static _baseCache;
  92474. /**
  92475. * Instantiates an effect.
  92476. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92477. * @param baseName Name of the effect.
  92478. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92479. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92480. * @param samplers List of sampler variables that will be passed to the shader.
  92481. * @param engine Engine to be used to render the effect
  92482. * @param defines Define statements to be added to the shader.
  92483. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92484. * @param onCompiled Callback that will be called when the shader is compiled.
  92485. * @param onError Callback that will be called if an error occurs during shader compilation.
  92486. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92487. */
  92488. 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);
  92489. private _useFinalCode;
  92490. /**
  92491. * Unique key for this effect
  92492. */
  92493. readonly key: string;
  92494. /**
  92495. * If the effect has been compiled and prepared.
  92496. * @returns if the effect is compiled and prepared.
  92497. */
  92498. isReady(): boolean;
  92499. /**
  92500. * The engine the effect was initialized with.
  92501. * @returns the engine.
  92502. */
  92503. getEngine(): Engine;
  92504. /**
  92505. * The pipeline context for this effect
  92506. * @returns the associated pipeline context
  92507. */
  92508. getPipelineContext(): Nullable<IPipelineContext>;
  92509. /**
  92510. * The set of names of attribute variables for the shader.
  92511. * @returns An array of attribute names.
  92512. */
  92513. getAttributesNames(): string[];
  92514. /**
  92515. * Returns the attribute at the given index.
  92516. * @param index The index of the attribute.
  92517. * @returns The location of the attribute.
  92518. */
  92519. getAttributeLocation(index: number): number;
  92520. /**
  92521. * Returns the attribute based on the name of the variable.
  92522. * @param name of the attribute to look up.
  92523. * @returns the attribute location.
  92524. */
  92525. getAttributeLocationByName(name: string): number;
  92526. /**
  92527. * The number of attributes.
  92528. * @returns the numnber of attributes.
  92529. */
  92530. getAttributesCount(): number;
  92531. /**
  92532. * Gets the index of a uniform variable.
  92533. * @param uniformName of the uniform to look up.
  92534. * @returns the index.
  92535. */
  92536. getUniformIndex(uniformName: string): number;
  92537. /**
  92538. * Returns the attribute based on the name of the variable.
  92539. * @param uniformName of the uniform to look up.
  92540. * @returns the location of the uniform.
  92541. */
  92542. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92543. /**
  92544. * Returns an array of sampler variable names
  92545. * @returns The array of sampler variable neames.
  92546. */
  92547. getSamplers(): string[];
  92548. /**
  92549. * The error from the last compilation.
  92550. * @returns the error string.
  92551. */
  92552. getCompilationError(): string;
  92553. /**
  92554. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92555. * @param func The callback to be used.
  92556. */
  92557. executeWhenCompiled(func: (effect: Effect) => void): void;
  92558. private _checkIsReady;
  92559. /** @hidden */
  92560. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92561. /** @hidden */
  92562. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92563. /** @hidden */
  92564. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92565. /**
  92566. * Recompiles the webGL program
  92567. * @param vertexSourceCode The source code for the vertex shader.
  92568. * @param fragmentSourceCode The source code for the fragment shader.
  92569. * @param onCompiled Callback called when completed.
  92570. * @param onError Callback called on error.
  92571. * @hidden
  92572. */
  92573. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92574. /**
  92575. * Prepares the effect
  92576. * @hidden
  92577. */
  92578. _prepareEffect(): void;
  92579. /**
  92580. * Checks if the effect is supported. (Must be called after compilation)
  92581. */
  92582. readonly isSupported: boolean;
  92583. /**
  92584. * Binds a texture to the engine to be used as output of the shader.
  92585. * @param channel Name of the output variable.
  92586. * @param texture Texture to bind.
  92587. * @hidden
  92588. */
  92589. _bindTexture(channel: string, texture: InternalTexture): void;
  92590. /**
  92591. * Sets a texture on the engine to be used in the shader.
  92592. * @param channel Name of the sampler variable.
  92593. * @param texture Texture to set.
  92594. */
  92595. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92596. /**
  92597. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92598. * @param channel Name of the sampler variable.
  92599. * @param texture Texture to set.
  92600. */
  92601. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92602. /**
  92603. * Sets an array of textures on the engine to be used in the shader.
  92604. * @param channel Name of the variable.
  92605. * @param textures Textures to set.
  92606. */
  92607. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92608. /**
  92609. * 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)
  92610. * @param channel Name of the sampler variable.
  92611. * @param postProcess Post process to get the input texture from.
  92612. */
  92613. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92614. /**
  92615. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92616. * 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)
  92617. * @param channel Name of the sampler variable.
  92618. * @param postProcess Post process to get the output texture from.
  92619. */
  92620. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92621. /** @hidden */
  92622. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92623. /** @hidden */
  92624. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92625. /** @hidden */
  92626. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92627. /** @hidden */
  92628. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92629. /**
  92630. * Binds a buffer to a uniform.
  92631. * @param buffer Buffer to bind.
  92632. * @param name Name of the uniform variable to bind to.
  92633. */
  92634. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92635. /**
  92636. * Binds block to a uniform.
  92637. * @param blockName Name of the block to bind.
  92638. * @param index Index to bind.
  92639. */
  92640. bindUniformBlock(blockName: string, index: number): void;
  92641. /**
  92642. * Sets an interger value on a uniform variable.
  92643. * @param uniformName Name of the variable.
  92644. * @param value Value to be set.
  92645. * @returns this effect.
  92646. */
  92647. setInt(uniformName: string, value: number): Effect;
  92648. /**
  92649. * Sets an int array on a uniform variable.
  92650. * @param uniformName Name of the variable.
  92651. * @param array array to be set.
  92652. * @returns this effect.
  92653. */
  92654. setIntArray(uniformName: string, array: Int32Array): Effect;
  92655. /**
  92656. * 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)
  92657. * @param uniformName Name of the variable.
  92658. * @param array array to be set.
  92659. * @returns this effect.
  92660. */
  92661. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92662. /**
  92663. * 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)
  92664. * @param uniformName Name of the variable.
  92665. * @param array array to be set.
  92666. * @returns this effect.
  92667. */
  92668. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92669. /**
  92670. * 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)
  92671. * @param uniformName Name of the variable.
  92672. * @param array array to be set.
  92673. * @returns this effect.
  92674. */
  92675. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92676. /**
  92677. * Sets an float array on a uniform variable.
  92678. * @param uniformName Name of the variable.
  92679. * @param array array to be set.
  92680. * @returns this effect.
  92681. */
  92682. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92683. /**
  92684. * 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)
  92685. * @param uniformName Name of the variable.
  92686. * @param array array to be set.
  92687. * @returns this effect.
  92688. */
  92689. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92690. /**
  92691. * 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)
  92692. * @param uniformName Name of the variable.
  92693. * @param array array to be set.
  92694. * @returns this effect.
  92695. */
  92696. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92697. /**
  92698. * 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)
  92699. * @param uniformName Name of the variable.
  92700. * @param array array to be set.
  92701. * @returns this effect.
  92702. */
  92703. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92704. /**
  92705. * Sets an array on a uniform variable.
  92706. * @param uniformName Name of the variable.
  92707. * @param array array to be set.
  92708. * @returns this effect.
  92709. */
  92710. setArray(uniformName: string, array: number[]): Effect;
  92711. /**
  92712. * 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)
  92713. * @param uniformName Name of the variable.
  92714. * @param array array to be set.
  92715. * @returns this effect.
  92716. */
  92717. setArray2(uniformName: string, array: number[]): Effect;
  92718. /**
  92719. * 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)
  92720. * @param uniformName Name of the variable.
  92721. * @param array array to be set.
  92722. * @returns this effect.
  92723. */
  92724. setArray3(uniformName: string, array: number[]): Effect;
  92725. /**
  92726. * 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)
  92727. * @param uniformName Name of the variable.
  92728. * @param array array to be set.
  92729. * @returns this effect.
  92730. */
  92731. setArray4(uniformName: string, array: number[]): Effect;
  92732. /**
  92733. * Sets matrices on a uniform variable.
  92734. * @param uniformName Name of the variable.
  92735. * @param matrices matrices to be set.
  92736. * @returns this effect.
  92737. */
  92738. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92739. /**
  92740. * Sets matrix on a uniform variable.
  92741. * @param uniformName Name of the variable.
  92742. * @param matrix matrix to be set.
  92743. * @returns this effect.
  92744. */
  92745. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92746. /**
  92747. * 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)
  92748. * @param uniformName Name of the variable.
  92749. * @param matrix matrix to be set.
  92750. * @returns this effect.
  92751. */
  92752. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92753. /**
  92754. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92755. * @param uniformName Name of the variable.
  92756. * @param matrix matrix to be set.
  92757. * @returns this effect.
  92758. */
  92759. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92760. /**
  92761. * Sets a float on a uniform variable.
  92762. * @param uniformName Name of the variable.
  92763. * @param value value to be set.
  92764. * @returns this effect.
  92765. */
  92766. setFloat(uniformName: string, value: number): Effect;
  92767. /**
  92768. * Sets a boolean on a uniform variable.
  92769. * @param uniformName Name of the variable.
  92770. * @param bool value to be set.
  92771. * @returns this effect.
  92772. */
  92773. setBool(uniformName: string, bool: boolean): Effect;
  92774. /**
  92775. * Sets a Vector2 on a uniform variable.
  92776. * @param uniformName Name of the variable.
  92777. * @param vector2 vector2 to be set.
  92778. * @returns this effect.
  92779. */
  92780. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92781. /**
  92782. * Sets a float2 on a uniform variable.
  92783. * @param uniformName Name of the variable.
  92784. * @param x First float in float2.
  92785. * @param y Second float in float2.
  92786. * @returns this effect.
  92787. */
  92788. setFloat2(uniformName: string, x: number, y: number): Effect;
  92789. /**
  92790. * Sets a Vector3 on a uniform variable.
  92791. * @param uniformName Name of the variable.
  92792. * @param vector3 Value to be set.
  92793. * @returns this effect.
  92794. */
  92795. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92796. /**
  92797. * Sets a float3 on a uniform variable.
  92798. * @param uniformName Name of the variable.
  92799. * @param x First float in float3.
  92800. * @param y Second float in float3.
  92801. * @param z Third float in float3.
  92802. * @returns this effect.
  92803. */
  92804. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92805. /**
  92806. * Sets a Vector4 on a uniform variable.
  92807. * @param uniformName Name of the variable.
  92808. * @param vector4 Value to be set.
  92809. * @returns this effect.
  92810. */
  92811. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92812. /**
  92813. * Sets a float4 on a uniform variable.
  92814. * @param uniformName Name of the variable.
  92815. * @param x First float in float4.
  92816. * @param y Second float in float4.
  92817. * @param z Third float in float4.
  92818. * @param w Fourth float in float4.
  92819. * @returns this effect.
  92820. */
  92821. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92822. /**
  92823. * Sets a Color3 on a uniform variable.
  92824. * @param uniformName Name of the variable.
  92825. * @param color3 Value to be set.
  92826. * @returns this effect.
  92827. */
  92828. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92829. /**
  92830. * Sets a Color4 on a uniform variable.
  92831. * @param uniformName Name of the variable.
  92832. * @param color3 Value to be set.
  92833. * @param alpha Alpha value to be set.
  92834. * @returns this effect.
  92835. */
  92836. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92837. /**
  92838. * Sets a Color4 on a uniform variable
  92839. * @param uniformName defines the name of the variable
  92840. * @param color4 defines the value to be set
  92841. * @returns this effect.
  92842. */
  92843. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92844. /** Release all associated resources */
  92845. dispose(): void;
  92846. /**
  92847. * This function will add a new shader to the shader store
  92848. * @param name the name of the shader
  92849. * @param pixelShader optional pixel shader content
  92850. * @param vertexShader optional vertex shader content
  92851. */
  92852. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92853. /**
  92854. * Store of each shader (The can be looked up using effect.key)
  92855. */
  92856. static ShadersStore: {
  92857. [key: string]: string;
  92858. };
  92859. /**
  92860. * Store of each included file for a shader (The can be looked up using effect.key)
  92861. */
  92862. static IncludesShadersStore: {
  92863. [key: string]: string;
  92864. };
  92865. /**
  92866. * Resets the cache of effects.
  92867. */
  92868. static ResetCache(): void;
  92869. }
  92870. }
  92871. declare module BABYLON {
  92872. /**
  92873. * Uniform buffer objects.
  92874. *
  92875. * Handles blocks of uniform on the GPU.
  92876. *
  92877. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92878. *
  92879. * For more information, please refer to :
  92880. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92881. */
  92882. export class UniformBuffer {
  92883. private _engine;
  92884. private _buffer;
  92885. private _data;
  92886. private _bufferData;
  92887. private _dynamic?;
  92888. private _uniformLocations;
  92889. private _uniformSizes;
  92890. private _uniformLocationPointer;
  92891. private _needSync;
  92892. private _noUBO;
  92893. private _currentEffect;
  92894. private static _MAX_UNIFORM_SIZE;
  92895. private static _tempBuffer;
  92896. /**
  92897. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92898. * This is dynamic to allow compat with webgl 1 and 2.
  92899. * You will need to pass the name of the uniform as well as the value.
  92900. */
  92901. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92902. /**
  92903. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92904. * This is dynamic to allow compat with webgl 1 and 2.
  92905. * You will need to pass the name of the uniform as well as the value.
  92906. */
  92907. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92908. /**
  92909. * Lambda to Update a single float in a uniform buffer.
  92910. * This is dynamic to allow compat with webgl 1 and 2.
  92911. * You will need to pass the name of the uniform as well as the value.
  92912. */
  92913. updateFloat: (name: string, x: number) => void;
  92914. /**
  92915. * Lambda to Update a vec2 of float in a uniform buffer.
  92916. * This is dynamic to allow compat with webgl 1 and 2.
  92917. * You will need to pass the name of the uniform as well as the value.
  92918. */
  92919. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92920. /**
  92921. * Lambda to Update a vec3 of float in a uniform buffer.
  92922. * This is dynamic to allow compat with webgl 1 and 2.
  92923. * You will need to pass the name of the uniform as well as the value.
  92924. */
  92925. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92926. /**
  92927. * Lambda to Update a vec4 of float in a uniform buffer.
  92928. * This is dynamic to allow compat with webgl 1 and 2.
  92929. * You will need to pass the name of the uniform as well as the value.
  92930. */
  92931. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92932. /**
  92933. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92934. * This is dynamic to allow compat with webgl 1 and 2.
  92935. * You will need to pass the name of the uniform as well as the value.
  92936. */
  92937. updateMatrix: (name: string, mat: Matrix) => void;
  92938. /**
  92939. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92940. * This is dynamic to allow compat with webgl 1 and 2.
  92941. * You will need to pass the name of the uniform as well as the value.
  92942. */
  92943. updateVector3: (name: string, vector: Vector3) => void;
  92944. /**
  92945. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92946. * This is dynamic to allow compat with webgl 1 and 2.
  92947. * You will need to pass the name of the uniform as well as the value.
  92948. */
  92949. updateVector4: (name: string, vector: Vector4) => void;
  92950. /**
  92951. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92952. * This is dynamic to allow compat with webgl 1 and 2.
  92953. * You will need to pass the name of the uniform as well as the value.
  92954. */
  92955. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92956. /**
  92957. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92958. * This is dynamic to allow compat with webgl 1 and 2.
  92959. * You will need to pass the name of the uniform as well as the value.
  92960. */
  92961. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92962. /**
  92963. * Instantiates a new Uniform buffer objects.
  92964. *
  92965. * Handles blocks of uniform on the GPU.
  92966. *
  92967. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92968. *
  92969. * For more information, please refer to :
  92970. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92971. * @param engine Define the engine the buffer is associated with
  92972. * @param data Define the data contained in the buffer
  92973. * @param dynamic Define if the buffer is updatable
  92974. */
  92975. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92976. /**
  92977. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92978. * or just falling back on setUniformXXX calls.
  92979. */
  92980. readonly useUbo: boolean;
  92981. /**
  92982. * Indicates if the WebGL underlying uniform buffer is in sync
  92983. * with the javascript cache data.
  92984. */
  92985. readonly isSync: boolean;
  92986. /**
  92987. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92988. * Also, a dynamic UniformBuffer will disable cache verification and always
  92989. * update the underlying WebGL uniform buffer to the GPU.
  92990. * @returns if Dynamic, otherwise false
  92991. */
  92992. isDynamic(): boolean;
  92993. /**
  92994. * The data cache on JS side.
  92995. * @returns the underlying data as a float array
  92996. */
  92997. getData(): Float32Array;
  92998. /**
  92999. * The underlying WebGL Uniform buffer.
  93000. * @returns the webgl buffer
  93001. */
  93002. getBuffer(): Nullable<DataBuffer>;
  93003. /**
  93004. * std140 layout specifies how to align data within an UBO structure.
  93005. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  93006. * for specs.
  93007. */
  93008. private _fillAlignment;
  93009. /**
  93010. * Adds an uniform in the buffer.
  93011. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  93012. * for the layout to be correct !
  93013. * @param name Name of the uniform, as used in the uniform block in the shader.
  93014. * @param size Data size, or data directly.
  93015. */
  93016. addUniform(name: string, size: number | number[]): void;
  93017. /**
  93018. * Adds a Matrix 4x4 to the uniform buffer.
  93019. * @param name Name of the uniform, as used in the uniform block in the shader.
  93020. * @param mat A 4x4 matrix.
  93021. */
  93022. addMatrix(name: string, mat: Matrix): void;
  93023. /**
  93024. * Adds a vec2 to the uniform buffer.
  93025. * @param name Name of the uniform, as used in the uniform block in the shader.
  93026. * @param x Define the x component value of the vec2
  93027. * @param y Define the y component value of the vec2
  93028. */
  93029. addFloat2(name: string, x: number, y: number): void;
  93030. /**
  93031. * Adds a vec3 to the uniform buffer.
  93032. * @param name Name of the uniform, as used in the uniform block in the shader.
  93033. * @param x Define the x component value of the vec3
  93034. * @param y Define the y component value of the vec3
  93035. * @param z Define the z component value of the vec3
  93036. */
  93037. addFloat3(name: string, x: number, y: number, z: number): void;
  93038. /**
  93039. * Adds a vec3 to the uniform buffer.
  93040. * @param name Name of the uniform, as used in the uniform block in the shader.
  93041. * @param color Define the vec3 from a Color
  93042. */
  93043. addColor3(name: string, color: Color3): void;
  93044. /**
  93045. * Adds a vec4 to the uniform buffer.
  93046. * @param name Name of the uniform, as used in the uniform block in the shader.
  93047. * @param color Define the rgb components from a Color
  93048. * @param alpha Define the a component of the vec4
  93049. */
  93050. addColor4(name: string, color: Color3, alpha: number): void;
  93051. /**
  93052. * Adds a vec3 to the uniform buffer.
  93053. * @param name Name of the uniform, as used in the uniform block in the shader.
  93054. * @param vector Define the vec3 components from a Vector
  93055. */
  93056. addVector3(name: string, vector: Vector3): void;
  93057. /**
  93058. * Adds a Matrix 3x3 to the uniform buffer.
  93059. * @param name Name of the uniform, as used in the uniform block in the shader.
  93060. */
  93061. addMatrix3x3(name: string): void;
  93062. /**
  93063. * Adds a Matrix 2x2 to the uniform buffer.
  93064. * @param name Name of the uniform, as used in the uniform block in the shader.
  93065. */
  93066. addMatrix2x2(name: string): void;
  93067. /**
  93068. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  93069. */
  93070. create(): void;
  93071. /** @hidden */
  93072. _rebuild(): void;
  93073. /**
  93074. * Updates the WebGL Uniform Buffer on the GPU.
  93075. * If the `dynamic` flag is set to true, no cache comparison is done.
  93076. * Otherwise, the buffer will be updated only if the cache differs.
  93077. */
  93078. update(): void;
  93079. /**
  93080. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  93081. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93082. * @param data Define the flattened data
  93083. * @param size Define the size of the data.
  93084. */
  93085. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  93086. private _updateMatrix3x3ForUniform;
  93087. private _updateMatrix3x3ForEffect;
  93088. private _updateMatrix2x2ForEffect;
  93089. private _updateMatrix2x2ForUniform;
  93090. private _updateFloatForEffect;
  93091. private _updateFloatForUniform;
  93092. private _updateFloat2ForEffect;
  93093. private _updateFloat2ForUniform;
  93094. private _updateFloat3ForEffect;
  93095. private _updateFloat3ForUniform;
  93096. private _updateFloat4ForEffect;
  93097. private _updateFloat4ForUniform;
  93098. private _updateMatrixForEffect;
  93099. private _updateMatrixForUniform;
  93100. private _updateVector3ForEffect;
  93101. private _updateVector3ForUniform;
  93102. private _updateVector4ForEffect;
  93103. private _updateVector4ForUniform;
  93104. private _updateColor3ForEffect;
  93105. private _updateColor3ForUniform;
  93106. private _updateColor4ForEffect;
  93107. private _updateColor4ForUniform;
  93108. /**
  93109. * Sets a sampler uniform on the effect.
  93110. * @param name Define the name of the sampler.
  93111. * @param texture Define the texture to set in the sampler
  93112. */
  93113. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  93114. /**
  93115. * Directly updates the value of the uniform in the cache AND on the GPU.
  93116. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  93117. * @param data Define the flattened data
  93118. */
  93119. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  93120. /**
  93121. * Binds this uniform buffer to an effect.
  93122. * @param effect Define the effect to bind the buffer to
  93123. * @param name Name of the uniform block in the shader.
  93124. */
  93125. bindToEffect(effect: Effect, name: string): void;
  93126. /**
  93127. * Disposes the uniform buffer.
  93128. */
  93129. dispose(): void;
  93130. }
  93131. }
  93132. declare module BABYLON {
  93133. /**
  93134. * Class used to work with sound analyzer using fast fourier transform (FFT)
  93135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93136. */
  93137. export class Analyser {
  93138. /**
  93139. * Gets or sets the smoothing
  93140. * @ignorenaming
  93141. */
  93142. SMOOTHING: number;
  93143. /**
  93144. * Gets or sets the FFT table size
  93145. * @ignorenaming
  93146. */
  93147. FFT_SIZE: number;
  93148. /**
  93149. * Gets or sets the bar graph amplitude
  93150. * @ignorenaming
  93151. */
  93152. BARGRAPHAMPLITUDE: number;
  93153. /**
  93154. * Gets or sets the position of the debug canvas
  93155. * @ignorenaming
  93156. */
  93157. DEBUGCANVASPOS: {
  93158. x: number;
  93159. y: number;
  93160. };
  93161. /**
  93162. * Gets or sets the debug canvas size
  93163. * @ignorenaming
  93164. */
  93165. DEBUGCANVASSIZE: {
  93166. width: number;
  93167. height: number;
  93168. };
  93169. private _byteFreqs;
  93170. private _byteTime;
  93171. private _floatFreqs;
  93172. private _webAudioAnalyser;
  93173. private _debugCanvas;
  93174. private _debugCanvasContext;
  93175. private _scene;
  93176. private _registerFunc;
  93177. private _audioEngine;
  93178. /**
  93179. * Creates a new analyser
  93180. * @param scene defines hosting scene
  93181. */
  93182. constructor(scene: Scene);
  93183. /**
  93184. * Get the number of data values you will have to play with for the visualization
  93185. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  93186. * @returns a number
  93187. */
  93188. getFrequencyBinCount(): number;
  93189. /**
  93190. * Gets the current frequency data as a byte array
  93191. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93192. * @returns a Uint8Array
  93193. */
  93194. getByteFrequencyData(): Uint8Array;
  93195. /**
  93196. * Gets the current waveform as a byte array
  93197. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  93198. * @returns a Uint8Array
  93199. */
  93200. getByteTimeDomainData(): Uint8Array;
  93201. /**
  93202. * Gets the current frequency data as a float array
  93203. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  93204. * @returns a Float32Array
  93205. */
  93206. getFloatFrequencyData(): Float32Array;
  93207. /**
  93208. * Renders the debug canvas
  93209. */
  93210. drawDebugCanvas(): void;
  93211. /**
  93212. * Stops rendering the debug canvas and removes it
  93213. */
  93214. stopDebugCanvas(): void;
  93215. /**
  93216. * Connects two audio nodes
  93217. * @param inputAudioNode defines first node to connect
  93218. * @param outputAudioNode defines second node to connect
  93219. */
  93220. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  93221. /**
  93222. * Releases all associated resources
  93223. */
  93224. dispose(): void;
  93225. }
  93226. }
  93227. declare module BABYLON {
  93228. /**
  93229. * This represents an audio engine and it is responsible
  93230. * to play, synchronize and analyse sounds throughout the application.
  93231. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93232. */
  93233. export interface IAudioEngine extends IDisposable {
  93234. /**
  93235. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93236. */
  93237. readonly canUseWebAudio: boolean;
  93238. /**
  93239. * Gets the current AudioContext if available.
  93240. */
  93241. readonly audioContext: Nullable<AudioContext>;
  93242. /**
  93243. * The master gain node defines the global audio volume of your audio engine.
  93244. */
  93245. readonly masterGain: GainNode;
  93246. /**
  93247. * Gets whether or not mp3 are supported by your browser.
  93248. */
  93249. readonly isMP3supported: boolean;
  93250. /**
  93251. * Gets whether or not ogg are supported by your browser.
  93252. */
  93253. readonly isOGGsupported: boolean;
  93254. /**
  93255. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93256. * @ignoreNaming
  93257. */
  93258. WarnedWebAudioUnsupported: boolean;
  93259. /**
  93260. * Defines if the audio engine relies on a custom unlocked button.
  93261. * In this case, the embedded button will not be displayed.
  93262. */
  93263. useCustomUnlockedButton: boolean;
  93264. /**
  93265. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  93266. */
  93267. readonly unlocked: boolean;
  93268. /**
  93269. * Event raised when audio has been unlocked on the browser.
  93270. */
  93271. onAudioUnlockedObservable: Observable<AudioEngine>;
  93272. /**
  93273. * Event raised when audio has been locked on the browser.
  93274. */
  93275. onAudioLockedObservable: Observable<AudioEngine>;
  93276. /**
  93277. * Flags the audio engine in Locked state.
  93278. * This happens due to new browser policies preventing audio to autoplay.
  93279. */
  93280. lock(): void;
  93281. /**
  93282. * Unlocks the audio engine once a user action has been done on the dom.
  93283. * This is helpful to resume play once browser policies have been satisfied.
  93284. */
  93285. unlock(): void;
  93286. }
  93287. /**
  93288. * This represents the default audio engine used in babylon.
  93289. * It is responsible to play, synchronize and analyse sounds throughout the application.
  93290. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93291. */
  93292. export class AudioEngine implements IAudioEngine {
  93293. private _audioContext;
  93294. private _audioContextInitialized;
  93295. private _muteButton;
  93296. private _hostElement;
  93297. /**
  93298. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  93299. */
  93300. canUseWebAudio: boolean;
  93301. /**
  93302. * The master gain node defines the global audio volume of your audio engine.
  93303. */
  93304. masterGain: GainNode;
  93305. /**
  93306. * Defines if Babylon should emit a warning if WebAudio is not supported.
  93307. * @ignoreNaming
  93308. */
  93309. WarnedWebAudioUnsupported: boolean;
  93310. /**
  93311. * Gets whether or not mp3 are supported by your browser.
  93312. */
  93313. isMP3supported: boolean;
  93314. /**
  93315. * Gets whether or not ogg are supported by your browser.
  93316. */
  93317. isOGGsupported: boolean;
  93318. /**
  93319. * Gets whether audio has been unlocked on the device.
  93320. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  93321. * a user interaction has happened.
  93322. */
  93323. unlocked: boolean;
  93324. /**
  93325. * Defines if the audio engine relies on a custom unlocked button.
  93326. * In this case, the embedded button will not be displayed.
  93327. */
  93328. useCustomUnlockedButton: boolean;
  93329. /**
  93330. * Event raised when audio has been unlocked on the browser.
  93331. */
  93332. onAudioUnlockedObservable: Observable<AudioEngine>;
  93333. /**
  93334. * Event raised when audio has been locked on the browser.
  93335. */
  93336. onAudioLockedObservable: Observable<AudioEngine>;
  93337. /**
  93338. * Gets the current AudioContext if available.
  93339. */
  93340. readonly audioContext: Nullable<AudioContext>;
  93341. private _connectedAnalyser;
  93342. /**
  93343. * Instantiates a new audio engine.
  93344. *
  93345. * There should be only one per page as some browsers restrict the number
  93346. * of audio contexts you can create.
  93347. * @param hostElement defines the host element where to display the mute icon if necessary
  93348. */
  93349. constructor(hostElement?: Nullable<HTMLElement>);
  93350. /**
  93351. * Flags the audio engine in Locked state.
  93352. * This happens due to new browser policies preventing audio to autoplay.
  93353. */
  93354. lock(): void;
  93355. /**
  93356. * Unlocks the audio engine once a user action has been done on the dom.
  93357. * This is helpful to resume play once browser policies have been satisfied.
  93358. */
  93359. unlock(): void;
  93360. private _resumeAudioContext;
  93361. private _initializeAudioContext;
  93362. private _tryToRun;
  93363. private _triggerRunningState;
  93364. private _triggerSuspendedState;
  93365. private _displayMuteButton;
  93366. private _moveButtonToTopLeft;
  93367. private _onResize;
  93368. private _hideMuteButton;
  93369. /**
  93370. * Destroy and release the resources associated with the audio ccontext.
  93371. */
  93372. dispose(): void;
  93373. /**
  93374. * Gets the global volume sets on the master gain.
  93375. * @returns the global volume if set or -1 otherwise
  93376. */
  93377. getGlobalVolume(): number;
  93378. /**
  93379. * Sets the global volume of your experience (sets on the master gain).
  93380. * @param newVolume Defines the new global volume of the application
  93381. */
  93382. setGlobalVolume(newVolume: number): void;
  93383. /**
  93384. * Connect the audio engine to an audio analyser allowing some amazing
  93385. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93387. * @param analyser The analyser to connect to the engine
  93388. */
  93389. connectToAnalyser(analyser: Analyser): void;
  93390. }
  93391. }
  93392. declare module BABYLON {
  93393. /**
  93394. * Interface used to present a loading screen while loading a scene
  93395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93396. */
  93397. export interface ILoadingScreen {
  93398. /**
  93399. * Function called to display the loading screen
  93400. */
  93401. displayLoadingUI: () => void;
  93402. /**
  93403. * Function called to hide the loading screen
  93404. */
  93405. hideLoadingUI: () => void;
  93406. /**
  93407. * Gets or sets the color to use for the background
  93408. */
  93409. loadingUIBackgroundColor: string;
  93410. /**
  93411. * Gets or sets the text to display while loading
  93412. */
  93413. loadingUIText: string;
  93414. }
  93415. /**
  93416. * Class used for the default loading screen
  93417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93418. */
  93419. export class DefaultLoadingScreen implements ILoadingScreen {
  93420. private _renderingCanvas;
  93421. private _loadingText;
  93422. private _loadingDivBackgroundColor;
  93423. private _loadingDiv;
  93424. private _loadingTextDiv;
  93425. /** Gets or sets the logo url to use for the default loading screen */
  93426. static DefaultLogoUrl: string;
  93427. /** Gets or sets the spinner url to use for the default loading screen */
  93428. static DefaultSpinnerUrl: string;
  93429. /**
  93430. * Creates a new default loading screen
  93431. * @param _renderingCanvas defines the canvas used to render the scene
  93432. * @param _loadingText defines the default text to display
  93433. * @param _loadingDivBackgroundColor defines the default background color
  93434. */
  93435. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93436. /**
  93437. * Function called to display the loading screen
  93438. */
  93439. displayLoadingUI(): void;
  93440. /**
  93441. * Function called to hide the loading screen
  93442. */
  93443. hideLoadingUI(): void;
  93444. /**
  93445. * Gets or sets the text to display while loading
  93446. */
  93447. loadingUIText: string;
  93448. /**
  93449. * Gets or sets the color to use for the background
  93450. */
  93451. loadingUIBackgroundColor: string;
  93452. private _resizeLoadingUI;
  93453. }
  93454. }
  93455. declare module BABYLON {
  93456. /** @hidden */
  93457. export class WebGLPipelineContext implements IPipelineContext {
  93458. engine: Engine;
  93459. program: Nullable<WebGLProgram>;
  93460. context?: WebGLRenderingContext;
  93461. vertexShader?: WebGLShader;
  93462. fragmentShader?: WebGLShader;
  93463. isParallelCompiled: boolean;
  93464. onCompiled?: () => void;
  93465. transformFeedback?: WebGLTransformFeedback | null;
  93466. readonly isAsync: boolean;
  93467. readonly isReady: boolean;
  93468. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93469. }
  93470. }
  93471. declare module BABYLON {
  93472. /** @hidden */
  93473. export class WebGLDataBuffer extends DataBuffer {
  93474. private _buffer;
  93475. constructor(resource: WebGLBuffer);
  93476. readonly underlyingResource: any;
  93477. }
  93478. }
  93479. declare module BABYLON {
  93480. /** @hidden */
  93481. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93482. attributeProcessor(attribute: string): string;
  93483. varyingProcessor(varying: string, isFragment: boolean): string;
  93484. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93485. }
  93486. }
  93487. declare module BABYLON {
  93488. /**
  93489. * This class is used to track a performance counter which is number based.
  93490. * The user has access to many properties which give statistics of different nature.
  93491. *
  93492. * The implementer can track two kinds of Performance Counter: time and count.
  93493. * 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.
  93494. * 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.
  93495. */
  93496. export class PerfCounter {
  93497. /**
  93498. * Gets or sets a global boolean to turn on and off all the counters
  93499. */
  93500. static Enabled: boolean;
  93501. /**
  93502. * Returns the smallest value ever
  93503. */
  93504. readonly min: number;
  93505. /**
  93506. * Returns the biggest value ever
  93507. */
  93508. readonly max: number;
  93509. /**
  93510. * Returns the average value since the performance counter is running
  93511. */
  93512. readonly average: number;
  93513. /**
  93514. * Returns the average value of the last second the counter was monitored
  93515. */
  93516. readonly lastSecAverage: number;
  93517. /**
  93518. * Returns the current value
  93519. */
  93520. readonly current: number;
  93521. /**
  93522. * Gets the accumulated total
  93523. */
  93524. readonly total: number;
  93525. /**
  93526. * Gets the total value count
  93527. */
  93528. readonly count: number;
  93529. /**
  93530. * Creates a new counter
  93531. */
  93532. constructor();
  93533. /**
  93534. * Call this method to start monitoring a new frame.
  93535. * 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.
  93536. */
  93537. fetchNewFrame(): void;
  93538. /**
  93539. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93540. * @param newCount the count value to add to the monitored count
  93541. * @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.
  93542. */
  93543. addCount(newCount: number, fetchResult: boolean): void;
  93544. /**
  93545. * Start monitoring this performance counter
  93546. */
  93547. beginMonitoring(): void;
  93548. /**
  93549. * Compute the time lapsed since the previous beginMonitoring() call.
  93550. * @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
  93551. */
  93552. endMonitoring(newFrame?: boolean): void;
  93553. private _fetchResult;
  93554. private _startMonitoringTime;
  93555. private _min;
  93556. private _max;
  93557. private _average;
  93558. private _current;
  93559. private _totalValueCount;
  93560. private _totalAccumulated;
  93561. private _lastSecAverage;
  93562. private _lastSecAccumulated;
  93563. private _lastSecTime;
  93564. private _lastSecValueCount;
  93565. }
  93566. }
  93567. declare module BABYLON {
  93568. /**
  93569. * Interface for any object that can request an animation frame
  93570. */
  93571. export interface ICustomAnimationFrameRequester {
  93572. /**
  93573. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93574. */
  93575. renderFunction?: Function;
  93576. /**
  93577. * Called to request the next frame to render to
  93578. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93579. */
  93580. requestAnimationFrame: Function;
  93581. /**
  93582. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93583. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93584. */
  93585. requestID?: number;
  93586. }
  93587. }
  93588. declare module BABYLON {
  93589. /**
  93590. * Settings for finer control over video usage
  93591. */
  93592. export interface VideoTextureSettings {
  93593. /**
  93594. * Applies `autoplay` to video, if specified
  93595. */
  93596. autoPlay?: boolean;
  93597. /**
  93598. * Applies `loop` to video, if specified
  93599. */
  93600. loop?: boolean;
  93601. /**
  93602. * Automatically updates internal texture from video at every frame in the render loop
  93603. */
  93604. autoUpdateTexture: boolean;
  93605. /**
  93606. * Image src displayed during the video loading or until the user interacts with the video.
  93607. */
  93608. poster?: string;
  93609. }
  93610. /**
  93611. * If you want to display a video in your scene, this is the special texture for that.
  93612. * This special texture works similar to other textures, with the exception of a few parameters.
  93613. * @see https://doc.babylonjs.com/how_to/video_texture
  93614. */
  93615. export class VideoTexture extends Texture {
  93616. /**
  93617. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93618. */
  93619. readonly autoUpdateTexture: boolean;
  93620. /**
  93621. * The video instance used by the texture internally
  93622. */
  93623. readonly video: HTMLVideoElement;
  93624. private _onUserActionRequestedObservable;
  93625. /**
  93626. * Event triggerd when a dom action is required by the user to play the video.
  93627. * This happens due to recent changes in browser policies preventing video to auto start.
  93628. */
  93629. readonly onUserActionRequestedObservable: Observable<Texture>;
  93630. private _generateMipMaps;
  93631. private _engine;
  93632. private _stillImageCaptured;
  93633. private _displayingPosterTexture;
  93634. private _settings;
  93635. private _createInternalTextureOnEvent;
  93636. /**
  93637. * Creates a video texture.
  93638. * If you want to display a video in your scene, this is the special texture for that.
  93639. * This special texture works similar to other textures, with the exception of a few parameters.
  93640. * @see https://doc.babylonjs.com/how_to/video_texture
  93641. * @param name optional name, will detect from video source, if not defined
  93642. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93643. * @param scene is obviously the current scene.
  93644. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93645. * @param invertY is false by default but can be used to invert video on Y axis
  93646. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93647. * @param settings allows finer control over video usage
  93648. */
  93649. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93650. private _getName;
  93651. private _getVideo;
  93652. private _createInternalTexture;
  93653. private reset;
  93654. /**
  93655. * @hidden Internal method to initiate `update`.
  93656. */
  93657. _rebuild(): void;
  93658. /**
  93659. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93660. */
  93661. update(): void;
  93662. /**
  93663. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93664. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93665. */
  93666. updateTexture(isVisible: boolean): void;
  93667. protected _updateInternalTexture: () => void;
  93668. /**
  93669. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93670. * @param url New url.
  93671. */
  93672. updateURL(url: string): void;
  93673. /**
  93674. * Dispose the texture and release its associated resources.
  93675. */
  93676. dispose(): void;
  93677. /**
  93678. * Creates a video texture straight from a stream.
  93679. * @param scene Define the scene the texture should be created in
  93680. * @param stream Define the stream the texture should be created from
  93681. * @returns The created video texture as a promise
  93682. */
  93683. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93684. /**
  93685. * Creates a video texture straight from your WebCam video feed.
  93686. * @param scene Define the scene the texture should be created in
  93687. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93688. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93689. * @returns The created video texture as a promise
  93690. */
  93691. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93692. minWidth: number;
  93693. maxWidth: number;
  93694. minHeight: number;
  93695. maxHeight: number;
  93696. deviceId: string;
  93697. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93698. /**
  93699. * Creates a video texture straight from your WebCam video feed.
  93700. * @param scene Define the scene the texture should be created in
  93701. * @param onReady Define a callback to triggered once the texture will be ready
  93702. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93703. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93704. */
  93705. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93706. minWidth: number;
  93707. maxWidth: number;
  93708. minHeight: number;
  93709. maxHeight: number;
  93710. deviceId: string;
  93711. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93712. }
  93713. }
  93714. declare module BABYLON {
  93715. /**
  93716. * Defines the interface used by objects containing a viewport (like a camera)
  93717. */
  93718. interface IViewportOwnerLike {
  93719. /**
  93720. * Gets or sets the viewport
  93721. */
  93722. viewport: IViewportLike;
  93723. }
  93724. /**
  93725. * Interface for attribute information associated with buffer instanciation
  93726. */
  93727. export class InstancingAttributeInfo {
  93728. /**
  93729. * Index/offset of the attribute in the vertex shader
  93730. */
  93731. index: number;
  93732. /**
  93733. * size of the attribute, 1, 2, 3 or 4
  93734. */
  93735. attributeSize: number;
  93736. /**
  93737. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93738. * default is FLOAT
  93739. */
  93740. attribyteType: number;
  93741. /**
  93742. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93743. */
  93744. normalized: boolean;
  93745. /**
  93746. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93747. */
  93748. offset: number;
  93749. /**
  93750. * Name of the GLSL attribute, for debugging purpose only
  93751. */
  93752. attributeName: string;
  93753. }
  93754. /**
  93755. * Define options used to create a depth texture
  93756. */
  93757. export class DepthTextureCreationOptions {
  93758. /** Specifies whether or not a stencil should be allocated in the texture */
  93759. generateStencil?: boolean;
  93760. /** Specifies whether or not bilinear filtering is enable on the texture */
  93761. bilinearFiltering?: boolean;
  93762. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93763. comparisonFunction?: number;
  93764. /** Specifies if the created texture is a cube texture */
  93765. isCube?: boolean;
  93766. }
  93767. /**
  93768. * Class used to describe the capabilities of the engine relatively to the current browser
  93769. */
  93770. export class EngineCapabilities {
  93771. /** Maximum textures units per fragment shader */
  93772. maxTexturesImageUnits: number;
  93773. /** Maximum texture units per vertex shader */
  93774. maxVertexTextureImageUnits: number;
  93775. /** Maximum textures units in the entire pipeline */
  93776. maxCombinedTexturesImageUnits: number;
  93777. /** Maximum texture size */
  93778. maxTextureSize: number;
  93779. /** Maximum cube texture size */
  93780. maxCubemapTextureSize: number;
  93781. /** Maximum render texture size */
  93782. maxRenderTextureSize: number;
  93783. /** Maximum number of vertex attributes */
  93784. maxVertexAttribs: number;
  93785. /** Maximum number of varyings */
  93786. maxVaryingVectors: number;
  93787. /** Maximum number of uniforms per vertex shader */
  93788. maxVertexUniformVectors: number;
  93789. /** Maximum number of uniforms per fragment shader */
  93790. maxFragmentUniformVectors: number;
  93791. /** Defines if standard derivates (dx/dy) are supported */
  93792. standardDerivatives: boolean;
  93793. /** Defines if s3tc texture compression is supported */
  93794. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93795. /** Defines if pvrtc texture compression is supported */
  93796. pvrtc: any;
  93797. /** Defines if etc1 texture compression is supported */
  93798. etc1: any;
  93799. /** Defines if etc2 texture compression is supported */
  93800. etc2: any;
  93801. /** Defines if astc texture compression is supported */
  93802. astc: any;
  93803. /** Defines if float textures are supported */
  93804. textureFloat: boolean;
  93805. /** Defines if vertex array objects are supported */
  93806. vertexArrayObject: boolean;
  93807. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93808. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93809. /** Gets the maximum level of anisotropy supported */
  93810. maxAnisotropy: number;
  93811. /** Defines if instancing is supported */
  93812. instancedArrays: boolean;
  93813. /** Defines if 32 bits indices are supported */
  93814. uintIndices: boolean;
  93815. /** Defines if high precision shaders are supported */
  93816. highPrecisionShaderSupported: boolean;
  93817. /** Defines if depth reading in the fragment shader is supported */
  93818. fragmentDepthSupported: boolean;
  93819. /** Defines if float texture linear filtering is supported*/
  93820. textureFloatLinearFiltering: boolean;
  93821. /** Defines if rendering to float textures is supported */
  93822. textureFloatRender: boolean;
  93823. /** Defines if half float textures are supported*/
  93824. textureHalfFloat: boolean;
  93825. /** Defines if half float texture linear filtering is supported*/
  93826. textureHalfFloatLinearFiltering: boolean;
  93827. /** Defines if rendering to half float textures is supported */
  93828. textureHalfFloatRender: boolean;
  93829. /** Defines if textureLOD shader command is supported */
  93830. textureLOD: boolean;
  93831. /** Defines if draw buffers extension is supported */
  93832. drawBuffersExtension: boolean;
  93833. /** Defines if depth textures are supported */
  93834. depthTextureExtension: boolean;
  93835. /** Defines if float color buffer are supported */
  93836. colorBufferFloat: boolean;
  93837. /** Gets disjoint timer query extension (null if not supported) */
  93838. timerQuery: EXT_disjoint_timer_query;
  93839. /** Defines if timestamp can be used with timer query */
  93840. canUseTimestampForTimerQuery: boolean;
  93841. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93842. multiview: any;
  93843. /** Function used to let the system compiles shaders in background */
  93844. parallelShaderCompile: {
  93845. COMPLETION_STATUS_KHR: number;
  93846. };
  93847. /** Max number of texture samples for MSAA */
  93848. maxMSAASamples: number;
  93849. }
  93850. /** Interface defining initialization parameters for Engine class */
  93851. export interface EngineOptions extends WebGLContextAttributes {
  93852. /**
  93853. * Defines if the engine should no exceed a specified device ratio
  93854. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93855. */
  93856. limitDeviceRatio?: number;
  93857. /**
  93858. * Defines if webvr should be enabled automatically
  93859. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93860. */
  93861. autoEnableWebVR?: boolean;
  93862. /**
  93863. * Defines if webgl2 should be turned off even if supported
  93864. * @see http://doc.babylonjs.com/features/webgl2
  93865. */
  93866. disableWebGL2Support?: boolean;
  93867. /**
  93868. * Defines if webaudio should be initialized as well
  93869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93870. */
  93871. audioEngine?: boolean;
  93872. /**
  93873. * Defines if animations should run using a deterministic lock step
  93874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93875. */
  93876. deterministicLockstep?: boolean;
  93877. /** Defines the maximum steps to use with deterministic lock step mode */
  93878. lockstepMaxSteps?: number;
  93879. /**
  93880. * Defines that engine should ignore context lost events
  93881. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93882. */
  93883. doNotHandleContextLost?: boolean;
  93884. /**
  93885. * Defines that engine should ignore modifying touch action attribute and style
  93886. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93887. */
  93888. doNotHandleTouchAction?: boolean;
  93889. /**
  93890. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93891. */
  93892. useHighPrecisionFloats?: boolean;
  93893. }
  93894. /**
  93895. * Defines the interface used by display changed events
  93896. */
  93897. export interface IDisplayChangedEventArgs {
  93898. /** Gets the vrDisplay object (if any) */
  93899. vrDisplay: Nullable<any>;
  93900. /** Gets a boolean indicating if webVR is supported */
  93901. vrSupported: boolean;
  93902. }
  93903. /**
  93904. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93905. */
  93906. export class Engine {
  93907. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93908. static ExceptionList: ({
  93909. key: string;
  93910. capture: string;
  93911. captureConstraint: number;
  93912. targets: string[];
  93913. } | {
  93914. key: string;
  93915. capture: null;
  93916. captureConstraint: null;
  93917. targets: string[];
  93918. })[];
  93919. /** Gets the list of created engines */
  93920. static readonly Instances: Engine[];
  93921. /**
  93922. * Gets the latest created engine
  93923. */
  93924. static readonly LastCreatedEngine: Nullable<Engine>;
  93925. /**
  93926. * Gets the latest created scene
  93927. */
  93928. static readonly LastCreatedScene: Nullable<Scene>;
  93929. /**
  93930. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93931. * @param flag defines which part of the materials must be marked as dirty
  93932. * @param predicate defines a predicate used to filter which materials should be affected
  93933. */
  93934. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93935. /** @hidden */
  93936. static _TextureLoaders: IInternalTextureLoader[];
  93937. /** Defines that alpha blending is disabled */
  93938. static readonly ALPHA_DISABLE: number;
  93939. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93940. static readonly ALPHA_ADD: number;
  93941. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93942. static readonly ALPHA_COMBINE: number;
  93943. /** Defines that alpha blending to DEST - SRC * DEST */
  93944. static readonly ALPHA_SUBTRACT: number;
  93945. /** Defines that alpha blending to SRC * DEST */
  93946. static readonly ALPHA_MULTIPLY: number;
  93947. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93948. static readonly ALPHA_MAXIMIZED: number;
  93949. /** Defines that alpha blending to SRC + DEST */
  93950. static readonly ALPHA_ONEONE: number;
  93951. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93952. static readonly ALPHA_PREMULTIPLIED: number;
  93953. /**
  93954. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93955. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93956. */
  93957. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93958. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93959. static readonly ALPHA_INTERPOLATE: number;
  93960. /**
  93961. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93962. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93963. */
  93964. static readonly ALPHA_SCREENMODE: number;
  93965. /** Defines that the ressource is not delayed*/
  93966. static readonly DELAYLOADSTATE_NONE: number;
  93967. /** Defines that the ressource was successfully delay loaded */
  93968. static readonly DELAYLOADSTATE_LOADED: number;
  93969. /** Defines that the ressource is currently delay loading */
  93970. static readonly DELAYLOADSTATE_LOADING: number;
  93971. /** Defines that the ressource is delayed and has not started loading */
  93972. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93973. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93974. static readonly NEVER: number;
  93975. /** 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 */
  93976. static readonly ALWAYS: number;
  93977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93978. static readonly LESS: number;
  93979. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93980. static readonly EQUAL: number;
  93981. /** 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 */
  93982. static readonly LEQUAL: number;
  93983. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93984. static readonly GREATER: number;
  93985. /** 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 */
  93986. static readonly GEQUAL: number;
  93987. /** 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 */
  93988. static readonly NOTEQUAL: number;
  93989. /** Passed to stencilOperation to specify that stencil value must be kept */
  93990. static readonly KEEP: number;
  93991. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93992. static readonly REPLACE: number;
  93993. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93994. static readonly INCR: number;
  93995. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93996. static readonly DECR: number;
  93997. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93998. static readonly INVERT: number;
  93999. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  94000. static readonly INCR_WRAP: number;
  94001. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  94002. static readonly DECR_WRAP: number;
  94003. /** Texture is not repeating outside of 0..1 UVs */
  94004. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  94005. /** Texture is repeating outside of 0..1 UVs */
  94006. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  94007. /** Texture is repeating and mirrored */
  94008. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  94009. /** ALPHA */
  94010. static readonly TEXTUREFORMAT_ALPHA: number;
  94011. /** LUMINANCE */
  94012. static readonly TEXTUREFORMAT_LUMINANCE: number;
  94013. /** LUMINANCE_ALPHA */
  94014. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  94015. /** RGB */
  94016. static readonly TEXTUREFORMAT_RGB: number;
  94017. /** RGBA */
  94018. static readonly TEXTUREFORMAT_RGBA: number;
  94019. /** RED */
  94020. static readonly TEXTUREFORMAT_RED: number;
  94021. /** RED (2nd reference) */
  94022. static readonly TEXTUREFORMAT_R: number;
  94023. /** RG */
  94024. static readonly TEXTUREFORMAT_RG: number;
  94025. /** RED_INTEGER */
  94026. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  94027. /** RED_INTEGER (2nd reference) */
  94028. static readonly TEXTUREFORMAT_R_INTEGER: number;
  94029. /** RG_INTEGER */
  94030. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  94031. /** RGB_INTEGER */
  94032. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  94033. /** RGBA_INTEGER */
  94034. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  94035. /** UNSIGNED_BYTE */
  94036. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  94037. /** UNSIGNED_BYTE (2nd reference) */
  94038. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  94039. /** FLOAT */
  94040. static readonly TEXTURETYPE_FLOAT: number;
  94041. /** HALF_FLOAT */
  94042. static readonly TEXTURETYPE_HALF_FLOAT: number;
  94043. /** BYTE */
  94044. static readonly TEXTURETYPE_BYTE: number;
  94045. /** SHORT */
  94046. static readonly TEXTURETYPE_SHORT: number;
  94047. /** UNSIGNED_SHORT */
  94048. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  94049. /** INT */
  94050. static readonly TEXTURETYPE_INT: number;
  94051. /** UNSIGNED_INT */
  94052. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  94053. /** UNSIGNED_SHORT_4_4_4_4 */
  94054. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  94055. /** UNSIGNED_SHORT_5_5_5_1 */
  94056. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  94057. /** UNSIGNED_SHORT_5_6_5 */
  94058. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  94059. /** UNSIGNED_INT_2_10_10_10_REV */
  94060. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  94061. /** UNSIGNED_INT_24_8 */
  94062. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  94063. /** UNSIGNED_INT_10F_11F_11F_REV */
  94064. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  94065. /** UNSIGNED_INT_5_9_9_9_REV */
  94066. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  94067. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  94068. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  94069. /** nearest is mag = nearest and min = nearest and mip = linear */
  94070. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  94071. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94072. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  94073. /** Trilinear is mag = linear and min = linear and mip = linear */
  94074. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  94075. /** nearest is mag = nearest and min = nearest and mip = linear */
  94076. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  94077. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94078. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  94079. /** Trilinear is mag = linear and min = linear and mip = linear */
  94080. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  94081. /** mag = nearest and min = nearest and mip = nearest */
  94082. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  94083. /** mag = nearest and min = linear and mip = nearest */
  94084. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  94085. /** mag = nearest and min = linear and mip = linear */
  94086. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  94087. /** mag = nearest and min = linear and mip = none */
  94088. static readonly TEXTURE_NEAREST_LINEAR: number;
  94089. /** mag = nearest and min = nearest and mip = none */
  94090. static readonly TEXTURE_NEAREST_NEAREST: number;
  94091. /** mag = linear and min = nearest and mip = nearest */
  94092. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  94093. /** mag = linear and min = nearest and mip = linear */
  94094. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  94095. /** mag = linear and min = linear and mip = none */
  94096. static readonly TEXTURE_LINEAR_LINEAR: number;
  94097. /** mag = linear and min = nearest and mip = none */
  94098. static readonly TEXTURE_LINEAR_NEAREST: number;
  94099. /** Explicit coordinates mode */
  94100. static readonly TEXTURE_EXPLICIT_MODE: number;
  94101. /** Spherical coordinates mode */
  94102. static readonly TEXTURE_SPHERICAL_MODE: number;
  94103. /** Planar coordinates mode */
  94104. static readonly TEXTURE_PLANAR_MODE: number;
  94105. /** Cubic coordinates mode */
  94106. static readonly TEXTURE_CUBIC_MODE: number;
  94107. /** Projection coordinates mode */
  94108. static readonly TEXTURE_PROJECTION_MODE: number;
  94109. /** Skybox coordinates mode */
  94110. static readonly TEXTURE_SKYBOX_MODE: number;
  94111. /** Inverse Cubic coordinates mode */
  94112. static readonly TEXTURE_INVCUBIC_MODE: number;
  94113. /** Equirectangular coordinates mode */
  94114. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  94115. /** Equirectangular Fixed coordinates mode */
  94116. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  94117. /** Equirectangular Fixed Mirrored coordinates mode */
  94118. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94119. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  94120. static readonly SCALEMODE_FLOOR: number;
  94121. /** Defines that texture rescaling will look for the nearest power of 2 size */
  94122. static readonly SCALEMODE_NEAREST: number;
  94123. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  94124. static readonly SCALEMODE_CEILING: number;
  94125. /**
  94126. * Returns the current npm package of the sdk
  94127. */
  94128. static readonly NpmPackage: string;
  94129. /**
  94130. * Returns the current version of the framework
  94131. */
  94132. static readonly Version: string;
  94133. /**
  94134. * Returns a string describing the current engine
  94135. */
  94136. readonly description: string;
  94137. /**
  94138. * Gets or sets the epsilon value used by collision engine
  94139. */
  94140. static CollisionsEpsilon: number;
  94141. /**
  94142. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94143. */
  94144. static ShadersRepository: string;
  94145. /**
  94146. * Method called to create the default loading screen.
  94147. * This can be overriden in your own app.
  94148. * @param canvas The rendering canvas element
  94149. * @returns The loading screen
  94150. */
  94151. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  94152. /**
  94153. * Method called to create the default rescale post process on each engine.
  94154. */
  94155. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  94156. /** @hidden */
  94157. _shaderProcessor: IShaderProcessor;
  94158. /**
  94159. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  94160. */
  94161. forcePOTTextures: boolean;
  94162. /**
  94163. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  94164. */
  94165. isFullscreen: boolean;
  94166. /**
  94167. * Gets a boolean indicating if the pointer is currently locked
  94168. */
  94169. isPointerLock: boolean;
  94170. /**
  94171. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  94172. */
  94173. cullBackFaces: boolean;
  94174. /**
  94175. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  94176. */
  94177. renderEvenInBackground: boolean;
  94178. /**
  94179. * Gets or sets a boolean indicating that cache can be kept between frames
  94180. */
  94181. preventCacheWipeBetweenFrames: boolean;
  94182. /**
  94183. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  94184. **/
  94185. enableOfflineSupport: boolean;
  94186. /**
  94187. * 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)
  94188. **/
  94189. disableManifestCheck: boolean;
  94190. /**
  94191. * Gets the list of created scenes
  94192. */
  94193. scenes: Scene[];
  94194. /**
  94195. * Event raised when a new scene is created
  94196. */
  94197. onNewSceneAddedObservable: Observable<Scene>;
  94198. /**
  94199. * Gets the list of created postprocesses
  94200. */
  94201. postProcesses: PostProcess[];
  94202. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  94203. validateShaderPrograms: boolean;
  94204. /**
  94205. * Observable event triggered each time the rendering canvas is resized
  94206. */
  94207. onResizeObservable: Observable<Engine>;
  94208. /**
  94209. * Observable event triggered each time the canvas loses focus
  94210. */
  94211. onCanvasBlurObservable: Observable<Engine>;
  94212. /**
  94213. * Observable event triggered each time the canvas gains focus
  94214. */
  94215. onCanvasFocusObservable: Observable<Engine>;
  94216. /**
  94217. * Observable event triggered each time the canvas receives pointerout event
  94218. */
  94219. onCanvasPointerOutObservable: Observable<PointerEvent>;
  94220. /**
  94221. * Observable event triggered before each texture is initialized
  94222. */
  94223. onBeforeTextureInitObservable: Observable<Texture>;
  94224. /**
  94225. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  94226. */
  94227. disableUniformBuffers: boolean;
  94228. /** @hidden */
  94229. _uniformBuffers: UniformBuffer[];
  94230. /**
  94231. * Gets a boolean indicating that the engine supports uniform buffers
  94232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94233. */
  94234. readonly supportsUniformBuffers: boolean;
  94235. /**
  94236. * Observable raised when the engine begins a new frame
  94237. */
  94238. onBeginFrameObservable: Observable<Engine>;
  94239. /**
  94240. * If set, will be used to request the next animation frame for the render loop
  94241. */
  94242. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  94243. /**
  94244. * Observable raised when the engine ends the current frame
  94245. */
  94246. onEndFrameObservable: Observable<Engine>;
  94247. /**
  94248. * Observable raised when the engine is about to compile a shader
  94249. */
  94250. onBeforeShaderCompilationObservable: Observable<Engine>;
  94251. /**
  94252. * Observable raised when the engine has jsut compiled a shader
  94253. */
  94254. onAfterShaderCompilationObservable: Observable<Engine>;
  94255. /** @hidden */
  94256. _gl: WebGLRenderingContext;
  94257. private _renderingCanvas;
  94258. private _windowIsBackground;
  94259. private _webGLVersion;
  94260. protected _highPrecisionShadersAllowed: boolean;
  94261. /** @hidden */
  94262. readonly _shouldUseHighPrecisionShader: boolean;
  94263. /**
  94264. * Gets a boolean indicating that only power of 2 textures are supported
  94265. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  94266. */
  94267. readonly needPOTTextures: boolean;
  94268. /** @hidden */
  94269. _badOS: boolean;
  94270. /** @hidden */
  94271. _badDesktopOS: boolean;
  94272. /**
  94273. * Gets the audio engine
  94274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94275. * @ignorenaming
  94276. */
  94277. static audioEngine: IAudioEngine;
  94278. /**
  94279. * Default AudioEngine factory responsible of creating the Audio Engine.
  94280. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  94281. */
  94282. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  94283. /**
  94284. * Default offline support factory responsible of creating a tool used to store data locally.
  94285. * By default, this will create a Database object if the workload has been embedded.
  94286. */
  94287. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  94288. private _onFocus;
  94289. private _onBlur;
  94290. private _onCanvasPointerOut;
  94291. private _onCanvasBlur;
  94292. private _onCanvasFocus;
  94293. private _onFullscreenChange;
  94294. private _onPointerLockChange;
  94295. private _hardwareScalingLevel;
  94296. /** @hidden */
  94297. _caps: EngineCapabilities;
  94298. private _pointerLockRequested;
  94299. private _isStencilEnable;
  94300. private _colorWrite;
  94301. private _loadingScreen;
  94302. /** @hidden */
  94303. _drawCalls: PerfCounter;
  94304. private _glVersion;
  94305. private _glRenderer;
  94306. private _glVendor;
  94307. private _videoTextureSupported;
  94308. private _renderingQueueLaunched;
  94309. private _activeRenderLoops;
  94310. private _deterministicLockstep;
  94311. private _lockstepMaxSteps;
  94312. /**
  94313. * Observable signaled when a context lost event is raised
  94314. */
  94315. onContextLostObservable: Observable<Engine>;
  94316. /**
  94317. * Observable signaled when a context restored event is raised
  94318. */
  94319. onContextRestoredObservable: Observable<Engine>;
  94320. private _onContextLost;
  94321. private _onContextRestored;
  94322. private _contextWasLost;
  94323. /** @hidden */
  94324. _doNotHandleContextLost: boolean;
  94325. /**
  94326. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94328. */
  94329. doNotHandleContextLost: boolean;
  94330. private _performanceMonitor;
  94331. private _fps;
  94332. private _deltaTime;
  94333. /**
  94334. * Turn this value on if you want to pause FPS computation when in background
  94335. */
  94336. disablePerformanceMonitorInBackground: boolean;
  94337. /**
  94338. * Gets the performance monitor attached to this engine
  94339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94340. */
  94341. readonly performanceMonitor: PerformanceMonitor;
  94342. /**
  94343. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94344. */
  94345. disableVertexArrayObjects: boolean;
  94346. /** @hidden */
  94347. protected _depthCullingState: _DepthCullingState;
  94348. /** @hidden */
  94349. protected _stencilState: _StencilState;
  94350. /** @hidden */
  94351. protected _alphaState: _AlphaState;
  94352. /** @hidden */
  94353. protected _alphaMode: number;
  94354. /** @hidden */
  94355. _internalTexturesCache: InternalTexture[];
  94356. /** @hidden */
  94357. protected _activeChannel: number;
  94358. private _currentTextureChannel;
  94359. /** @hidden */
  94360. protected _boundTexturesCache: {
  94361. [key: string]: Nullable<InternalTexture>;
  94362. };
  94363. /** @hidden */
  94364. protected _currentEffect: Nullable<Effect>;
  94365. /** @hidden */
  94366. protected _currentProgram: Nullable<WebGLProgram>;
  94367. private _compiledEffects;
  94368. private _vertexAttribArraysEnabled;
  94369. /** @hidden */
  94370. protected _cachedViewport: Nullable<IViewportLike>;
  94371. private _cachedVertexArrayObject;
  94372. /** @hidden */
  94373. protected _cachedVertexBuffers: any;
  94374. /** @hidden */
  94375. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94376. /** @hidden */
  94377. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94378. /** @hidden */
  94379. _currentRenderTarget: Nullable<InternalTexture>;
  94380. private _uintIndicesCurrentlySet;
  94381. private _currentBoundBuffer;
  94382. /** @hidden */
  94383. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94384. private _currentBufferPointers;
  94385. private _currentInstanceLocations;
  94386. private _currentInstanceBuffers;
  94387. private _textureUnits;
  94388. /** @hidden */
  94389. _workingCanvas: Nullable<HTMLCanvasElement>;
  94390. /** @hidden */
  94391. _workingContext: Nullable<CanvasRenderingContext2D>;
  94392. private _rescalePostProcess;
  94393. private _dummyFramebuffer;
  94394. private _externalData;
  94395. /** @hidden */
  94396. _bindedRenderFunction: any;
  94397. private _vaoRecordInProgress;
  94398. private _mustWipeVertexAttributes;
  94399. private _emptyTexture;
  94400. private _emptyCubeTexture;
  94401. private _emptyTexture3D;
  94402. /** @hidden */
  94403. _frameHandler: number;
  94404. private _nextFreeTextureSlots;
  94405. private _maxSimultaneousTextures;
  94406. private _activeRequests;
  94407. private _texturesSupported;
  94408. /** @hidden */
  94409. _textureFormatInUse: Nullable<string>;
  94410. /**
  94411. * Gets the list of texture formats supported
  94412. */
  94413. readonly texturesSupported: Array<string>;
  94414. /**
  94415. * Gets the list of texture formats in use
  94416. */
  94417. readonly textureFormatInUse: Nullable<string>;
  94418. /**
  94419. * Gets the current viewport
  94420. */
  94421. readonly currentViewport: Nullable<IViewportLike>;
  94422. /**
  94423. * Gets the default empty texture
  94424. */
  94425. readonly emptyTexture: InternalTexture;
  94426. /**
  94427. * Gets the default empty 3D texture
  94428. */
  94429. readonly emptyTexture3D: InternalTexture;
  94430. /**
  94431. * Gets the default empty cube texture
  94432. */
  94433. readonly emptyCubeTexture: InternalTexture;
  94434. /**
  94435. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94436. */
  94437. readonly premultipliedAlpha: boolean;
  94438. /**
  94439. * Creates a new engine
  94440. * @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
  94441. * @param antialias defines enable antialiasing (default: false)
  94442. * @param options defines further options to be sent to the getContext() function
  94443. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94444. */
  94445. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94446. /**
  94447. * Initializes a webVR display and starts listening to display change events
  94448. * The onVRDisplayChangedObservable will be notified upon these changes
  94449. * @returns The onVRDisplayChangedObservable
  94450. */
  94451. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94452. /** @hidden */
  94453. _prepareVRComponent(): void;
  94454. /** @hidden */
  94455. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94456. /** @hidden */
  94457. _submitVRFrame(): void;
  94458. /**
  94459. * Call this function to leave webVR mode
  94460. * Will do nothing if webVR is not supported or if there is no webVR device
  94461. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94462. */
  94463. disableVR(): void;
  94464. /**
  94465. * Gets a boolean indicating that the system is in VR mode and is presenting
  94466. * @returns true if VR mode is engaged
  94467. */
  94468. isVRPresenting(): boolean;
  94469. /** @hidden */
  94470. _requestVRFrame(): void;
  94471. private _disableTouchAction;
  94472. private _rebuildInternalTextures;
  94473. private _rebuildEffects;
  94474. /**
  94475. * Gets a boolean indicating if all created effects are ready
  94476. * @returns true if all effects are ready
  94477. */
  94478. areAllEffectsReady(): boolean;
  94479. private _rebuildBuffers;
  94480. private _initGLContext;
  94481. /**
  94482. * Gets version of the current webGL context
  94483. */
  94484. readonly webGLVersion: number;
  94485. /**
  94486. * Gets a string idenfifying the name of the class
  94487. * @returns "Engine" string
  94488. */
  94489. getClassName(): string;
  94490. /**
  94491. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94492. */
  94493. readonly isStencilEnable: boolean;
  94494. /** @hidden */
  94495. _prepareWorkingCanvas(): void;
  94496. /**
  94497. * Reset the texture cache to empty state
  94498. */
  94499. resetTextureCache(): void;
  94500. /**
  94501. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94502. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94503. * @returns true if engine is in deterministic lock step mode
  94504. */
  94505. isDeterministicLockStep(): boolean;
  94506. /**
  94507. * Gets the max steps when engine is running in deterministic lock step
  94508. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94509. * @returns the max steps
  94510. */
  94511. getLockstepMaxSteps(): number;
  94512. /**
  94513. * Gets an object containing information about the current webGL context
  94514. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94515. */
  94516. getGlInfo(): {
  94517. vendor: string;
  94518. renderer: string;
  94519. version: string;
  94520. };
  94521. /**
  94522. * Gets current aspect ratio
  94523. * @param viewportOwner defines the camera to use to get the aspect ratio
  94524. * @param useScreen defines if screen size must be used (or the current render target if any)
  94525. * @returns a number defining the aspect ratio
  94526. */
  94527. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94528. /**
  94529. * Gets current screen aspect ratio
  94530. * @returns a number defining the aspect ratio
  94531. */
  94532. getScreenAspectRatio(): number;
  94533. /**
  94534. * Gets the current render width
  94535. * @param useScreen defines if screen size must be used (or the current render target if any)
  94536. * @returns a number defining the current render width
  94537. */
  94538. getRenderWidth(useScreen?: boolean): number;
  94539. /**
  94540. * Gets the current render height
  94541. * @param useScreen defines if screen size must be used (or the current render target if any)
  94542. * @returns a number defining the current render height
  94543. */
  94544. getRenderHeight(useScreen?: boolean): number;
  94545. /**
  94546. * Gets the HTML canvas attached with the current webGL context
  94547. * @returns a HTML canvas
  94548. */
  94549. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94550. /**
  94551. * Gets host window
  94552. * @returns the host window object
  94553. */
  94554. getHostWindow(): Window;
  94555. /**
  94556. * Gets host document
  94557. * @returns the host document object
  94558. */
  94559. getHostDocument(): Document;
  94560. /**
  94561. * Gets the client rect of the HTML canvas attached with the current webGL context
  94562. * @returns a client rectanglee
  94563. */
  94564. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94565. /**
  94566. * Defines the hardware scaling level.
  94567. * By default the hardware scaling level is computed from the window device ratio.
  94568. * 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.
  94569. * @param level defines the level to use
  94570. */
  94571. setHardwareScalingLevel(level: number): void;
  94572. /**
  94573. * Gets the current hardware scaling level.
  94574. * By default the hardware scaling level is computed from the window device ratio.
  94575. * 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.
  94576. * @returns a number indicating the current hardware scaling level
  94577. */
  94578. getHardwareScalingLevel(): number;
  94579. /**
  94580. * Gets the list of loaded textures
  94581. * @returns an array containing all loaded textures
  94582. */
  94583. getLoadedTexturesCache(): InternalTexture[];
  94584. /**
  94585. * Gets the object containing all engine capabilities
  94586. * @returns the EngineCapabilities object
  94587. */
  94588. getCaps(): EngineCapabilities;
  94589. /**
  94590. * Gets the current depth function
  94591. * @returns a number defining the depth function
  94592. */
  94593. getDepthFunction(): Nullable<number>;
  94594. /**
  94595. * Sets the current depth function
  94596. * @param depthFunc defines the function to use
  94597. */
  94598. setDepthFunction(depthFunc: number): void;
  94599. /**
  94600. * Sets the current depth function to GREATER
  94601. */
  94602. setDepthFunctionToGreater(): void;
  94603. /**
  94604. * Sets the current depth function to GEQUAL
  94605. */
  94606. setDepthFunctionToGreaterOrEqual(): void;
  94607. /**
  94608. * Sets the current depth function to LESS
  94609. */
  94610. setDepthFunctionToLess(): void;
  94611. private _cachedStencilBuffer;
  94612. private _cachedStencilFunction;
  94613. private _cachedStencilMask;
  94614. private _cachedStencilOperationPass;
  94615. private _cachedStencilOperationFail;
  94616. private _cachedStencilOperationDepthFail;
  94617. private _cachedStencilReference;
  94618. /**
  94619. * Caches the the state of the stencil buffer
  94620. */
  94621. cacheStencilState(): void;
  94622. /**
  94623. * Restores the state of the stencil buffer
  94624. */
  94625. restoreStencilState(): void;
  94626. /**
  94627. * Sets the current depth function to LEQUAL
  94628. */
  94629. setDepthFunctionToLessOrEqual(): void;
  94630. /**
  94631. * Gets a boolean indicating if stencil buffer is enabled
  94632. * @returns the current stencil buffer state
  94633. */
  94634. getStencilBuffer(): boolean;
  94635. /**
  94636. * Enable or disable the stencil buffer
  94637. * @param enable defines if the stencil buffer must be enabled or disabled
  94638. */
  94639. setStencilBuffer(enable: boolean): void;
  94640. /**
  94641. * Gets the current stencil mask
  94642. * @returns a number defining the new stencil mask to use
  94643. */
  94644. getStencilMask(): number;
  94645. /**
  94646. * Sets the current stencil mask
  94647. * @param mask defines the new stencil mask to use
  94648. */
  94649. setStencilMask(mask: number): void;
  94650. /**
  94651. * Gets the current stencil function
  94652. * @returns a number defining the stencil function to use
  94653. */
  94654. getStencilFunction(): number;
  94655. /**
  94656. * Gets the current stencil reference value
  94657. * @returns a number defining the stencil reference value to use
  94658. */
  94659. getStencilFunctionReference(): number;
  94660. /**
  94661. * Gets the current stencil mask
  94662. * @returns a number defining the stencil mask to use
  94663. */
  94664. getStencilFunctionMask(): number;
  94665. /**
  94666. * Sets the current stencil function
  94667. * @param stencilFunc defines the new stencil function to use
  94668. */
  94669. setStencilFunction(stencilFunc: number): void;
  94670. /**
  94671. * Sets the current stencil reference
  94672. * @param reference defines the new stencil reference to use
  94673. */
  94674. setStencilFunctionReference(reference: number): void;
  94675. /**
  94676. * Sets the current stencil mask
  94677. * @param mask defines the new stencil mask to use
  94678. */
  94679. setStencilFunctionMask(mask: number): void;
  94680. /**
  94681. * Gets the current stencil operation when stencil fails
  94682. * @returns a number defining stencil operation to use when stencil fails
  94683. */
  94684. getStencilOperationFail(): number;
  94685. /**
  94686. * Gets the current stencil operation when depth fails
  94687. * @returns a number defining stencil operation to use when depth fails
  94688. */
  94689. getStencilOperationDepthFail(): number;
  94690. /**
  94691. * Gets the current stencil operation when stencil passes
  94692. * @returns a number defining stencil operation to use when stencil passes
  94693. */
  94694. getStencilOperationPass(): number;
  94695. /**
  94696. * Sets the stencil operation to use when stencil fails
  94697. * @param operation defines the stencil operation to use when stencil fails
  94698. */
  94699. setStencilOperationFail(operation: number): void;
  94700. /**
  94701. * Sets the stencil operation to use when depth fails
  94702. * @param operation defines the stencil operation to use when depth fails
  94703. */
  94704. setStencilOperationDepthFail(operation: number): void;
  94705. /**
  94706. * Sets the stencil operation to use when stencil passes
  94707. * @param operation defines the stencil operation to use when stencil passes
  94708. */
  94709. setStencilOperationPass(operation: number): void;
  94710. /**
  94711. * Sets a boolean indicating if the dithering state is enabled or disabled
  94712. * @param value defines the dithering state
  94713. */
  94714. setDitheringState(value: boolean): void;
  94715. /**
  94716. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94717. * @param value defines the rasterizer state
  94718. */
  94719. setRasterizerState(value: boolean): void;
  94720. /**
  94721. * stop executing a render loop function and remove it from the execution array
  94722. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94723. */
  94724. stopRenderLoop(renderFunction?: () => void): void;
  94725. /** @hidden */
  94726. _renderLoop(): void;
  94727. /**
  94728. * Register and execute a render loop. The engine can have more than one render function
  94729. * @param renderFunction defines the function to continuously execute
  94730. */
  94731. runRenderLoop(renderFunction: () => void): void;
  94732. /**
  94733. * Toggle full screen mode
  94734. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94735. */
  94736. switchFullscreen(requestPointerLock: boolean): void;
  94737. /**
  94738. * Enters full screen mode
  94739. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94740. */
  94741. enterFullscreen(requestPointerLock: boolean): void;
  94742. /**
  94743. * Exits full screen mode
  94744. */
  94745. exitFullscreen(): void;
  94746. /**
  94747. * Enters Pointerlock mode
  94748. */
  94749. enterPointerlock(): void;
  94750. /**
  94751. * Exits Pointerlock mode
  94752. */
  94753. exitPointerlock(): void;
  94754. /**
  94755. * Clear the current render buffer or the current render target (if any is set up)
  94756. * @param color defines the color to use
  94757. * @param backBuffer defines if the back buffer must be cleared
  94758. * @param depth defines if the depth buffer must be cleared
  94759. * @param stencil defines if the stencil buffer must be cleared
  94760. */
  94761. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94762. /**
  94763. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94764. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94765. * @param y defines the y-coordinate of the corner of the clear rectangle
  94766. * @param width defines the width of the clear rectangle
  94767. * @param height defines the height of the clear rectangle
  94768. * @param clearColor defines the clear color
  94769. */
  94770. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94771. /**
  94772. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94773. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94774. * @param y defines the y-coordinate of the corner of the clear rectangle
  94775. * @param width defines the width of the clear rectangle
  94776. * @param height defines the height of the clear rectangle
  94777. */
  94778. enableScissor(x: number, y: number, width: number, height: number): void;
  94779. /**
  94780. * Disable previously set scissor test rectangle
  94781. */
  94782. disableScissor(): void;
  94783. private _viewportCached;
  94784. /** @hidden */
  94785. _viewport(x: number, y: number, width: number, height: number): void;
  94786. /**
  94787. * Set the WebGL's viewport
  94788. * @param viewport defines the viewport element to be used
  94789. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94790. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94791. */
  94792. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94793. /**
  94794. * Directly set the WebGL Viewport
  94795. * @param x defines the x coordinate of the viewport (in screen space)
  94796. * @param y defines the y coordinate of the viewport (in screen space)
  94797. * @param width defines the width of the viewport (in screen space)
  94798. * @param height defines the height of the viewport (in screen space)
  94799. * @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
  94800. */
  94801. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94802. /**
  94803. * Begin a new frame
  94804. */
  94805. beginFrame(): void;
  94806. /**
  94807. * Enf the current frame
  94808. */
  94809. endFrame(): void;
  94810. /**
  94811. * Resize the view according to the canvas' size
  94812. */
  94813. resize(): void;
  94814. /**
  94815. * Force a specific size of the canvas
  94816. * @param width defines the new canvas' width
  94817. * @param height defines the new canvas' height
  94818. */
  94819. setSize(width: number, height: number): void;
  94820. /**
  94821. * Binds the frame buffer to the specified texture.
  94822. * @param texture The texture to render to or null for the default canvas
  94823. * @param faceIndex The face of the texture to render to in case of cube texture
  94824. * @param requiredWidth The width of the target to render to
  94825. * @param requiredHeight The height of the target to render to
  94826. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94827. * @param depthStencilTexture The depth stencil texture to use to render
  94828. * @param lodLevel defines le lod level to bind to the frame buffer
  94829. */
  94830. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94831. /** @hidden */
  94832. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94833. /**
  94834. * Unbind the current render target texture from the webGL context
  94835. * @param texture defines the render target texture to unbind
  94836. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94837. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94838. */
  94839. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94840. /**
  94841. * Force the mipmap generation for the given render target texture
  94842. * @param texture defines the render target texture to use
  94843. */
  94844. generateMipMapsForCubemap(texture: InternalTexture): void;
  94845. /**
  94846. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94847. */
  94848. flushFramebuffer(): void;
  94849. /**
  94850. * Unbind the current render target and bind the default framebuffer
  94851. */
  94852. restoreDefaultFramebuffer(): void;
  94853. /**
  94854. * Create an uniform buffer
  94855. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94856. * @param elements defines the content of the uniform buffer
  94857. * @returns the webGL uniform buffer
  94858. */
  94859. createUniformBuffer(elements: FloatArray): DataBuffer;
  94860. /**
  94861. * Create a dynamic uniform buffer
  94862. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94863. * @param elements defines the content of the uniform buffer
  94864. * @returns the webGL uniform buffer
  94865. */
  94866. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94867. /**
  94868. * Update an existing uniform buffer
  94869. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94870. * @param uniformBuffer defines the target uniform buffer
  94871. * @param elements defines the content to update
  94872. * @param offset defines the offset in the uniform buffer where update should start
  94873. * @param count defines the size of the data to update
  94874. */
  94875. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94876. private _resetVertexBufferBinding;
  94877. /**
  94878. * Creates a vertex buffer
  94879. * @param data the data for the vertex buffer
  94880. * @returns the new WebGL static buffer
  94881. */
  94882. createVertexBuffer(data: DataArray): DataBuffer;
  94883. /**
  94884. * Creates a dynamic vertex buffer
  94885. * @param data the data for the dynamic vertex buffer
  94886. * @returns the new WebGL dynamic buffer
  94887. */
  94888. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94889. /**
  94890. * Update a dynamic index buffer
  94891. * @param indexBuffer defines the target index buffer
  94892. * @param indices defines the data to update
  94893. * @param offset defines the offset in the target index buffer where update should start
  94894. */
  94895. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94896. /**
  94897. * Updates a dynamic vertex buffer.
  94898. * @param vertexBuffer the vertex buffer to update
  94899. * @param data the data used to update the vertex buffer
  94900. * @param byteOffset the byte offset of the data
  94901. * @param byteLength the byte length of the data
  94902. */
  94903. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94904. private _resetIndexBufferBinding;
  94905. /**
  94906. * Creates a new index buffer
  94907. * @param indices defines the content of the index buffer
  94908. * @param updatable defines if the index buffer must be updatable
  94909. * @returns a new webGL buffer
  94910. */
  94911. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94912. /**
  94913. * Bind a webGL buffer to the webGL context
  94914. * @param buffer defines the buffer to bind
  94915. */
  94916. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94917. /**
  94918. * Bind an uniform buffer to the current webGL context
  94919. * @param buffer defines the buffer to bind
  94920. */
  94921. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94922. /**
  94923. * Bind a buffer to the current webGL context at a given location
  94924. * @param buffer defines the buffer to bind
  94925. * @param location defines the index where to bind the buffer
  94926. */
  94927. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94928. /**
  94929. * Bind a specific block at a given index in a specific shader program
  94930. * @param pipelineContext defines the pipeline context to use
  94931. * @param blockName defines the block name
  94932. * @param index defines the index where to bind the block
  94933. */
  94934. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94935. private bindIndexBuffer;
  94936. private bindBuffer;
  94937. /**
  94938. * update the bound buffer with the given data
  94939. * @param data defines the data to update
  94940. */
  94941. updateArrayBuffer(data: Float32Array): void;
  94942. private _vertexAttribPointer;
  94943. private _bindIndexBufferWithCache;
  94944. private _bindVertexBuffersAttributes;
  94945. /**
  94946. * Records a vertex array object
  94947. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94948. * @param vertexBuffers defines the list of vertex buffers to store
  94949. * @param indexBuffer defines the index buffer to store
  94950. * @param effect defines the effect to store
  94951. * @returns the new vertex array object
  94952. */
  94953. recordVertexArrayObject(vertexBuffers: {
  94954. [key: string]: VertexBuffer;
  94955. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94956. /**
  94957. * Bind a specific vertex array object
  94958. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94959. * @param vertexArrayObject defines the vertex array object to bind
  94960. * @param indexBuffer defines the index buffer to bind
  94961. */
  94962. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94963. /**
  94964. * Bind webGl buffers directly to the webGL context
  94965. * @param vertexBuffer defines the vertex buffer to bind
  94966. * @param indexBuffer defines the index buffer to bind
  94967. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94968. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94969. * @param effect defines the effect associated with the vertex buffer
  94970. */
  94971. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94972. private _unbindVertexArrayObject;
  94973. /**
  94974. * Bind a list of vertex buffers to the webGL context
  94975. * @param vertexBuffers defines the list of vertex buffers to bind
  94976. * @param indexBuffer defines the index buffer to bind
  94977. * @param effect defines the effect associated with the vertex buffers
  94978. */
  94979. bindBuffers(vertexBuffers: {
  94980. [key: string]: Nullable<VertexBuffer>;
  94981. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94982. /**
  94983. * Unbind all instance attributes
  94984. */
  94985. unbindInstanceAttributes(): void;
  94986. /**
  94987. * Release and free the memory of a vertex array object
  94988. * @param vao defines the vertex array object to delete
  94989. */
  94990. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94991. /** @hidden */
  94992. _releaseBuffer(buffer: DataBuffer): boolean;
  94993. /**
  94994. * Creates a webGL buffer to use with instanciation
  94995. * @param capacity defines the size of the buffer
  94996. * @returns the webGL buffer
  94997. */
  94998. createInstancesBuffer(capacity: number): DataBuffer;
  94999. /**
  95000. * Delete a webGL buffer used with instanciation
  95001. * @param buffer defines the webGL buffer to delete
  95002. */
  95003. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  95004. /**
  95005. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  95006. * @param instancesBuffer defines the webGL buffer to update and bind
  95007. * @param data defines the data to store in the buffer
  95008. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  95009. */
  95010. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  95011. /**
  95012. * Apply all cached states (depth, culling, stencil and alpha)
  95013. */
  95014. applyStates(): void;
  95015. /**
  95016. * Send a draw order
  95017. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95018. * @param indexStart defines the starting index
  95019. * @param indexCount defines the number of index to draw
  95020. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95021. */
  95022. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  95023. /**
  95024. * Draw a list of points
  95025. * @param verticesStart defines the index of first vertex to draw
  95026. * @param verticesCount defines the count of vertices to draw
  95027. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95028. */
  95029. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95030. /**
  95031. * Draw a list of unindexed primitives
  95032. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  95033. * @param verticesStart defines the index of first vertex to draw
  95034. * @param verticesCount defines the count of vertices to draw
  95035. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95036. */
  95037. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95038. /**
  95039. * Draw a list of indexed primitives
  95040. * @param fillMode defines the primitive to use
  95041. * @param indexStart defines the starting index
  95042. * @param indexCount defines the number of index to draw
  95043. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95044. */
  95045. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  95046. /**
  95047. * Draw a list of unindexed primitives
  95048. * @param fillMode defines the primitive to use
  95049. * @param verticesStart defines the index of first vertex to draw
  95050. * @param verticesCount defines the count of vertices to draw
  95051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  95052. */
  95053. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  95054. private _drawMode;
  95055. /** @hidden */
  95056. _releaseEffect(effect: Effect): void;
  95057. /** @hidden */
  95058. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  95059. /**
  95060. * Create a new effect (used to store vertex/fragment shaders)
  95061. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  95062. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  95063. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  95064. * @param samplers defines an array of string used to represent textures
  95065. * @param defines defines the string containing the defines to use to compile the shaders
  95066. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  95067. * @param onCompiled defines a function to call when the effect creation is successful
  95068. * @param onError defines a function to call when the effect creation has failed
  95069. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  95070. * @returns the new Effect
  95071. */
  95072. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  95073. private _compileShader;
  95074. private _compileRawShader;
  95075. /**
  95076. * Directly creates a webGL program
  95077. * @param pipelineContext defines the pipeline context to attach to
  95078. * @param vertexCode defines the vertex shader code to use
  95079. * @param fragmentCode defines the fragment shader code to use
  95080. * @param context defines the webGL context to use (if not set, the current one will be used)
  95081. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95082. * @returns the new webGL program
  95083. */
  95084. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95085. /**
  95086. * Creates a webGL program
  95087. * @param pipelineContext defines the pipeline context to attach to
  95088. * @param vertexCode defines the vertex shader code to use
  95089. * @param fragmentCode defines the fragment shader code to use
  95090. * @param defines defines the string containing the defines to use to compile the shaders
  95091. * @param context defines the webGL context to use (if not set, the current one will be used)
  95092. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  95093. * @returns the new webGL program
  95094. */
  95095. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  95096. /**
  95097. * Creates a new pipeline context
  95098. * @returns the new pipeline
  95099. */
  95100. createPipelineContext(): WebGLPipelineContext;
  95101. private _createShaderProgram;
  95102. private _finalizePipelineContext;
  95103. /** @hidden */
  95104. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  95105. /** @hidden */
  95106. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  95107. /** @hidden */
  95108. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  95109. /**
  95110. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  95111. * @param pipelineContext defines the pipeline context to use
  95112. * @param uniformsNames defines the list of uniform names
  95113. * @returns an array of webGL uniform locations
  95114. */
  95115. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  95116. /**
  95117. * Gets the lsit of active attributes for a given webGL program
  95118. * @param pipelineContext defines the pipeline context to use
  95119. * @param attributesNames defines the list of attribute names to get
  95120. * @returns an array of indices indicating the offset of each attribute
  95121. */
  95122. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  95123. /**
  95124. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  95125. * @param effect defines the effect to activate
  95126. */
  95127. enableEffect(effect: Nullable<Effect>): void;
  95128. /**
  95129. * Set the value of an uniform to an array of int32
  95130. * @param uniform defines the webGL uniform location where to store the value
  95131. * @param array defines the array of int32 to store
  95132. */
  95133. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95134. /**
  95135. * Set the value of an uniform to an array of int32 (stored as vec2)
  95136. * @param uniform defines the webGL uniform location where to store the value
  95137. * @param array defines the array of int32 to store
  95138. */
  95139. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95140. /**
  95141. * Set the value of an uniform to an array of int32 (stored as vec3)
  95142. * @param uniform defines the webGL uniform location where to store the value
  95143. * @param array defines the array of int32 to store
  95144. */
  95145. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95146. /**
  95147. * Set the value of an uniform to an array of int32 (stored as vec4)
  95148. * @param uniform defines the webGL uniform location where to store the value
  95149. * @param array defines the array of int32 to store
  95150. */
  95151. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  95152. /**
  95153. * Set the value of an uniform to an array of float32
  95154. * @param uniform defines the webGL uniform location where to store the value
  95155. * @param array defines the array of float32 to store
  95156. */
  95157. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95158. /**
  95159. * Set the value of an uniform to an array of float32 (stored as vec2)
  95160. * @param uniform defines the webGL uniform location where to store the value
  95161. * @param array defines the array of float32 to store
  95162. */
  95163. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95164. /**
  95165. * Set the value of an uniform to an array of float32 (stored as vec3)
  95166. * @param uniform defines the webGL uniform location where to store the value
  95167. * @param array defines the array of float32 to store
  95168. */
  95169. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95170. /**
  95171. * Set the value of an uniform to an array of float32 (stored as vec4)
  95172. * @param uniform defines the webGL uniform location where to store the value
  95173. * @param array defines the array of float32 to store
  95174. */
  95175. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  95176. /**
  95177. * Set the value of an uniform to an array of number
  95178. * @param uniform defines the webGL uniform location where to store the value
  95179. * @param array defines the array of number to store
  95180. */
  95181. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95182. /**
  95183. * Set the value of an uniform to an array of number (stored as vec2)
  95184. * @param uniform defines the webGL uniform location where to store the value
  95185. * @param array defines the array of number to store
  95186. */
  95187. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95188. /**
  95189. * Set the value of an uniform to an array of number (stored as vec3)
  95190. * @param uniform defines the webGL uniform location where to store the value
  95191. * @param array defines the array of number to store
  95192. */
  95193. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95194. /**
  95195. * Set the value of an uniform to an array of number (stored as vec4)
  95196. * @param uniform defines the webGL uniform location where to store the value
  95197. * @param array defines the array of number to store
  95198. */
  95199. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  95200. /**
  95201. * Set the value of an uniform to an array of float32 (stored as matrices)
  95202. * @param uniform defines the webGL uniform location where to store the value
  95203. * @param matrices defines the array of float32 to store
  95204. */
  95205. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  95206. /**
  95207. * Set the value of an uniform to a matrix (3x3)
  95208. * @param uniform defines the webGL uniform location where to store the value
  95209. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  95210. */
  95211. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95212. /**
  95213. * Set the value of an uniform to a matrix (2x2)
  95214. * @param uniform defines the webGL uniform location where to store the value
  95215. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  95216. */
  95217. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  95218. /**
  95219. * Set the value of an uniform to a number (int)
  95220. * @param uniform defines the webGL uniform location where to store the value
  95221. * @param value defines the int number to store
  95222. */
  95223. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95224. /**
  95225. * Set the value of an uniform to a number (float)
  95226. * @param uniform defines the webGL uniform location where to store the value
  95227. * @param value defines the float number to store
  95228. */
  95229. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  95230. /**
  95231. * Set the value of an uniform to a vec2
  95232. * @param uniform defines the webGL uniform location where to store the value
  95233. * @param x defines the 1st component of the value
  95234. * @param y defines the 2nd component of the value
  95235. */
  95236. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  95237. /**
  95238. * Set the value of an uniform to a vec3
  95239. * @param uniform defines the webGL uniform location where to store the value
  95240. * @param x defines the 1st component of the value
  95241. * @param y defines the 2nd component of the value
  95242. * @param z defines the 3rd component of the value
  95243. */
  95244. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  95245. /**
  95246. * Set the value of an uniform to a boolean
  95247. * @param uniform defines the webGL uniform location where to store the value
  95248. * @param bool defines the boolean to store
  95249. */
  95250. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  95251. /**
  95252. * Set the value of an uniform to a vec4
  95253. * @param uniform defines the webGL uniform location where to store the value
  95254. * @param x defines the 1st component of the value
  95255. * @param y defines the 2nd component of the value
  95256. * @param z defines the 3rd component of the value
  95257. * @param w defines the 4th component of the value
  95258. */
  95259. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  95260. /**
  95261. * Sets a Color4 on a uniform variable
  95262. * @param uniform defines the uniform location
  95263. * @param color4 defines the value to be set
  95264. */
  95265. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  95266. /**
  95267. * Set various states to the webGL context
  95268. * @param culling defines backface culling state
  95269. * @param zOffset defines the value to apply to zOffset (0 by default)
  95270. * @param force defines if states must be applied even if cache is up to date
  95271. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  95272. */
  95273. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  95274. /**
  95275. * Set the z offset to apply to current rendering
  95276. * @param value defines the offset to apply
  95277. */
  95278. setZOffset(value: number): void;
  95279. /**
  95280. * Gets the current value of the zOffset
  95281. * @returns the current zOffset state
  95282. */
  95283. getZOffset(): number;
  95284. /**
  95285. * Enable or disable depth buffering
  95286. * @param enable defines the state to set
  95287. */
  95288. setDepthBuffer(enable: boolean): void;
  95289. /**
  95290. * Gets a boolean indicating if depth writing is enabled
  95291. * @returns the current depth writing state
  95292. */
  95293. getDepthWrite(): boolean;
  95294. /**
  95295. * Enable or disable depth writing
  95296. * @param enable defines the state to set
  95297. */
  95298. setDepthWrite(enable: boolean): void;
  95299. /**
  95300. * Enable or disable color writing
  95301. * @param enable defines the state to set
  95302. */
  95303. setColorWrite(enable: boolean): void;
  95304. /**
  95305. * Gets a boolean indicating if color writing is enabled
  95306. * @returns the current color writing state
  95307. */
  95308. getColorWrite(): boolean;
  95309. /**
  95310. * Sets alpha constants used by some alpha blending modes
  95311. * @param r defines the red component
  95312. * @param g defines the green component
  95313. * @param b defines the blue component
  95314. * @param a defines the alpha component
  95315. */
  95316. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  95317. /**
  95318. * Sets the current alpha mode
  95319. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  95320. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  95321. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95322. */
  95323. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  95324. /**
  95325. * Gets the current alpha mode
  95326. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  95327. * @returns the current alpha mode
  95328. */
  95329. getAlphaMode(): number;
  95330. /**
  95331. * Clears the list of texture accessible through engine.
  95332. * This can help preventing texture load conflict due to name collision.
  95333. */
  95334. clearInternalTexturesCache(): void;
  95335. /**
  95336. * Force the entire cache to be cleared
  95337. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95338. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95339. */
  95340. wipeCaches(bruteForce?: boolean): void;
  95341. /**
  95342. * Set the compressed texture format to use, based on the formats you have, and the formats
  95343. * supported by the hardware / browser.
  95344. *
  95345. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95346. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95347. * to API arguments needed to compressed textures. This puts the burden on the container
  95348. * generator to house the arcane code for determining these for current & future formats.
  95349. *
  95350. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95351. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95352. *
  95353. * Note: The result of this call is not taken into account when a texture is base64.
  95354. *
  95355. * @param formatsAvailable defines the list of those format families you have created
  95356. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95357. *
  95358. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95359. * @returns The extension selected.
  95360. */
  95361. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95362. /** @hidden */
  95363. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95364. min: number;
  95365. mag: number;
  95366. };
  95367. /** @hidden */
  95368. _createTexture(): WebGLTexture;
  95369. /**
  95370. * Usually called from Texture.ts.
  95371. * Passed information to create a WebGLTexture
  95372. * @param urlArg defines a value which contains one of the following:
  95373. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95374. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95375. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95376. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95377. * @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)
  95378. * @param scene needed for loading to the correct scene
  95379. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95380. * @param onLoad optional callback to be called upon successful completion
  95381. * @param onError optional callback to be called upon failure
  95382. * @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
  95383. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95384. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95385. * @param forcedExtension defines the extension to use to pick the right loader
  95386. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95387. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95388. */
  95389. 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;
  95390. /**
  95391. * @hidden
  95392. * Rescales a texture
  95393. * @param source input texutre
  95394. * @param destination destination texture
  95395. * @param scene scene to use to render the resize
  95396. * @param internalFormat format to use when resizing
  95397. * @param onComplete callback to be called when resize has completed
  95398. */
  95399. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95400. private _unpackFlipYCached;
  95401. /**
  95402. * In case you are sharing the context with other applications, it might
  95403. * be interested to not cache the unpack flip y state to ensure a consistent
  95404. * value would be set.
  95405. */
  95406. enableUnpackFlipYCached: boolean;
  95407. /** @hidden */
  95408. _unpackFlipY(value: boolean): void;
  95409. /** @hidden */
  95410. _getUnpackAlignement(): number;
  95411. /**
  95412. * Creates a dynamic texture
  95413. * @param width defines the width of the texture
  95414. * @param height defines the height of the texture
  95415. * @param generateMipMaps defines if the engine should generate the mip levels
  95416. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95417. * @returns the dynamic texture inside an InternalTexture
  95418. */
  95419. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95420. /**
  95421. * Update the sampling mode of a given texture
  95422. * @param samplingMode defines the required sampling mode
  95423. * @param texture defines the texture to update
  95424. */
  95425. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95426. /**
  95427. * Update the content of a dynamic texture
  95428. * @param texture defines the texture to update
  95429. * @param canvas defines the canvas containing the source
  95430. * @param invertY defines if data must be stored with Y axis inverted
  95431. * @param premulAlpha defines if alpha is stored as premultiplied
  95432. * @param format defines the format of the data
  95433. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95434. */
  95435. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95436. /**
  95437. * Update a video texture
  95438. * @param texture defines the texture to update
  95439. * @param video defines the video element to use
  95440. * @param invertY defines if data must be stored with Y axis inverted
  95441. */
  95442. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95443. /**
  95444. * Updates a depth texture Comparison Mode and Function.
  95445. * If the comparison Function is equal to 0, the mode will be set to none.
  95446. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95447. * @param texture The texture to set the comparison function for
  95448. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95449. */
  95450. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95451. /** @hidden */
  95452. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95453. width: number;
  95454. height: number;
  95455. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95456. /**
  95457. * Creates a depth stencil texture.
  95458. * This is only available in WebGL 2 or with the depth texture extension available.
  95459. * @param size The size of face edge in the texture.
  95460. * @param options The options defining the texture.
  95461. * @returns The texture
  95462. */
  95463. createDepthStencilTexture(size: number | {
  95464. width: number;
  95465. height: number;
  95466. }, options: DepthTextureCreationOptions): InternalTexture;
  95467. /**
  95468. * Creates a depth stencil texture.
  95469. * This is only available in WebGL 2 or with the depth texture extension available.
  95470. * @param size The size of face edge in the texture.
  95471. * @param options The options defining the texture.
  95472. * @returns The texture
  95473. */
  95474. private _createDepthStencilTexture;
  95475. /**
  95476. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95477. * @param renderTarget The render target to set the frame buffer for
  95478. */
  95479. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95480. /**
  95481. * Creates a new render target texture
  95482. * @param size defines the size of the texture
  95483. * @param options defines the options used to create the texture
  95484. * @returns a new render target texture stored in an InternalTexture
  95485. */
  95486. createRenderTargetTexture(size: number | {
  95487. width: number;
  95488. height: number;
  95489. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95490. /** @hidden */
  95491. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95492. /**
  95493. * Updates the sample count of a render target texture
  95494. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95495. * @param texture defines the texture to update
  95496. * @param samples defines the sample count to set
  95497. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95498. */
  95499. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95500. /** @hidden */
  95501. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95502. /** @hidden */
  95503. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95504. /** @hidden */
  95505. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95506. /** @hidden */
  95507. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95508. /**
  95509. * @hidden
  95510. */
  95511. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95512. private _prepareWebGLTextureContinuation;
  95513. private _prepareWebGLTexture;
  95514. /** @hidden */
  95515. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95516. /** @hidden */
  95517. _releaseFramebufferObjects(texture: InternalTexture): void;
  95518. /** @hidden */
  95519. _releaseTexture(texture: InternalTexture): void;
  95520. private setProgram;
  95521. private _boundUniforms;
  95522. /**
  95523. * Binds an effect to the webGL context
  95524. * @param effect defines the effect to bind
  95525. */
  95526. bindSamplers(effect: Effect): void;
  95527. private _activateCurrentTexture;
  95528. /** @hidden */
  95529. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95530. /** @hidden */
  95531. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95532. /**
  95533. * Sets a texture to the webGL context from a postprocess
  95534. * @param channel defines the channel to use
  95535. * @param postProcess defines the source postprocess
  95536. */
  95537. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95538. /**
  95539. * Binds the output of the passed in post process to the texture channel specified
  95540. * @param channel The channel the texture should be bound to
  95541. * @param postProcess The post process which's output should be bound
  95542. */
  95543. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95544. /**
  95545. * Unbind all textures from the webGL context
  95546. */
  95547. unbindAllTextures(): void;
  95548. /**
  95549. * Sets a texture to the according uniform.
  95550. * @param channel The texture channel
  95551. * @param uniform The uniform to set
  95552. * @param texture The texture to apply
  95553. */
  95554. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95555. /**
  95556. * Sets a depth stencil texture from a render target to the according uniform.
  95557. * @param channel The texture channel
  95558. * @param uniform The uniform to set
  95559. * @param texture The render target texture containing the depth stencil texture to apply
  95560. */
  95561. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95562. private _bindSamplerUniformToChannel;
  95563. private _getTextureWrapMode;
  95564. private _setTexture;
  95565. /**
  95566. * Sets an array of texture to the webGL context
  95567. * @param channel defines the channel where the texture array must be set
  95568. * @param uniform defines the associated uniform location
  95569. * @param textures defines the array of textures to bind
  95570. */
  95571. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95572. /** @hidden */
  95573. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95574. private _setTextureParameterFloat;
  95575. private _setTextureParameterInteger;
  95576. /**
  95577. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95578. * @param x defines the x coordinate of the rectangle where pixels must be read
  95579. * @param y defines the y coordinate of the rectangle where pixels must be read
  95580. * @param width defines the width of the rectangle where pixels must be read
  95581. * @param height defines the height of the rectangle where pixels must be read
  95582. * @returns a Uint8Array containing RGBA colors
  95583. */
  95584. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95585. /**
  95586. * Add an externaly attached data from its key.
  95587. * This method call will fail and return false, if such key already exists.
  95588. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95589. * @param key the unique key that identifies the data
  95590. * @param data the data object to associate to the key for this Engine instance
  95591. * @return true if no such key were already present and the data was added successfully, false otherwise
  95592. */
  95593. addExternalData<T>(key: string, data: T): boolean;
  95594. /**
  95595. * Get an externaly attached data from its key
  95596. * @param key the unique key that identifies the data
  95597. * @return the associated data, if present (can be null), or undefined if not present
  95598. */
  95599. getExternalData<T>(key: string): T;
  95600. /**
  95601. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95602. * @param key the unique key that identifies the data
  95603. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95604. * @return the associated data, can be null if the factory returned null.
  95605. */
  95606. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95607. /**
  95608. * Remove an externaly attached data from the Engine instance
  95609. * @param key the unique key that identifies the data
  95610. * @return true if the data was successfully removed, false if it doesn't exist
  95611. */
  95612. removeExternalData(key: string): boolean;
  95613. /**
  95614. * Unbind all vertex attributes from the webGL context
  95615. */
  95616. unbindAllAttributes(): void;
  95617. /**
  95618. * 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
  95619. */
  95620. releaseEffects(): void;
  95621. /**
  95622. * Dispose and release all associated resources
  95623. */
  95624. dispose(): void;
  95625. /**
  95626. * Display the loading screen
  95627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95628. */
  95629. displayLoadingUI(): void;
  95630. /**
  95631. * Hide the loading screen
  95632. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95633. */
  95634. hideLoadingUI(): void;
  95635. /**
  95636. * Gets the current loading screen object
  95637. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95638. */
  95639. /**
  95640. * Sets the current loading screen object
  95641. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95642. */
  95643. loadingScreen: ILoadingScreen;
  95644. /**
  95645. * Sets the current loading screen text
  95646. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95647. */
  95648. loadingUIText: string;
  95649. /**
  95650. * Sets the current loading screen background color
  95651. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95652. */
  95653. loadingUIBackgroundColor: string;
  95654. /**
  95655. * Attach a new callback raised when context lost event is fired
  95656. * @param callback defines the callback to call
  95657. */
  95658. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95659. /**
  95660. * Attach a new callback raised when context restored event is fired
  95661. * @param callback defines the callback to call
  95662. */
  95663. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95664. /**
  95665. * Gets the source code of the vertex shader associated with a specific webGL program
  95666. * @param program defines the program to use
  95667. * @returns a string containing the source code of the vertex shader associated with the program
  95668. */
  95669. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95670. /**
  95671. * Gets the source code of the fragment shader associated with a specific webGL program
  95672. * @param program defines the program to use
  95673. * @returns a string containing the source code of the fragment shader associated with the program
  95674. */
  95675. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95676. /**
  95677. * Get the current error code of the webGL context
  95678. * @returns the error code
  95679. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95680. */
  95681. getError(): number;
  95682. /**
  95683. * Gets the current framerate
  95684. * @returns a number representing the framerate
  95685. */
  95686. getFps(): number;
  95687. /**
  95688. * Gets the time spent between current and previous frame
  95689. * @returns a number representing the delta time in ms
  95690. */
  95691. getDeltaTime(): number;
  95692. private _measureFps;
  95693. /** @hidden */
  95694. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95695. private _canRenderToFloatFramebuffer;
  95696. private _canRenderToHalfFloatFramebuffer;
  95697. private _canRenderToFramebuffer;
  95698. /** @hidden */
  95699. _getWebGLTextureType(type: number): number;
  95700. /** @hidden */
  95701. _getInternalFormat(format: number): number;
  95702. /** @hidden */
  95703. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95704. /** @hidden */
  95705. _getRGBAMultiSampleBufferFormat(type: number): number;
  95706. /** @hidden */
  95707. _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;
  95708. /** @hidden */
  95709. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95710. /**
  95711. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95712. * @returns true if the engine can be created
  95713. * @ignorenaming
  95714. */
  95715. static isSupported(): boolean;
  95716. /**
  95717. * Find the next highest power of two.
  95718. * @param x Number to start search from.
  95719. * @return Next highest power of two.
  95720. */
  95721. static CeilingPOT(x: number): number;
  95722. /**
  95723. * Find the next lowest power of two.
  95724. * @param x Number to start search from.
  95725. * @return Next lowest power of two.
  95726. */
  95727. static FloorPOT(x: number): number;
  95728. /**
  95729. * Find the nearest power of two.
  95730. * @param x Number to start search from.
  95731. * @return Next nearest power of two.
  95732. */
  95733. static NearestPOT(x: number): number;
  95734. /**
  95735. * Get the closest exponent of two
  95736. * @param value defines the value to approximate
  95737. * @param max defines the maximum value to return
  95738. * @param mode defines how to define the closest value
  95739. * @returns closest exponent of two of the given value
  95740. */
  95741. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95742. /**
  95743. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95744. * @param func - the function to be called
  95745. * @param requester - the object that will request the next frame. Falls back to window.
  95746. * @returns frame number
  95747. */
  95748. static QueueNewFrame(func: () => void, requester?: any): number;
  95749. /**
  95750. * Ask the browser to promote the current element to pointerlock mode
  95751. * @param element defines the DOM element to promote
  95752. */
  95753. static _RequestPointerlock(element: HTMLElement): void;
  95754. /**
  95755. * Asks the browser to exit pointerlock mode
  95756. */
  95757. static _ExitPointerlock(): void;
  95758. /**
  95759. * Ask the browser to promote the current element to fullscreen rendering mode
  95760. * @param element defines the DOM element to promote
  95761. */
  95762. static _RequestFullscreen(element: HTMLElement): void;
  95763. /**
  95764. * Asks the browser to exit fullscreen mode
  95765. */
  95766. static _ExitFullscreen(): void;
  95767. }
  95768. }
  95769. declare module BABYLON {
  95770. /**
  95771. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95772. * during the life time of the application.
  95773. */
  95774. export class EngineStore {
  95775. /** Gets the list of created engines */
  95776. static Instances: Engine[];
  95777. /** @hidden */
  95778. static _LastCreatedScene: Nullable<Scene>;
  95779. /**
  95780. * Gets the latest created engine
  95781. */
  95782. static readonly LastCreatedEngine: Nullable<Engine>;
  95783. /**
  95784. * Gets the latest created scene
  95785. */
  95786. static readonly LastCreatedScene: Nullable<Scene>;
  95787. /**
  95788. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95789. * @ignorenaming
  95790. */
  95791. static UseFallbackTexture: boolean;
  95792. /**
  95793. * Texture content used if a texture cannot loaded
  95794. * @ignorenaming
  95795. */
  95796. static FallbackTexture: string;
  95797. }
  95798. }
  95799. declare module BABYLON {
  95800. /**
  95801. * Helper class that provides a small promise polyfill
  95802. */
  95803. export class PromisePolyfill {
  95804. /**
  95805. * Static function used to check if the polyfill is required
  95806. * If this is the case then the function will inject the polyfill to window.Promise
  95807. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95808. */
  95809. static Apply(force?: boolean): void;
  95810. }
  95811. }
  95812. declare module BABYLON {
  95813. /**
  95814. * Interface for screenshot methods with describe argument called `size` as object with options
  95815. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  95816. */
  95817. export interface IScreenshotSize {
  95818. /**
  95819. * number in pixels for canvas height
  95820. */
  95821. height?: number;
  95822. /**
  95823. * multiplier allowing render at a higher or lower resolution
  95824. * If value is defined then height and width will be ignored and taken from camera
  95825. */
  95826. precision?: number;
  95827. /**
  95828. * number in pixels for canvas width
  95829. */
  95830. width?: number;
  95831. }
  95832. }
  95833. declare module BABYLON {
  95834. interface IColor4Like {
  95835. r: float;
  95836. g: float;
  95837. b: float;
  95838. a: float;
  95839. }
  95840. /**
  95841. * Class containing a set of static utilities functions
  95842. */
  95843. export class Tools {
  95844. /**
  95845. * Gets or sets the base URL to use to load assets
  95846. */
  95847. static BaseUrl: string;
  95848. /**
  95849. * Enable/Disable Custom HTTP Request Headers globally.
  95850. * default = false
  95851. * @see CustomRequestHeaders
  95852. */
  95853. static UseCustomRequestHeaders: boolean;
  95854. /**
  95855. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95856. * i.e. when loading files, where the server/service expects an Authorization header
  95857. */
  95858. static CustomRequestHeaders: {
  95859. [key: string]: string;
  95860. };
  95861. /**
  95862. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95863. */
  95864. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95865. /**
  95866. * Default behaviour for cors in the application.
  95867. * It can be a string if the expected behavior is identical in the entire app.
  95868. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95869. */
  95870. static CorsBehavior: string | ((url: string | string[]) => string);
  95871. /**
  95872. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95873. * @ignorenaming
  95874. */
  95875. static UseFallbackTexture: boolean;
  95876. /**
  95877. * Use this object to register external classes like custom textures or material
  95878. * to allow the laoders to instantiate them
  95879. */
  95880. static RegisteredExternalClasses: {
  95881. [key: string]: Object;
  95882. };
  95883. /**
  95884. * Texture content used if a texture cannot loaded
  95885. * @ignorenaming
  95886. */
  95887. static fallbackTexture: string;
  95888. /**
  95889. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95890. * @param u defines the coordinate on X axis
  95891. * @param v defines the coordinate on Y axis
  95892. * @param width defines the width of the source data
  95893. * @param height defines the height of the source data
  95894. * @param pixels defines the source byte array
  95895. * @param color defines the output color
  95896. */
  95897. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95898. /**
  95899. * Interpolates between a and b via alpha
  95900. * @param a The lower value (returned when alpha = 0)
  95901. * @param b The upper value (returned when alpha = 1)
  95902. * @param alpha The interpolation-factor
  95903. * @return The mixed value
  95904. */
  95905. static Mix(a: number, b: number, alpha: number): number;
  95906. /**
  95907. * Tries to instantiate a new object from a given class name
  95908. * @param className defines the class name to instantiate
  95909. * @returns the new object or null if the system was not able to do the instantiation
  95910. */
  95911. static Instantiate(className: string): any;
  95912. /**
  95913. * Provides a slice function that will work even on IE
  95914. * @param data defines the array to slice
  95915. * @param start defines the start of the data (optional)
  95916. * @param end defines the end of the data (optional)
  95917. * @returns the new sliced array
  95918. */
  95919. static Slice<T>(data: T, start?: number, end?: number): T;
  95920. /**
  95921. * Polyfill for setImmediate
  95922. * @param action defines the action to execute after the current execution block
  95923. */
  95924. static SetImmediate(action: () => void): void;
  95925. /**
  95926. * Function indicating if a number is an exponent of 2
  95927. * @param value defines the value to test
  95928. * @returns true if the value is an exponent of 2
  95929. */
  95930. static IsExponentOfTwo(value: number): boolean;
  95931. private static _tmpFloatArray;
  95932. /**
  95933. * Returns the nearest 32-bit single precision float representation of a Number
  95934. * @param value A Number. If the parameter is of a different type, it will get converted
  95935. * to a number or to NaN if it cannot be converted
  95936. * @returns number
  95937. */
  95938. static FloatRound(value: number): number;
  95939. /**
  95940. * Extracts the filename from a path
  95941. * @param path defines the path to use
  95942. * @returns the filename
  95943. */
  95944. static GetFilename(path: string): string;
  95945. /**
  95946. * Extracts the "folder" part of a path (everything before the filename).
  95947. * @param uri The URI to extract the info from
  95948. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95949. * @returns The "folder" part of the path
  95950. */
  95951. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95952. /**
  95953. * Extracts text content from a DOM element hierarchy
  95954. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95955. */
  95956. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95957. /**
  95958. * Convert an angle in radians to degrees
  95959. * @param angle defines the angle to convert
  95960. * @returns the angle in degrees
  95961. */
  95962. static ToDegrees(angle: number): number;
  95963. /**
  95964. * Convert an angle in degrees to radians
  95965. * @param angle defines the angle to convert
  95966. * @returns the angle in radians
  95967. */
  95968. static ToRadians(angle: number): number;
  95969. /**
  95970. * Encode a buffer to a base64 string
  95971. * @param buffer defines the buffer to encode
  95972. * @returns the encoded string
  95973. */
  95974. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95975. /**
  95976. * Returns an array if obj is not an array
  95977. * @param obj defines the object to evaluate as an array
  95978. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95979. * @returns either obj directly if obj is an array or a new array containing obj
  95980. */
  95981. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95982. /**
  95983. * Gets the pointer prefix to use
  95984. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95985. */
  95986. static GetPointerPrefix(): string;
  95987. /**
  95988. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95989. * @param url define the url we are trying
  95990. * @param element define the dom element where to configure the cors policy
  95991. */
  95992. static SetCorsBehavior(url: string | string[], element: {
  95993. crossOrigin: string | null;
  95994. }): void;
  95995. /**
  95996. * Removes unwanted characters from an url
  95997. * @param url defines the url to clean
  95998. * @returns the cleaned url
  95999. */
  96000. static CleanUrl(url: string): string;
  96001. /**
  96002. * Gets or sets a function used to pre-process url before using them to load assets
  96003. */
  96004. static PreprocessUrl: (url: string) => string;
  96005. /**
  96006. * Loads an image as an HTMLImageElement.
  96007. * @param input url string, ArrayBuffer, or Blob to load
  96008. * @param onLoad callback called when the image successfully loads
  96009. * @param onError callback called when the image fails to load
  96010. * @param offlineProvider offline provider for caching
  96011. * @returns the HTMLImageElement of the loaded image
  96012. */
  96013. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  96014. /**
  96015. * Loads a file
  96016. * @param url url string, ArrayBuffer, or Blob to load
  96017. * @param onSuccess callback called when the file successfully loads
  96018. * @param onProgress callback called while file is loading (if the server supports this mode)
  96019. * @param offlineProvider defines the offline provider for caching
  96020. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  96021. * @param onError callback called when the file fails to load
  96022. * @returns a file request object
  96023. */
  96024. 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;
  96025. /**
  96026. * Loads a file from a url
  96027. * @param url the file url to load
  96028. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  96029. */
  96030. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  96031. /**
  96032. * Load a script (identified by an url). When the url returns, the
  96033. * content of this file is added into a new script element, attached to the DOM (body element)
  96034. * @param scriptUrl defines the url of the script to laod
  96035. * @param onSuccess defines the callback called when the script is loaded
  96036. * @param onError defines the callback to call if an error occurs
  96037. * @param scriptId defines the id of the script element
  96038. */
  96039. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  96040. /**
  96041. * Load an asynchronous script (identified by an url). When the url returns, the
  96042. * content of this file is added into a new script element, attached to the DOM (body element)
  96043. * @param scriptUrl defines the url of the script to laod
  96044. * @param scriptId defines the id of the script element
  96045. * @returns a promise request object
  96046. */
  96047. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  96048. /**
  96049. * Loads a file from a blob
  96050. * @param fileToLoad defines the blob to use
  96051. * @param callback defines the callback to call when data is loaded
  96052. * @param progressCallback defines the callback to call during loading process
  96053. * @returns a file request object
  96054. */
  96055. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  96056. /**
  96057. * Loads a file
  96058. * @param fileToLoad defines the file to load
  96059. * @param callback defines the callback to call when data is loaded
  96060. * @param progressCallBack defines the callback to call during loading process
  96061. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  96062. * @returns a file request object
  96063. */
  96064. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  96065. /**
  96066. * Creates a data url from a given string content
  96067. * @param content defines the content to convert
  96068. * @returns the new data url link
  96069. */
  96070. static FileAsURL(content: string): string;
  96071. /**
  96072. * Format the given number to a specific decimal format
  96073. * @param value defines the number to format
  96074. * @param decimals defines the number of decimals to use
  96075. * @returns the formatted string
  96076. */
  96077. static Format(value: number, decimals?: number): string;
  96078. /**
  96079. * Tries to copy an object by duplicating every property
  96080. * @param source defines the source object
  96081. * @param destination defines the target object
  96082. * @param doNotCopyList defines a list of properties to avoid
  96083. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  96084. */
  96085. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  96086. /**
  96087. * Gets a boolean indicating if the given object has no own property
  96088. * @param obj defines the object to test
  96089. * @returns true if object has no own property
  96090. */
  96091. static IsEmpty(obj: any): boolean;
  96092. /**
  96093. * Function used to register events at window level
  96094. * @param windowElement defines the Window object to use
  96095. * @param events defines the events to register
  96096. */
  96097. static RegisterTopRootEvents(windowElement: Window, events: {
  96098. name: string;
  96099. handler: Nullable<(e: FocusEvent) => any>;
  96100. }[]): void;
  96101. /**
  96102. * Function used to unregister events from window level
  96103. * @param windowElement defines the Window object to use
  96104. * @param events defines the events to unregister
  96105. */
  96106. static UnregisterTopRootEvents(windowElement: Window, events: {
  96107. name: string;
  96108. handler: Nullable<(e: FocusEvent) => any>;
  96109. }[]): void;
  96110. /**
  96111. * @ignore
  96112. */
  96113. static _ScreenshotCanvas: HTMLCanvasElement;
  96114. /**
  96115. * Dumps the current bound framebuffer
  96116. * @param width defines the rendering width
  96117. * @param height defines the rendering height
  96118. * @param engine defines the hosting engine
  96119. * @param successCallback defines the callback triggered once the data are available
  96120. * @param mimeType defines the mime type of the result
  96121. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  96122. */
  96123. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96124. /**
  96125. * Converts the canvas data to blob.
  96126. * This acts as a polyfill for browsers not supporting the to blob function.
  96127. * @param canvas Defines the canvas to extract the data from
  96128. * @param successCallback Defines the callback triggered once the data are available
  96129. * @param mimeType Defines the mime type of the result
  96130. */
  96131. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  96132. /**
  96133. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  96134. * @param successCallback defines the callback triggered once the data are available
  96135. * @param mimeType defines the mime type of the result
  96136. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  96137. */
  96138. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  96139. /**
  96140. * Downloads a blob in the browser
  96141. * @param blob defines the blob to download
  96142. * @param fileName defines the name of the downloaded file
  96143. */
  96144. static Download(blob: Blob, fileName: string): void;
  96145. /**
  96146. * Captures a screenshot of the current rendering
  96147. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96148. * @param engine defines the rendering engine
  96149. * @param camera defines the source camera
  96150. * @param size This parameter can be set to a single number or to an object with the
  96151. * following (optional) properties: precision, width, height. If a single number is passed,
  96152. * it will be used for both width and height. If an object is passed, the screenshot size
  96153. * will be derived from the parameters. The precision property is a multiplier allowing
  96154. * rendering at a higher or lower resolution
  96155. * @param successCallback defines the callback receives a single parameter which contains the
  96156. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96157. * src parameter of an <img> to display it
  96158. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96159. * Check your browser for supported MIME types
  96160. */
  96161. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  96162. /**
  96163. * Captures a screenshot of the current rendering
  96164. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96165. * @param engine defines the rendering engine
  96166. * @param camera defines the source camera
  96167. * @param size This parameter can be set to a single number or to an object with the
  96168. * following (optional) properties: precision, width, height. If a single number is passed,
  96169. * it will be used for both width and height. If an object is passed, the screenshot size
  96170. * will be derived from the parameters. The precision property is a multiplier allowing
  96171. * rendering at a higher or lower resolution
  96172. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  96173. * Check your browser for supported MIME types
  96174. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96175. * to the src parameter of an <img> to display it
  96176. */
  96177. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  96178. /**
  96179. * Generates an image screenshot from the specified camera.
  96180. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96181. * @param engine The engine to use for rendering
  96182. * @param camera The camera to use for rendering
  96183. * @param size This parameter can be set to a single number or to an object with the
  96184. * following (optional) properties: precision, width, height. If a single number is passed,
  96185. * it will be used for both width and height. If an object is passed, the screenshot size
  96186. * will be derived from the parameters. The precision property is a multiplier allowing
  96187. * rendering at a higher or lower resolution
  96188. * @param successCallback The callback receives a single parameter which contains the
  96189. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  96190. * src parameter of an <img> to display it
  96191. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96192. * Check your browser for supported MIME types
  96193. * @param samples Texture samples (default: 1)
  96194. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96195. * @param fileName A name for for the downloaded file.
  96196. */
  96197. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  96198. /**
  96199. * Generates an image screenshot from the specified camera.
  96200. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  96201. * @param engine The engine to use for rendering
  96202. * @param camera The camera to use for rendering
  96203. * @param size This parameter can be set to a single number or to an object with the
  96204. * following (optional) properties: precision, width, height. If a single number is passed,
  96205. * it will be used for both width and height. If an object is passed, the screenshot size
  96206. * will be derived from the parameters. The precision property is a multiplier allowing
  96207. * rendering at a higher or lower resolution
  96208. * @param mimeType The MIME type of the screenshot image (default: image/png).
  96209. * Check your browser for supported MIME types
  96210. * @param samples Texture samples (default: 1)
  96211. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  96212. * @param fileName A name for for the downloaded file.
  96213. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  96214. * to the src parameter of an <img> to display it
  96215. */
  96216. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  96217. /**
  96218. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96219. * Be aware Math.random() could cause collisions, but:
  96220. * "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"
  96221. * @returns a pseudo random id
  96222. */
  96223. static RandomId(): string;
  96224. /**
  96225. * Test if the given uri is a base64 string
  96226. * @param uri The uri to test
  96227. * @return True if the uri is a base64 string or false otherwise
  96228. */
  96229. static IsBase64(uri: string): boolean;
  96230. /**
  96231. * Decode the given base64 uri.
  96232. * @param uri The uri to decode
  96233. * @return The decoded base64 data.
  96234. */
  96235. static DecodeBase64(uri: string): ArrayBuffer;
  96236. /**
  96237. * Gets the absolute url.
  96238. * @param url the input url
  96239. * @return the absolute url
  96240. */
  96241. static GetAbsoluteUrl(url: string): string;
  96242. /**
  96243. * No log
  96244. */
  96245. static readonly NoneLogLevel: number;
  96246. /**
  96247. * Only message logs
  96248. */
  96249. static readonly MessageLogLevel: number;
  96250. /**
  96251. * Only warning logs
  96252. */
  96253. static readonly WarningLogLevel: number;
  96254. /**
  96255. * Only error logs
  96256. */
  96257. static readonly ErrorLogLevel: number;
  96258. /**
  96259. * All logs
  96260. */
  96261. static readonly AllLogLevel: number;
  96262. /**
  96263. * Gets a value indicating the number of loading errors
  96264. * @ignorenaming
  96265. */
  96266. static readonly errorsCount: number;
  96267. /**
  96268. * Callback called when a new log is added
  96269. */
  96270. static OnNewCacheEntry: (entry: string) => void;
  96271. /**
  96272. * Log a message to the console
  96273. * @param message defines the message to log
  96274. */
  96275. static Log(message: string): void;
  96276. /**
  96277. * Write a warning message to the console
  96278. * @param message defines the message to log
  96279. */
  96280. static Warn(message: string): void;
  96281. /**
  96282. * Write an error message to the console
  96283. * @param message defines the message to log
  96284. */
  96285. static Error(message: string): void;
  96286. /**
  96287. * Gets current log cache (list of logs)
  96288. */
  96289. static readonly LogCache: string;
  96290. /**
  96291. * Clears the log cache
  96292. */
  96293. static ClearLogCache(): void;
  96294. /**
  96295. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  96296. */
  96297. static LogLevels: number;
  96298. /**
  96299. * Checks if the window object exists
  96300. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  96301. */
  96302. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  96303. /**
  96304. * No performance log
  96305. */
  96306. static readonly PerformanceNoneLogLevel: number;
  96307. /**
  96308. * Use user marks to log performance
  96309. */
  96310. static readonly PerformanceUserMarkLogLevel: number;
  96311. /**
  96312. * Log performance to the console
  96313. */
  96314. static readonly PerformanceConsoleLogLevel: number;
  96315. private static _performance;
  96316. /**
  96317. * Sets the current performance log level
  96318. */
  96319. static PerformanceLogLevel: number;
  96320. private static _StartPerformanceCounterDisabled;
  96321. private static _EndPerformanceCounterDisabled;
  96322. private static _StartUserMark;
  96323. private static _EndUserMark;
  96324. private static _StartPerformanceConsole;
  96325. private static _EndPerformanceConsole;
  96326. /**
  96327. * Starts a performance counter
  96328. */
  96329. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96330. /**
  96331. * Ends a specific performance coutner
  96332. */
  96333. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  96334. /**
  96335. * Gets either window.performance.now() if supported or Date.now() else
  96336. */
  96337. static readonly Now: number;
  96338. /**
  96339. * This method will return the name of the class used to create the instance of the given object.
  96340. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  96341. * @param object the object to get the class name from
  96342. * @param isType defines if the object is actually a type
  96343. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  96344. */
  96345. static GetClassName(object: any, isType?: boolean): string;
  96346. /**
  96347. * Gets the first element of an array satisfying a given predicate
  96348. * @param array defines the array to browse
  96349. * @param predicate defines the predicate to use
  96350. * @returns null if not found or the element
  96351. */
  96352. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  96353. /**
  96354. * This method will return the name of the full name of the class, including its owning module (if any).
  96355. * 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).
  96356. * @param object the object to get the class name from
  96357. * @param isType defines if the object is actually a type
  96358. * @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.
  96359. * @ignorenaming
  96360. */
  96361. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96362. /**
  96363. * Returns a promise that resolves after the given amount of time.
  96364. * @param delay Number of milliseconds to delay
  96365. * @returns Promise that resolves after the given amount of time
  96366. */
  96367. static DelayAsync(delay: number): Promise<void>;
  96368. }
  96369. /**
  96370. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96371. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96372. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96373. * @param name The name of the class, case should be preserved
  96374. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96375. */
  96376. export function className(name: string, module?: string): (target: Object) => void;
  96377. /**
  96378. * An implementation of a loop for asynchronous functions.
  96379. */
  96380. export class AsyncLoop {
  96381. /**
  96382. * Defines the number of iterations for the loop
  96383. */
  96384. iterations: number;
  96385. /**
  96386. * Defines the current index of the loop.
  96387. */
  96388. index: number;
  96389. private _done;
  96390. private _fn;
  96391. private _successCallback;
  96392. /**
  96393. * Constructor.
  96394. * @param iterations the number of iterations.
  96395. * @param func the function to run each iteration
  96396. * @param successCallback the callback that will be called upon succesful execution
  96397. * @param offset starting offset.
  96398. */
  96399. constructor(
  96400. /**
  96401. * Defines the number of iterations for the loop
  96402. */
  96403. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96404. /**
  96405. * Execute the next iteration. Must be called after the last iteration was finished.
  96406. */
  96407. executeNext(): void;
  96408. /**
  96409. * Break the loop and run the success callback.
  96410. */
  96411. breakLoop(): void;
  96412. /**
  96413. * Create and run an async loop.
  96414. * @param iterations the number of iterations.
  96415. * @param fn the function to run each iteration
  96416. * @param successCallback the callback that will be called upon succesful execution
  96417. * @param offset starting offset.
  96418. * @returns the created async loop object
  96419. */
  96420. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96421. /**
  96422. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96423. * @param iterations total number of iterations
  96424. * @param syncedIterations number of synchronous iterations in each async iteration.
  96425. * @param fn the function to call each iteration.
  96426. * @param callback a success call back that will be called when iterating stops.
  96427. * @param breakFunction a break condition (optional)
  96428. * @param timeout timeout settings for the setTimeout function. default - 0.
  96429. * @returns the created async loop object
  96430. */
  96431. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96432. }
  96433. }
  96434. declare module BABYLON {
  96435. /** @hidden */
  96436. export interface ICollisionCoordinator {
  96437. createCollider(): Collider;
  96438. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96439. init(scene: Scene): void;
  96440. }
  96441. /** @hidden */
  96442. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96443. private _scene;
  96444. private _scaledPosition;
  96445. private _scaledVelocity;
  96446. private _finalPosition;
  96447. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96448. createCollider(): Collider;
  96449. init(scene: Scene): void;
  96450. private _collideWithWorld;
  96451. }
  96452. }
  96453. declare module BABYLON {
  96454. /**
  96455. * Class used to manage all inputs for the scene.
  96456. */
  96457. export class InputManager {
  96458. /** The distance in pixel that you have to move to prevent some events */
  96459. static DragMovementThreshold: number;
  96460. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96461. static LongPressDelay: number;
  96462. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96463. static DoubleClickDelay: number;
  96464. /** If you need to check double click without raising a single click at first click, enable this flag */
  96465. static ExclusiveDoubleClickMode: boolean;
  96466. private _wheelEventName;
  96467. private _onPointerMove;
  96468. private _onPointerDown;
  96469. private _onPointerUp;
  96470. private _initClickEvent;
  96471. private _initActionManager;
  96472. private _delayedSimpleClick;
  96473. private _delayedSimpleClickTimeout;
  96474. private _previousDelayedSimpleClickTimeout;
  96475. private _meshPickProceed;
  96476. private _previousButtonPressed;
  96477. private _currentPickResult;
  96478. private _previousPickResult;
  96479. private _totalPointersPressed;
  96480. private _doubleClickOccured;
  96481. private _pointerOverMesh;
  96482. private _pickedDownMesh;
  96483. private _pickedUpMesh;
  96484. private _pointerX;
  96485. private _pointerY;
  96486. private _unTranslatedPointerX;
  96487. private _unTranslatedPointerY;
  96488. private _startingPointerPosition;
  96489. private _previousStartingPointerPosition;
  96490. private _startingPointerTime;
  96491. private _previousStartingPointerTime;
  96492. private _pointerCaptures;
  96493. private _onKeyDown;
  96494. private _onKeyUp;
  96495. private _onCanvasFocusObserver;
  96496. private _onCanvasBlurObserver;
  96497. private _scene;
  96498. /**
  96499. * Creates a new InputManager
  96500. * @param scene defines the hosting scene
  96501. */
  96502. constructor(scene: Scene);
  96503. /**
  96504. * Gets the mesh that is currently under the pointer
  96505. */
  96506. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96507. /**
  96508. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96509. */
  96510. readonly unTranslatedPointer: Vector2;
  96511. /**
  96512. * Gets or sets the current on-screen X position of the pointer
  96513. */
  96514. pointerX: number;
  96515. /**
  96516. * Gets or sets the current on-screen Y position of the pointer
  96517. */
  96518. pointerY: number;
  96519. private _updatePointerPosition;
  96520. private _processPointerMove;
  96521. private _setRayOnPointerInfo;
  96522. private _checkPrePointerObservable;
  96523. /**
  96524. * Use this method to simulate a pointer move on a mesh
  96525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96528. */
  96529. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96530. /**
  96531. * Use this method to simulate a pointer down on a mesh
  96532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96535. */
  96536. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96537. private _processPointerDown;
  96538. /** @hidden */
  96539. _isPointerSwiping(): boolean;
  96540. /**
  96541. * Use this method to simulate a pointer up on a mesh
  96542. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96543. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96544. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96545. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96546. */
  96547. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96548. private _processPointerUp;
  96549. /**
  96550. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96551. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96552. * @returns true if the pointer was captured
  96553. */
  96554. isPointerCaptured(pointerId?: number): boolean;
  96555. /**
  96556. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96557. * @param attachUp defines if you want to attach events to pointerup
  96558. * @param attachDown defines if you want to attach events to pointerdown
  96559. * @param attachMove defines if you want to attach events to pointermove
  96560. */
  96561. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96562. /**
  96563. * Detaches all event handlers
  96564. */
  96565. detachControl(): void;
  96566. /**
  96567. * Force the value of meshUnderPointer
  96568. * @param mesh defines the mesh to use
  96569. */
  96570. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96571. /**
  96572. * Gets the mesh under the pointer
  96573. * @returns a Mesh or null if no mesh is under the pointer
  96574. */
  96575. getPointerOverMesh(): Nullable<AbstractMesh>;
  96576. }
  96577. }
  96578. declare module BABYLON {
  96579. /**
  96580. * Helper class used to generate session unique ID
  96581. */
  96582. export class UniqueIdGenerator {
  96583. private static _UniqueIdCounter;
  96584. /**
  96585. * Gets an unique (relatively to the current scene) Id
  96586. */
  96587. static readonly UniqueId: number;
  96588. }
  96589. }
  96590. declare module BABYLON {
  96591. /**
  96592. * This class defines the direct association between an animation and a target
  96593. */
  96594. export class TargetedAnimation {
  96595. /**
  96596. * Animation to perform
  96597. */
  96598. animation: Animation;
  96599. /**
  96600. * Target to animate
  96601. */
  96602. target: any;
  96603. /**
  96604. * Serialize the object
  96605. * @returns the JSON object representing the current entity
  96606. */
  96607. serialize(): any;
  96608. }
  96609. /**
  96610. * Use this class to create coordinated animations on multiple targets
  96611. */
  96612. export class AnimationGroup implements IDisposable {
  96613. /** The name of the animation group */
  96614. name: string;
  96615. private _scene;
  96616. private _targetedAnimations;
  96617. private _animatables;
  96618. private _from;
  96619. private _to;
  96620. private _isStarted;
  96621. private _isPaused;
  96622. private _speedRatio;
  96623. private _loopAnimation;
  96624. /**
  96625. * Gets or sets the unique id of the node
  96626. */
  96627. uniqueId: number;
  96628. /**
  96629. * This observable will notify when one animation have ended
  96630. */
  96631. onAnimationEndObservable: Observable<TargetedAnimation>;
  96632. /**
  96633. * Observer raised when one animation loops
  96634. */
  96635. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96636. /**
  96637. * This observable will notify when all animations have ended.
  96638. */
  96639. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96640. /**
  96641. * This observable will notify when all animations have paused.
  96642. */
  96643. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96644. /**
  96645. * This observable will notify when all animations are playing.
  96646. */
  96647. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96648. /**
  96649. * Gets the first frame
  96650. */
  96651. readonly from: number;
  96652. /**
  96653. * Gets the last frame
  96654. */
  96655. readonly to: number;
  96656. /**
  96657. * Define if the animations are started
  96658. */
  96659. readonly isStarted: boolean;
  96660. /**
  96661. * Gets a value indicating that the current group is playing
  96662. */
  96663. readonly isPlaying: boolean;
  96664. /**
  96665. * Gets or sets the speed ratio to use for all animations
  96666. */
  96667. /**
  96668. * Gets or sets the speed ratio to use for all animations
  96669. */
  96670. speedRatio: number;
  96671. /**
  96672. * Gets or sets if all animations should loop or not
  96673. */
  96674. loopAnimation: boolean;
  96675. /**
  96676. * Gets the targeted animations for this animation group
  96677. */
  96678. readonly targetedAnimations: Array<TargetedAnimation>;
  96679. /**
  96680. * returning the list of animatables controlled by this animation group.
  96681. */
  96682. readonly animatables: Array<Animatable>;
  96683. /**
  96684. * Instantiates a new Animation Group.
  96685. * This helps managing several animations at once.
  96686. * @see http://doc.babylonjs.com/how_to/group
  96687. * @param name Defines the name of the group
  96688. * @param scene Defines the scene the group belongs to
  96689. */
  96690. constructor(
  96691. /** The name of the animation group */
  96692. name: string, scene?: Nullable<Scene>);
  96693. /**
  96694. * Add an animation (with its target) in the group
  96695. * @param animation defines the animation we want to add
  96696. * @param target defines the target of the animation
  96697. * @returns the TargetedAnimation object
  96698. */
  96699. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96700. /**
  96701. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96702. * It can add constant keys at begin or end
  96703. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96704. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96705. * @returns the animation group
  96706. */
  96707. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96708. /**
  96709. * Start all animations on given targets
  96710. * @param loop defines if animations must loop
  96711. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96712. * @param from defines the from key (optional)
  96713. * @param to defines the to key (optional)
  96714. * @returns the current animation group
  96715. */
  96716. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96717. /**
  96718. * Pause all animations
  96719. * @returns the animation group
  96720. */
  96721. pause(): AnimationGroup;
  96722. /**
  96723. * Play all animations to initial state
  96724. * This function will start() the animations if they were not started or will restart() them if they were paused
  96725. * @param loop defines if animations must loop
  96726. * @returns the animation group
  96727. */
  96728. play(loop?: boolean): AnimationGroup;
  96729. /**
  96730. * Reset all animations to initial state
  96731. * @returns the animation group
  96732. */
  96733. reset(): AnimationGroup;
  96734. /**
  96735. * Restart animations from key 0
  96736. * @returns the animation group
  96737. */
  96738. restart(): AnimationGroup;
  96739. /**
  96740. * Stop all animations
  96741. * @returns the animation group
  96742. */
  96743. stop(): AnimationGroup;
  96744. /**
  96745. * Set animation weight for all animatables
  96746. * @param weight defines the weight to use
  96747. * @return the animationGroup
  96748. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96749. */
  96750. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96751. /**
  96752. * Synchronize and normalize all animatables with a source animatable
  96753. * @param root defines the root animatable to synchronize with
  96754. * @return the animationGroup
  96755. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96756. */
  96757. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96758. /**
  96759. * Goes to a specific frame in this animation group
  96760. * @param frame the frame number to go to
  96761. * @return the animationGroup
  96762. */
  96763. goToFrame(frame: number): AnimationGroup;
  96764. /**
  96765. * Dispose all associated resources
  96766. */
  96767. dispose(): void;
  96768. private _checkAnimationGroupEnded;
  96769. /**
  96770. * Clone the current animation group and returns a copy
  96771. * @param newName defines the name of the new group
  96772. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96773. * @returns the new aniamtion group
  96774. */
  96775. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96776. /**
  96777. * Serializes the animationGroup to an object
  96778. * @returns Serialized object
  96779. */
  96780. serialize(): any;
  96781. /**
  96782. * Returns a new AnimationGroup object parsed from the source provided.
  96783. * @param parsedAnimationGroup defines the source
  96784. * @param scene defines the scene that will receive the animationGroup
  96785. * @returns a new AnimationGroup
  96786. */
  96787. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96788. /**
  96789. * Returns the string "AnimationGroup"
  96790. * @returns "AnimationGroup"
  96791. */
  96792. getClassName(): string;
  96793. /**
  96794. * Creates a detailled string about the object
  96795. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96796. * @returns a string representing the object
  96797. */
  96798. toString(fullDetails?: boolean): string;
  96799. }
  96800. }
  96801. declare module BABYLON {
  96802. /**
  96803. * Define an interface for all classes that will hold resources
  96804. */
  96805. export interface IDisposable {
  96806. /**
  96807. * Releases all held resources
  96808. */
  96809. dispose(): void;
  96810. }
  96811. /** Interface defining initialization parameters for Scene class */
  96812. export interface SceneOptions {
  96813. /**
  96814. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96815. * It will improve performance when the number of geometries becomes important.
  96816. */
  96817. useGeometryUniqueIdsMap?: boolean;
  96818. /**
  96819. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96820. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96821. */
  96822. useMaterialMeshMap?: boolean;
  96823. /**
  96824. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96825. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96826. */
  96827. useClonedMeshhMap?: boolean;
  96828. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96829. virtual?: boolean;
  96830. }
  96831. /**
  96832. * Represents a scene to be rendered by the engine.
  96833. * @see http://doc.babylonjs.com/features/scene
  96834. */
  96835. export class Scene extends AbstractScene implements IAnimatable {
  96836. /** The fog is deactivated */
  96837. static readonly FOGMODE_NONE: number;
  96838. /** The fog density is following an exponential function */
  96839. static readonly FOGMODE_EXP: number;
  96840. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96841. static readonly FOGMODE_EXP2: number;
  96842. /** The fog density is following a linear function. */
  96843. static readonly FOGMODE_LINEAR: number;
  96844. /**
  96845. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96846. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96847. */
  96848. static MinDeltaTime: number;
  96849. /**
  96850. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96851. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96852. */
  96853. static MaxDeltaTime: number;
  96854. /**
  96855. * Factory used to create the default material.
  96856. * @param name The name of the material to create
  96857. * @param scene The scene to create the material for
  96858. * @returns The default material
  96859. */
  96860. static DefaultMaterialFactory(scene: Scene): Material;
  96861. /**
  96862. * Factory used to create the a collision coordinator.
  96863. * @returns The collision coordinator
  96864. */
  96865. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96866. /** @hidden */
  96867. _inputManager: InputManager;
  96868. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96869. cameraToUseForPointers: Nullable<Camera>;
  96870. /** @hidden */
  96871. readonly _isScene: boolean;
  96872. /**
  96873. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96874. */
  96875. autoClear: boolean;
  96876. /**
  96877. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96878. */
  96879. autoClearDepthAndStencil: boolean;
  96880. /**
  96881. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96882. */
  96883. clearColor: Color4;
  96884. /**
  96885. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96886. */
  96887. ambientColor: Color3;
  96888. /**
  96889. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96890. * It should only be one of the following (if not the default embedded one):
  96891. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96892. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96893. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96894. * The material properties need to be setup according to the type of texture in use.
  96895. */
  96896. environmentBRDFTexture: BaseTexture;
  96897. /** @hidden */
  96898. protected _environmentTexture: Nullable<BaseTexture>;
  96899. /**
  96900. * Texture used in all pbr material as the reflection texture.
  96901. * As in the majority of the scene they are the same (exception for multi room and so on),
  96902. * this is easier to reference from here than from all the materials.
  96903. */
  96904. /**
  96905. * Texture used in all pbr material as the reflection texture.
  96906. * As in the majority of the scene they are the same (exception for multi room and so on),
  96907. * this is easier to set here than in all the materials.
  96908. */
  96909. environmentTexture: Nullable<BaseTexture>;
  96910. /** @hidden */
  96911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96912. /**
  96913. * Default image processing configuration used either in the rendering
  96914. * Forward main pass or through the imageProcessingPostProcess if present.
  96915. * As in the majority of the scene they are the same (exception for multi camera),
  96916. * this is easier to reference from here than from all the materials and post process.
  96917. *
  96918. * No setter as we it is a shared configuration, you can set the values instead.
  96919. */
  96920. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96921. private _forceWireframe;
  96922. /**
  96923. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96924. */
  96925. forceWireframe: boolean;
  96926. private _forcePointsCloud;
  96927. /**
  96928. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96929. */
  96930. forcePointsCloud: boolean;
  96931. /**
  96932. * Gets or sets the active clipplane 1
  96933. */
  96934. clipPlane: Nullable<Plane>;
  96935. /**
  96936. * Gets or sets the active clipplane 2
  96937. */
  96938. clipPlane2: Nullable<Plane>;
  96939. /**
  96940. * Gets or sets the active clipplane 3
  96941. */
  96942. clipPlane3: Nullable<Plane>;
  96943. /**
  96944. * Gets or sets the active clipplane 4
  96945. */
  96946. clipPlane4: Nullable<Plane>;
  96947. /**
  96948. * Gets or sets a boolean indicating if animations are enabled
  96949. */
  96950. animationsEnabled: boolean;
  96951. private _animationPropertiesOverride;
  96952. /**
  96953. * Gets or sets the animation properties override
  96954. */
  96955. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96956. /**
  96957. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96958. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96959. */
  96960. useConstantAnimationDeltaTime: boolean;
  96961. /**
  96962. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96963. * Please note that it requires to run a ray cast through the scene on every frame
  96964. */
  96965. constantlyUpdateMeshUnderPointer: boolean;
  96966. /**
  96967. * Defines the HTML cursor to use when hovering over interactive elements
  96968. */
  96969. hoverCursor: string;
  96970. /**
  96971. * Defines the HTML default cursor to use (empty by default)
  96972. */
  96973. defaultCursor: string;
  96974. /**
  96975. * This is used to call preventDefault() on pointer down
  96976. * in order to block unwanted artifacts like system double clicks
  96977. */
  96978. preventDefaultOnPointerDown: boolean;
  96979. /**
  96980. * This is used to call preventDefault() on pointer up
  96981. * in order to block unwanted artifacts like system double clicks
  96982. */
  96983. preventDefaultOnPointerUp: boolean;
  96984. /**
  96985. * Gets or sets user defined metadata
  96986. */
  96987. metadata: any;
  96988. /**
  96989. * For internal use only. Please do not use.
  96990. */
  96991. reservedDataStore: any;
  96992. /**
  96993. * Gets the name of the plugin used to load this scene (null by default)
  96994. */
  96995. loadingPluginName: string;
  96996. /**
  96997. * Use this array to add regular expressions used to disable offline support for specific urls
  96998. */
  96999. disableOfflineSupportExceptionRules: RegExp[];
  97000. /**
  97001. * An event triggered when the scene is disposed.
  97002. */
  97003. onDisposeObservable: Observable<Scene>;
  97004. private _onDisposeObserver;
  97005. /** Sets a function to be executed when this scene is disposed. */
  97006. onDispose: () => void;
  97007. /**
  97008. * An event triggered before rendering the scene (right after animations and physics)
  97009. */
  97010. onBeforeRenderObservable: Observable<Scene>;
  97011. private _onBeforeRenderObserver;
  97012. /** Sets a function to be executed before rendering this scene */
  97013. beforeRender: Nullable<() => void>;
  97014. /**
  97015. * An event triggered after rendering the scene
  97016. */
  97017. onAfterRenderObservable: Observable<Scene>;
  97018. /**
  97019. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  97020. */
  97021. onAfterRenderCameraObservable: Observable<Camera>;
  97022. private _onAfterRenderObserver;
  97023. /** Sets a function to be executed after rendering this scene */
  97024. afterRender: Nullable<() => void>;
  97025. /**
  97026. * An event triggered before animating the scene
  97027. */
  97028. onBeforeAnimationsObservable: Observable<Scene>;
  97029. /**
  97030. * An event triggered after animations processing
  97031. */
  97032. onAfterAnimationsObservable: Observable<Scene>;
  97033. /**
  97034. * An event triggered before draw calls are ready to be sent
  97035. */
  97036. onBeforeDrawPhaseObservable: Observable<Scene>;
  97037. /**
  97038. * An event triggered after draw calls have been sent
  97039. */
  97040. onAfterDrawPhaseObservable: Observable<Scene>;
  97041. /**
  97042. * An event triggered when the scene is ready
  97043. */
  97044. onReadyObservable: Observable<Scene>;
  97045. /**
  97046. * An event triggered before rendering a camera
  97047. */
  97048. onBeforeCameraRenderObservable: Observable<Camera>;
  97049. private _onBeforeCameraRenderObserver;
  97050. /** Sets a function to be executed before rendering a camera*/
  97051. beforeCameraRender: () => void;
  97052. /**
  97053. * An event triggered after rendering a camera
  97054. */
  97055. onAfterCameraRenderObservable: Observable<Camera>;
  97056. private _onAfterCameraRenderObserver;
  97057. /** Sets a function to be executed after rendering a camera*/
  97058. afterCameraRender: () => void;
  97059. /**
  97060. * An event triggered when active meshes evaluation is about to start
  97061. */
  97062. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  97063. /**
  97064. * An event triggered when active meshes evaluation is done
  97065. */
  97066. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  97067. /**
  97068. * An event triggered when particles rendering is about to start
  97069. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97070. */
  97071. onBeforeParticlesRenderingObservable: Observable<Scene>;
  97072. /**
  97073. * An event triggered when particles rendering is done
  97074. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  97075. */
  97076. onAfterParticlesRenderingObservable: Observable<Scene>;
  97077. /**
  97078. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  97079. */
  97080. onDataLoadedObservable: Observable<Scene>;
  97081. /**
  97082. * An event triggered when a camera is created
  97083. */
  97084. onNewCameraAddedObservable: Observable<Camera>;
  97085. /**
  97086. * An event triggered when a camera is removed
  97087. */
  97088. onCameraRemovedObservable: Observable<Camera>;
  97089. /**
  97090. * An event triggered when a light is created
  97091. */
  97092. onNewLightAddedObservable: Observable<Light>;
  97093. /**
  97094. * An event triggered when a light is removed
  97095. */
  97096. onLightRemovedObservable: Observable<Light>;
  97097. /**
  97098. * An event triggered when a geometry is created
  97099. */
  97100. onNewGeometryAddedObservable: Observable<Geometry>;
  97101. /**
  97102. * An event triggered when a geometry is removed
  97103. */
  97104. onGeometryRemovedObservable: Observable<Geometry>;
  97105. /**
  97106. * An event triggered when a transform node is created
  97107. */
  97108. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  97109. /**
  97110. * An event triggered when a transform node is removed
  97111. */
  97112. onTransformNodeRemovedObservable: Observable<TransformNode>;
  97113. /**
  97114. * An event triggered when a mesh is created
  97115. */
  97116. onNewMeshAddedObservable: Observable<AbstractMesh>;
  97117. /**
  97118. * An event triggered when a mesh is removed
  97119. */
  97120. onMeshRemovedObservable: Observable<AbstractMesh>;
  97121. /**
  97122. * An event triggered when a skeleton is created
  97123. */
  97124. onNewSkeletonAddedObservable: Observable<Skeleton>;
  97125. /**
  97126. * An event triggered when a skeleton is removed
  97127. */
  97128. onSkeletonRemovedObservable: Observable<Skeleton>;
  97129. /**
  97130. * An event triggered when a material is created
  97131. */
  97132. onNewMaterialAddedObservable: Observable<Material>;
  97133. /**
  97134. * An event triggered when a material is removed
  97135. */
  97136. onMaterialRemovedObservable: Observable<Material>;
  97137. /**
  97138. * An event triggered when a texture is created
  97139. */
  97140. onNewTextureAddedObservable: Observable<BaseTexture>;
  97141. /**
  97142. * An event triggered when a texture is removed
  97143. */
  97144. onTextureRemovedObservable: Observable<BaseTexture>;
  97145. /**
  97146. * An event triggered when render targets are about to be rendered
  97147. * Can happen multiple times per frame.
  97148. */
  97149. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  97150. /**
  97151. * An event triggered when render targets were rendered.
  97152. * Can happen multiple times per frame.
  97153. */
  97154. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  97155. /**
  97156. * An event triggered before calculating deterministic simulation step
  97157. */
  97158. onBeforeStepObservable: Observable<Scene>;
  97159. /**
  97160. * An event triggered after calculating deterministic simulation step
  97161. */
  97162. onAfterStepObservable: Observable<Scene>;
  97163. /**
  97164. * An event triggered when the activeCamera property is updated
  97165. */
  97166. onActiveCameraChanged: Observable<Scene>;
  97167. /**
  97168. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  97169. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97170. * 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)
  97171. */
  97172. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97173. /**
  97174. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  97175. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  97176. * 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)
  97177. */
  97178. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  97179. /**
  97180. * This Observable will when a mesh has been imported into the scene.
  97181. */
  97182. onMeshImportedObservable: Observable<AbstractMesh>;
  97183. /**
  97184. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  97185. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  97186. */
  97187. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  97188. /** @hidden */
  97189. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  97190. /**
  97191. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  97192. */
  97193. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  97194. /**
  97195. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  97196. */
  97197. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  97198. /**
  97199. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  97200. */
  97201. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  97202. /** Callback called when a pointer move is detected */
  97203. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97204. /** Callback called when a pointer down is detected */
  97205. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  97206. /** Callback called when a pointer up is detected */
  97207. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  97208. /** Callback called when a pointer pick is detected */
  97209. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  97210. /**
  97211. * 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).
  97212. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  97213. */
  97214. onPrePointerObservable: Observable<PointerInfoPre>;
  97215. /**
  97216. * Observable event triggered each time an input event is received from the rendering canvas
  97217. */
  97218. onPointerObservable: Observable<PointerInfo>;
  97219. /**
  97220. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  97221. */
  97222. readonly unTranslatedPointer: Vector2;
  97223. /**
  97224. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  97225. */
  97226. static DragMovementThreshold: number;
  97227. /**
  97228. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  97229. */
  97230. static LongPressDelay: number;
  97231. /**
  97232. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  97233. */
  97234. static DoubleClickDelay: number;
  97235. /** If you need to check double click without raising a single click at first click, enable this flag */
  97236. static ExclusiveDoubleClickMode: boolean;
  97237. /** @hidden */
  97238. _mirroredCameraPosition: Nullable<Vector3>;
  97239. /**
  97240. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  97241. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  97242. */
  97243. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  97244. /**
  97245. * Observable event triggered each time an keyboard event is received from the hosting window
  97246. */
  97247. onKeyboardObservable: Observable<KeyboardInfo>;
  97248. private _useRightHandedSystem;
  97249. /**
  97250. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  97251. */
  97252. useRightHandedSystem: boolean;
  97253. private _timeAccumulator;
  97254. private _currentStepId;
  97255. private _currentInternalStep;
  97256. /**
  97257. * Sets the step Id used by deterministic lock step
  97258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97259. * @param newStepId defines the step Id
  97260. */
  97261. setStepId(newStepId: number): void;
  97262. /**
  97263. * Gets the step Id used by deterministic lock step
  97264. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97265. * @returns the step Id
  97266. */
  97267. getStepId(): number;
  97268. /**
  97269. * Gets the internal step used by deterministic lock step
  97270. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97271. * @returns the internal step
  97272. */
  97273. getInternalStep(): number;
  97274. private _fogEnabled;
  97275. /**
  97276. * Gets or sets a boolean indicating if fog is enabled on this scene
  97277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97278. * (Default is true)
  97279. */
  97280. fogEnabled: boolean;
  97281. private _fogMode;
  97282. /**
  97283. * Gets or sets the fog mode to use
  97284. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97285. * | mode | value |
  97286. * | --- | --- |
  97287. * | FOGMODE_NONE | 0 |
  97288. * | FOGMODE_EXP | 1 |
  97289. * | FOGMODE_EXP2 | 2 |
  97290. * | FOGMODE_LINEAR | 3 |
  97291. */
  97292. fogMode: number;
  97293. /**
  97294. * Gets or sets the fog color to use
  97295. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97296. * (Default is Color3(0.2, 0.2, 0.3))
  97297. */
  97298. fogColor: Color3;
  97299. /**
  97300. * Gets or sets the fog density to use
  97301. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97302. * (Default is 0.1)
  97303. */
  97304. fogDensity: number;
  97305. /**
  97306. * Gets or sets the fog start distance to use
  97307. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97308. * (Default is 0)
  97309. */
  97310. fogStart: number;
  97311. /**
  97312. * Gets or sets the fog end distance to use
  97313. * @see http://doc.babylonjs.com/babylon101/environment#fog
  97314. * (Default is 1000)
  97315. */
  97316. fogEnd: number;
  97317. private _shadowsEnabled;
  97318. /**
  97319. * Gets or sets a boolean indicating if shadows are enabled on this scene
  97320. */
  97321. shadowsEnabled: boolean;
  97322. private _lightsEnabled;
  97323. /**
  97324. * Gets or sets a boolean indicating if lights are enabled on this scene
  97325. */
  97326. lightsEnabled: boolean;
  97327. /** All of the active cameras added to this scene. */
  97328. activeCameras: Camera[];
  97329. /** @hidden */
  97330. _activeCamera: Nullable<Camera>;
  97331. /** Gets or sets the current active camera */
  97332. activeCamera: Nullable<Camera>;
  97333. private _defaultMaterial;
  97334. /** The default material used on meshes when no material is affected */
  97335. /** The default material used on meshes when no material is affected */
  97336. defaultMaterial: Material;
  97337. private _texturesEnabled;
  97338. /**
  97339. * Gets or sets a boolean indicating if textures are enabled on this scene
  97340. */
  97341. texturesEnabled: boolean;
  97342. /**
  97343. * Gets or sets a boolean indicating if particles are enabled on this scene
  97344. */
  97345. particlesEnabled: boolean;
  97346. /**
  97347. * Gets or sets a boolean indicating if sprites are enabled on this scene
  97348. */
  97349. spritesEnabled: boolean;
  97350. private _skeletonsEnabled;
  97351. /**
  97352. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  97353. */
  97354. skeletonsEnabled: boolean;
  97355. /**
  97356. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  97357. */
  97358. lensFlaresEnabled: boolean;
  97359. /**
  97360. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97361. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97362. */
  97363. collisionsEnabled: boolean;
  97364. private _collisionCoordinator;
  97365. /** @hidden */
  97366. readonly collisionCoordinator: ICollisionCoordinator;
  97367. /**
  97368. * Defines the gravity applied to this scene (used only for collisions)
  97369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97370. */
  97371. gravity: Vector3;
  97372. /**
  97373. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97374. */
  97375. postProcessesEnabled: boolean;
  97376. /**
  97377. * The list of postprocesses added to the scene
  97378. */
  97379. postProcesses: PostProcess[];
  97380. /**
  97381. * Gets the current postprocess manager
  97382. */
  97383. postProcessManager: PostProcessManager;
  97384. /**
  97385. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97386. */
  97387. renderTargetsEnabled: boolean;
  97388. /**
  97389. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97390. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97391. */
  97392. dumpNextRenderTargets: boolean;
  97393. /**
  97394. * The list of user defined render targets added to the scene
  97395. */
  97396. customRenderTargets: RenderTargetTexture[];
  97397. /**
  97398. * Defines if texture loading must be delayed
  97399. * If true, textures will only be loaded when they need to be rendered
  97400. */
  97401. useDelayedTextureLoading: boolean;
  97402. /**
  97403. * Gets the list of meshes imported to the scene through SceneLoader
  97404. */
  97405. importedMeshesFiles: String[];
  97406. /**
  97407. * Gets or sets a boolean indicating if probes are enabled on this scene
  97408. */
  97409. probesEnabled: boolean;
  97410. /**
  97411. * Gets or sets the current offline provider to use to store scene data
  97412. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97413. */
  97414. offlineProvider: IOfflineProvider;
  97415. /**
  97416. * Gets or sets the action manager associated with the scene
  97417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97418. */
  97419. actionManager: AbstractActionManager;
  97420. private _meshesForIntersections;
  97421. /**
  97422. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97423. */
  97424. proceduralTexturesEnabled: boolean;
  97425. private _engine;
  97426. private _totalVertices;
  97427. /** @hidden */
  97428. _activeIndices: PerfCounter;
  97429. /** @hidden */
  97430. _activeParticles: PerfCounter;
  97431. /** @hidden */
  97432. _activeBones: PerfCounter;
  97433. private _animationRatio;
  97434. /** @hidden */
  97435. _animationTimeLast: number;
  97436. /** @hidden */
  97437. _animationTime: number;
  97438. /**
  97439. * Gets or sets a general scale for animation speed
  97440. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97441. */
  97442. animationTimeScale: number;
  97443. /** @hidden */
  97444. _cachedMaterial: Nullable<Material>;
  97445. /** @hidden */
  97446. _cachedEffect: Nullable<Effect>;
  97447. /** @hidden */
  97448. _cachedVisibility: Nullable<number>;
  97449. private _renderId;
  97450. private _frameId;
  97451. private _executeWhenReadyTimeoutId;
  97452. private _intermediateRendering;
  97453. private _viewUpdateFlag;
  97454. private _projectionUpdateFlag;
  97455. /** @hidden */
  97456. _toBeDisposed: Nullable<IDisposable>[];
  97457. private _activeRequests;
  97458. /** @hidden */
  97459. _pendingData: any[];
  97460. private _isDisposed;
  97461. /**
  97462. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97463. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97464. */
  97465. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97466. private _activeMeshes;
  97467. private _processedMaterials;
  97468. private _renderTargets;
  97469. /** @hidden */
  97470. _activeParticleSystems: SmartArray<IParticleSystem>;
  97471. private _activeSkeletons;
  97472. private _softwareSkinnedMeshes;
  97473. private _renderingManager;
  97474. /** @hidden */
  97475. _activeAnimatables: Animatable[];
  97476. private _transformMatrix;
  97477. private _sceneUbo;
  97478. /** @hidden */
  97479. _viewMatrix: Matrix;
  97480. private _projectionMatrix;
  97481. /** @hidden */
  97482. _forcedViewPosition: Nullable<Vector3>;
  97483. /** @hidden */
  97484. _frustumPlanes: Plane[];
  97485. /**
  97486. * Gets the list of frustum planes (built from the active camera)
  97487. */
  97488. readonly frustumPlanes: Plane[];
  97489. /**
  97490. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97491. * This is useful if there are more lights that the maximum simulteanous authorized
  97492. */
  97493. requireLightSorting: boolean;
  97494. /** @hidden */
  97495. readonly useMaterialMeshMap: boolean;
  97496. /** @hidden */
  97497. readonly useClonedMeshhMap: boolean;
  97498. private _externalData;
  97499. private _uid;
  97500. /**
  97501. * @hidden
  97502. * Backing store of defined scene components.
  97503. */
  97504. _components: ISceneComponent[];
  97505. /**
  97506. * @hidden
  97507. * Backing store of defined scene components.
  97508. */
  97509. _serializableComponents: ISceneSerializableComponent[];
  97510. /**
  97511. * List of components to register on the next registration step.
  97512. */
  97513. private _transientComponents;
  97514. /**
  97515. * Registers the transient components if needed.
  97516. */
  97517. private _registerTransientComponents;
  97518. /**
  97519. * @hidden
  97520. * Add a component to the scene.
  97521. * Note that the ccomponent could be registered on th next frame if this is called after
  97522. * the register component stage.
  97523. * @param component Defines the component to add to the scene
  97524. */
  97525. _addComponent(component: ISceneComponent): void;
  97526. /**
  97527. * @hidden
  97528. * Gets a component from the scene.
  97529. * @param name defines the name of the component to retrieve
  97530. * @returns the component or null if not present
  97531. */
  97532. _getComponent(name: string): Nullable<ISceneComponent>;
  97533. /**
  97534. * @hidden
  97535. * Defines the actions happening before camera updates.
  97536. */
  97537. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97538. /**
  97539. * @hidden
  97540. * Defines the actions happening before clear the canvas.
  97541. */
  97542. _beforeClearStage: Stage<SimpleStageAction>;
  97543. /**
  97544. * @hidden
  97545. * Defines the actions when collecting render targets for the frame.
  97546. */
  97547. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97548. /**
  97549. * @hidden
  97550. * Defines the actions happening for one camera in the frame.
  97551. */
  97552. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97553. /**
  97554. * @hidden
  97555. * Defines the actions happening during the per mesh ready checks.
  97556. */
  97557. _isReadyForMeshStage: Stage<MeshStageAction>;
  97558. /**
  97559. * @hidden
  97560. * Defines the actions happening before evaluate active mesh checks.
  97561. */
  97562. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97563. /**
  97564. * @hidden
  97565. * Defines the actions happening during the evaluate sub mesh checks.
  97566. */
  97567. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97568. /**
  97569. * @hidden
  97570. * Defines the actions happening during the active mesh stage.
  97571. */
  97572. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97573. /**
  97574. * @hidden
  97575. * Defines the actions happening during the per camera render target step.
  97576. */
  97577. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97578. /**
  97579. * @hidden
  97580. * Defines the actions happening just before the active camera is drawing.
  97581. */
  97582. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97583. /**
  97584. * @hidden
  97585. * Defines the actions happening just before a render target is drawing.
  97586. */
  97587. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97588. /**
  97589. * @hidden
  97590. * Defines the actions happening just before a rendering group is drawing.
  97591. */
  97592. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97593. /**
  97594. * @hidden
  97595. * Defines the actions happening just before a mesh is drawing.
  97596. */
  97597. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97598. /**
  97599. * @hidden
  97600. * Defines the actions happening just after a mesh has been drawn.
  97601. */
  97602. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97603. /**
  97604. * @hidden
  97605. * Defines the actions happening just after a rendering group has been drawn.
  97606. */
  97607. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97608. /**
  97609. * @hidden
  97610. * Defines the actions happening just after the active camera has been drawn.
  97611. */
  97612. _afterCameraDrawStage: Stage<CameraStageAction>;
  97613. /**
  97614. * @hidden
  97615. * Defines the actions happening just after a render target has been drawn.
  97616. */
  97617. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97618. /**
  97619. * @hidden
  97620. * Defines the actions happening just after rendering all cameras and computing intersections.
  97621. */
  97622. _afterRenderStage: Stage<SimpleStageAction>;
  97623. /**
  97624. * @hidden
  97625. * Defines the actions happening when a pointer move event happens.
  97626. */
  97627. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97628. /**
  97629. * @hidden
  97630. * Defines the actions happening when a pointer down event happens.
  97631. */
  97632. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97633. /**
  97634. * @hidden
  97635. * Defines the actions happening when a pointer up event happens.
  97636. */
  97637. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97638. /**
  97639. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97640. */
  97641. private geometriesByUniqueId;
  97642. /**
  97643. * Creates a new Scene
  97644. * @param engine defines the engine to use to render this scene
  97645. * @param options defines the scene options
  97646. */
  97647. constructor(engine: Engine, options?: SceneOptions);
  97648. /**
  97649. * Gets a string idenfifying the name of the class
  97650. * @returns "Scene" string
  97651. */
  97652. getClassName(): string;
  97653. private _defaultMeshCandidates;
  97654. /**
  97655. * @hidden
  97656. */
  97657. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97658. private _defaultSubMeshCandidates;
  97659. /**
  97660. * @hidden
  97661. */
  97662. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97663. /**
  97664. * Sets the default candidate providers for the scene.
  97665. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97666. * and getCollidingSubMeshCandidates to their default function
  97667. */
  97668. setDefaultCandidateProviders(): void;
  97669. /**
  97670. * Gets the mesh that is currently under the pointer
  97671. */
  97672. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97673. /**
  97674. * Gets or sets the current on-screen X position of the pointer
  97675. */
  97676. pointerX: number;
  97677. /**
  97678. * Gets or sets the current on-screen Y position of the pointer
  97679. */
  97680. pointerY: number;
  97681. /**
  97682. * Gets the cached material (ie. the latest rendered one)
  97683. * @returns the cached material
  97684. */
  97685. getCachedMaterial(): Nullable<Material>;
  97686. /**
  97687. * Gets the cached effect (ie. the latest rendered one)
  97688. * @returns the cached effect
  97689. */
  97690. getCachedEffect(): Nullable<Effect>;
  97691. /**
  97692. * Gets the cached visibility state (ie. the latest rendered one)
  97693. * @returns the cached visibility state
  97694. */
  97695. getCachedVisibility(): Nullable<number>;
  97696. /**
  97697. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97698. * @param material defines the current material
  97699. * @param effect defines the current effect
  97700. * @param visibility defines the current visibility state
  97701. * @returns true if one parameter is not cached
  97702. */
  97703. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97704. /**
  97705. * Gets the engine associated with the scene
  97706. * @returns an Engine
  97707. */
  97708. getEngine(): Engine;
  97709. /**
  97710. * Gets the total number of vertices rendered per frame
  97711. * @returns the total number of vertices rendered per frame
  97712. */
  97713. getTotalVertices(): number;
  97714. /**
  97715. * Gets the performance counter for total vertices
  97716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97717. */
  97718. readonly totalVerticesPerfCounter: PerfCounter;
  97719. /**
  97720. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97721. * @returns the total number of active indices rendered per frame
  97722. */
  97723. getActiveIndices(): number;
  97724. /**
  97725. * Gets the performance counter for active indices
  97726. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97727. */
  97728. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97729. /**
  97730. * Gets the total number of active particles rendered per frame
  97731. * @returns the total number of active particles rendered per frame
  97732. */
  97733. getActiveParticles(): number;
  97734. /**
  97735. * Gets the performance counter for active particles
  97736. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97737. */
  97738. readonly activeParticlesPerfCounter: PerfCounter;
  97739. /**
  97740. * Gets the total number of active bones rendered per frame
  97741. * @returns the total number of active bones rendered per frame
  97742. */
  97743. getActiveBones(): number;
  97744. /**
  97745. * Gets the performance counter for active bones
  97746. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97747. */
  97748. readonly activeBonesPerfCounter: PerfCounter;
  97749. /**
  97750. * Gets the array of active meshes
  97751. * @returns an array of AbstractMesh
  97752. */
  97753. getActiveMeshes(): SmartArray<AbstractMesh>;
  97754. /**
  97755. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97756. * @returns a number
  97757. */
  97758. getAnimationRatio(): number;
  97759. /**
  97760. * Gets an unique Id for the current render phase
  97761. * @returns a number
  97762. */
  97763. getRenderId(): number;
  97764. /**
  97765. * Gets an unique Id for the current frame
  97766. * @returns a number
  97767. */
  97768. getFrameId(): number;
  97769. /** Call this function if you want to manually increment the render Id*/
  97770. incrementRenderId(): void;
  97771. private _createUbo;
  97772. /**
  97773. * Use this method to simulate a pointer move on a mesh
  97774. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97775. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97776. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97777. * @returns the current scene
  97778. */
  97779. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97780. /**
  97781. * Use this method to simulate a pointer down on a mesh
  97782. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97783. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97784. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97785. * @returns the current scene
  97786. */
  97787. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97788. /**
  97789. * Use this method to simulate a pointer up on a mesh
  97790. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97791. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97792. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97793. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97794. * @returns the current scene
  97795. */
  97796. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97797. /**
  97798. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97799. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97800. * @returns true if the pointer was captured
  97801. */
  97802. isPointerCaptured(pointerId?: number): boolean;
  97803. /**
  97804. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97805. * @param attachUp defines if you want to attach events to pointerup
  97806. * @param attachDown defines if you want to attach events to pointerdown
  97807. * @param attachMove defines if you want to attach events to pointermove
  97808. */
  97809. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97810. /** Detaches all event handlers*/
  97811. detachControl(): void;
  97812. /**
  97813. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97814. * Delay loaded resources are not taking in account
  97815. * @return true if all required resources are ready
  97816. */
  97817. isReady(): boolean;
  97818. /** Resets all cached information relative to material (including effect and visibility) */
  97819. resetCachedMaterial(): void;
  97820. /**
  97821. * Registers a function to be called before every frame render
  97822. * @param func defines the function to register
  97823. */
  97824. registerBeforeRender(func: () => void): void;
  97825. /**
  97826. * Unregisters a function called before every frame render
  97827. * @param func defines the function to unregister
  97828. */
  97829. unregisterBeforeRender(func: () => void): void;
  97830. /**
  97831. * Registers a function to be called after every frame render
  97832. * @param func defines the function to register
  97833. */
  97834. registerAfterRender(func: () => void): void;
  97835. /**
  97836. * Unregisters a function called after every frame render
  97837. * @param func defines the function to unregister
  97838. */
  97839. unregisterAfterRender(func: () => void): void;
  97840. private _executeOnceBeforeRender;
  97841. /**
  97842. * The provided function will run before render once and will be disposed afterwards.
  97843. * A timeout delay can be provided so that the function will be executed in N ms.
  97844. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97845. * @param func The function to be executed.
  97846. * @param timeout optional delay in ms
  97847. */
  97848. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97849. /** @hidden */
  97850. _addPendingData(data: any): void;
  97851. /** @hidden */
  97852. _removePendingData(data: any): void;
  97853. /**
  97854. * Returns the number of items waiting to be loaded
  97855. * @returns the number of items waiting to be loaded
  97856. */
  97857. getWaitingItemsCount(): number;
  97858. /**
  97859. * Returns a boolean indicating if the scene is still loading data
  97860. */
  97861. readonly isLoading: boolean;
  97862. /**
  97863. * Registers a function to be executed when the scene is ready
  97864. * @param {Function} func - the function to be executed
  97865. */
  97866. executeWhenReady(func: () => void): void;
  97867. /**
  97868. * Returns a promise that resolves when the scene is ready
  97869. * @returns A promise that resolves when the scene is ready
  97870. */
  97871. whenReadyAsync(): Promise<void>;
  97872. /** @hidden */
  97873. _checkIsReady(): void;
  97874. /**
  97875. * Gets all animatable attached to the scene
  97876. */
  97877. readonly animatables: Animatable[];
  97878. /**
  97879. * Resets the last animation time frame.
  97880. * Useful to override when animations start running when loading a scene for the first time.
  97881. */
  97882. resetLastAnimationTimeFrame(): void;
  97883. /**
  97884. * Gets the current view matrix
  97885. * @returns a Matrix
  97886. */
  97887. getViewMatrix(): Matrix;
  97888. /**
  97889. * Gets the current projection matrix
  97890. * @returns a Matrix
  97891. */
  97892. getProjectionMatrix(): Matrix;
  97893. /**
  97894. * Gets the current transform matrix
  97895. * @returns a Matrix made of View * Projection
  97896. */
  97897. getTransformMatrix(): Matrix;
  97898. /**
  97899. * Sets the current transform matrix
  97900. * @param viewL defines the View matrix to use
  97901. * @param projectionL defines the Projection matrix to use
  97902. * @param viewR defines the right View matrix to use (if provided)
  97903. * @param projectionR defines the right Projection matrix to use (if provided)
  97904. */
  97905. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97906. /**
  97907. * Gets the uniform buffer used to store scene data
  97908. * @returns a UniformBuffer
  97909. */
  97910. getSceneUniformBuffer(): UniformBuffer;
  97911. /**
  97912. * Gets an unique (relatively to the current scene) Id
  97913. * @returns an unique number for the scene
  97914. */
  97915. getUniqueId(): number;
  97916. /**
  97917. * Add a mesh to the list of scene's meshes
  97918. * @param newMesh defines the mesh to add
  97919. * @param recursive if all child meshes should also be added to the scene
  97920. */
  97921. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97922. /**
  97923. * Remove a mesh for the list of scene's meshes
  97924. * @param toRemove defines the mesh to remove
  97925. * @param recursive if all child meshes should also be removed from the scene
  97926. * @returns the index where the mesh was in the mesh list
  97927. */
  97928. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97929. /**
  97930. * Add a transform node to the list of scene's transform nodes
  97931. * @param newTransformNode defines the transform node to add
  97932. */
  97933. addTransformNode(newTransformNode: TransformNode): void;
  97934. /**
  97935. * Remove a transform node for the list of scene's transform nodes
  97936. * @param toRemove defines the transform node to remove
  97937. * @returns the index where the transform node was in the transform node list
  97938. */
  97939. removeTransformNode(toRemove: TransformNode): number;
  97940. /**
  97941. * Remove a skeleton for the list of scene's skeletons
  97942. * @param toRemove defines the skeleton to remove
  97943. * @returns the index where the skeleton was in the skeleton list
  97944. */
  97945. removeSkeleton(toRemove: Skeleton): number;
  97946. /**
  97947. * Remove a morph target for the list of scene's morph targets
  97948. * @param toRemove defines the morph target to remove
  97949. * @returns the index where the morph target was in the morph target list
  97950. */
  97951. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97952. /**
  97953. * Remove a light for the list of scene's lights
  97954. * @param toRemove defines the light to remove
  97955. * @returns the index where the light was in the light list
  97956. */
  97957. removeLight(toRemove: Light): number;
  97958. /**
  97959. * Remove a camera for the list of scene's cameras
  97960. * @param toRemove defines the camera to remove
  97961. * @returns the index where the camera was in the camera list
  97962. */
  97963. removeCamera(toRemove: Camera): number;
  97964. /**
  97965. * Remove a particle system for the list of scene's particle systems
  97966. * @param toRemove defines the particle system to remove
  97967. * @returns the index where the particle system was in the particle system list
  97968. */
  97969. removeParticleSystem(toRemove: IParticleSystem): number;
  97970. /**
  97971. * Remove a animation for the list of scene's animations
  97972. * @param toRemove defines the animation to remove
  97973. * @returns the index where the animation was in the animation list
  97974. */
  97975. removeAnimation(toRemove: Animation): number;
  97976. /**
  97977. * Will stop the animation of the given target
  97978. * @param target - the target
  97979. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97980. * @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)
  97981. */
  97982. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97983. /**
  97984. * Removes the given animation group from this scene.
  97985. * @param toRemove The animation group to remove
  97986. * @returns The index of the removed animation group
  97987. */
  97988. removeAnimationGroup(toRemove: AnimationGroup): number;
  97989. /**
  97990. * Removes the given multi-material from this scene.
  97991. * @param toRemove The multi-material to remove
  97992. * @returns The index of the removed multi-material
  97993. */
  97994. removeMultiMaterial(toRemove: MultiMaterial): number;
  97995. /**
  97996. * Removes the given material from this scene.
  97997. * @param toRemove The material to remove
  97998. * @returns The index of the removed material
  97999. */
  98000. removeMaterial(toRemove: Material): number;
  98001. /**
  98002. * Removes the given action manager from this scene.
  98003. * @param toRemove The action manager to remove
  98004. * @returns The index of the removed action manager
  98005. */
  98006. removeActionManager(toRemove: AbstractActionManager): number;
  98007. /**
  98008. * Removes the given texture from this scene.
  98009. * @param toRemove The texture to remove
  98010. * @returns The index of the removed texture
  98011. */
  98012. removeTexture(toRemove: BaseTexture): number;
  98013. /**
  98014. * Adds the given light to this scene
  98015. * @param newLight The light to add
  98016. */
  98017. addLight(newLight: Light): void;
  98018. /**
  98019. * Sorts the list list based on light priorities
  98020. */
  98021. sortLightsByPriority(): void;
  98022. /**
  98023. * Adds the given camera to this scene
  98024. * @param newCamera The camera to add
  98025. */
  98026. addCamera(newCamera: Camera): void;
  98027. /**
  98028. * Adds the given skeleton to this scene
  98029. * @param newSkeleton The skeleton to add
  98030. */
  98031. addSkeleton(newSkeleton: Skeleton): void;
  98032. /**
  98033. * Adds the given particle system to this scene
  98034. * @param newParticleSystem The particle system to add
  98035. */
  98036. addParticleSystem(newParticleSystem: IParticleSystem): void;
  98037. /**
  98038. * Adds the given animation to this scene
  98039. * @param newAnimation The animation to add
  98040. */
  98041. addAnimation(newAnimation: Animation): void;
  98042. /**
  98043. * Adds the given animation group to this scene.
  98044. * @param newAnimationGroup The animation group to add
  98045. */
  98046. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  98047. /**
  98048. * Adds the given multi-material to this scene
  98049. * @param newMultiMaterial The multi-material to add
  98050. */
  98051. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  98052. /**
  98053. * Adds the given material to this scene
  98054. * @param newMaterial The material to add
  98055. */
  98056. addMaterial(newMaterial: Material): void;
  98057. /**
  98058. * Adds the given morph target to this scene
  98059. * @param newMorphTargetManager The morph target to add
  98060. */
  98061. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  98062. /**
  98063. * Adds the given geometry to this scene
  98064. * @param newGeometry The geometry to add
  98065. */
  98066. addGeometry(newGeometry: Geometry): void;
  98067. /**
  98068. * Adds the given action manager to this scene
  98069. * @param newActionManager The action manager to add
  98070. */
  98071. addActionManager(newActionManager: AbstractActionManager): void;
  98072. /**
  98073. * Adds the given texture to this scene.
  98074. * @param newTexture The texture to add
  98075. */
  98076. addTexture(newTexture: BaseTexture): void;
  98077. /**
  98078. * Switch active camera
  98079. * @param newCamera defines the new active camera
  98080. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  98081. */
  98082. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  98083. /**
  98084. * sets the active camera of the scene using its ID
  98085. * @param id defines the camera's ID
  98086. * @return the new active camera or null if none found.
  98087. */
  98088. setActiveCameraByID(id: string): Nullable<Camera>;
  98089. /**
  98090. * sets the active camera of the scene using its name
  98091. * @param name defines the camera's name
  98092. * @returns the new active camera or null if none found.
  98093. */
  98094. setActiveCameraByName(name: string): Nullable<Camera>;
  98095. /**
  98096. * get an animation group using its name
  98097. * @param name defines the material's name
  98098. * @return the animation group or null if none found.
  98099. */
  98100. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  98101. /**
  98102. * Get a material using its unique id
  98103. * @param uniqueId defines the material's unique id
  98104. * @return the material or null if none found.
  98105. */
  98106. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  98107. /**
  98108. * get a material using its id
  98109. * @param id defines the material's ID
  98110. * @return the material or null if none found.
  98111. */
  98112. getMaterialByID(id: string): Nullable<Material>;
  98113. /**
  98114. * Gets a the last added material using a given id
  98115. * @param id defines the material's ID
  98116. * @return the last material with the given id or null if none found.
  98117. */
  98118. getLastMaterialByID(id: string): Nullable<Material>;
  98119. /**
  98120. * Gets a material using its name
  98121. * @param name defines the material's name
  98122. * @return the material or null if none found.
  98123. */
  98124. getMaterialByName(name: string): Nullable<Material>;
  98125. /**
  98126. * Get a texture using its unique id
  98127. * @param uniqueId defines the texture's unique id
  98128. * @return the texture or null if none found.
  98129. */
  98130. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  98131. /**
  98132. * Gets a camera using its id
  98133. * @param id defines the id to look for
  98134. * @returns the camera or null if not found
  98135. */
  98136. getCameraByID(id: string): Nullable<Camera>;
  98137. /**
  98138. * Gets a camera using its unique id
  98139. * @param uniqueId defines the unique id to look for
  98140. * @returns the camera or null if not found
  98141. */
  98142. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  98143. /**
  98144. * Gets a camera using its name
  98145. * @param name defines the camera's name
  98146. * @return the camera or null if none found.
  98147. */
  98148. getCameraByName(name: string): Nullable<Camera>;
  98149. /**
  98150. * Gets a bone using its id
  98151. * @param id defines the bone's id
  98152. * @return the bone or null if not found
  98153. */
  98154. getBoneByID(id: string): Nullable<Bone>;
  98155. /**
  98156. * Gets a bone using its id
  98157. * @param name defines the bone's name
  98158. * @return the bone or null if not found
  98159. */
  98160. getBoneByName(name: string): Nullable<Bone>;
  98161. /**
  98162. * Gets a light node using its name
  98163. * @param name defines the the light's name
  98164. * @return the light or null if none found.
  98165. */
  98166. getLightByName(name: string): Nullable<Light>;
  98167. /**
  98168. * Gets a light node using its id
  98169. * @param id defines the light's id
  98170. * @return the light or null if none found.
  98171. */
  98172. getLightByID(id: string): Nullable<Light>;
  98173. /**
  98174. * Gets a light node using its scene-generated unique ID
  98175. * @param uniqueId defines the light's unique id
  98176. * @return the light or null if none found.
  98177. */
  98178. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  98179. /**
  98180. * Gets a particle system by id
  98181. * @param id defines the particle system id
  98182. * @return the corresponding system or null if none found
  98183. */
  98184. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  98185. /**
  98186. * Gets a geometry using its ID
  98187. * @param id defines the geometry's id
  98188. * @return the geometry or null if none found.
  98189. */
  98190. getGeometryByID(id: string): Nullable<Geometry>;
  98191. private _getGeometryByUniqueID;
  98192. /**
  98193. * Add a new geometry to this scene
  98194. * @param geometry defines the geometry to be added to the scene.
  98195. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  98196. * @return a boolean defining if the geometry was added or not
  98197. */
  98198. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  98199. /**
  98200. * Removes an existing geometry
  98201. * @param geometry defines the geometry to be removed from the scene
  98202. * @return a boolean defining if the geometry was removed or not
  98203. */
  98204. removeGeometry(geometry: Geometry): boolean;
  98205. /**
  98206. * Gets the list of geometries attached to the scene
  98207. * @returns an array of Geometry
  98208. */
  98209. getGeometries(): Geometry[];
  98210. /**
  98211. * Gets the first added mesh found of a given ID
  98212. * @param id defines the id to search for
  98213. * @return the mesh found or null if not found at all
  98214. */
  98215. getMeshByID(id: string): Nullable<AbstractMesh>;
  98216. /**
  98217. * Gets a list of meshes using their id
  98218. * @param id defines the id to search for
  98219. * @returns a list of meshes
  98220. */
  98221. getMeshesByID(id: string): Array<AbstractMesh>;
  98222. /**
  98223. * Gets the first added transform node found of a given ID
  98224. * @param id defines the id to search for
  98225. * @return the found transform node or null if not found at all.
  98226. */
  98227. getTransformNodeByID(id: string): Nullable<TransformNode>;
  98228. /**
  98229. * Gets a transform node with its auto-generated unique id
  98230. * @param uniqueId efines the unique id to search for
  98231. * @return the found transform node or null if not found at all.
  98232. */
  98233. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  98234. /**
  98235. * Gets a list of transform nodes using their id
  98236. * @param id defines the id to search for
  98237. * @returns a list of transform nodes
  98238. */
  98239. getTransformNodesByID(id: string): Array<TransformNode>;
  98240. /**
  98241. * Gets a mesh with its auto-generated unique id
  98242. * @param uniqueId defines the unique id to search for
  98243. * @return the found mesh or null if not found at all.
  98244. */
  98245. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  98246. /**
  98247. * Gets a the last added mesh using a given id
  98248. * @param id defines the id to search for
  98249. * @return the found mesh or null if not found at all.
  98250. */
  98251. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  98252. /**
  98253. * Gets a the last added node (Mesh, Camera, Light) using a given id
  98254. * @param id defines the id to search for
  98255. * @return the found node or null if not found at all
  98256. */
  98257. getLastEntryByID(id: string): Nullable<Node>;
  98258. /**
  98259. * Gets a node (Mesh, Camera, Light) using a given id
  98260. * @param id defines the id to search for
  98261. * @return the found node or null if not found at all
  98262. */
  98263. getNodeByID(id: string): Nullable<Node>;
  98264. /**
  98265. * Gets a node (Mesh, Camera, Light) using a given name
  98266. * @param name defines the name to search for
  98267. * @return the found node or null if not found at all.
  98268. */
  98269. getNodeByName(name: string): Nullable<Node>;
  98270. /**
  98271. * Gets a mesh using a given name
  98272. * @param name defines the name to search for
  98273. * @return the found mesh or null if not found at all.
  98274. */
  98275. getMeshByName(name: string): Nullable<AbstractMesh>;
  98276. /**
  98277. * Gets a transform node using a given name
  98278. * @param name defines the name to search for
  98279. * @return the found transform node or null if not found at all.
  98280. */
  98281. getTransformNodeByName(name: string): Nullable<TransformNode>;
  98282. /**
  98283. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  98284. * @param id defines the id to search for
  98285. * @return the found skeleton or null if not found at all.
  98286. */
  98287. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  98288. /**
  98289. * Gets a skeleton using a given auto generated unique id
  98290. * @param uniqueId defines the unique id to search for
  98291. * @return the found skeleton or null if not found at all.
  98292. */
  98293. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  98294. /**
  98295. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  98296. * @param id defines the id to search for
  98297. * @return the found skeleton or null if not found at all.
  98298. */
  98299. getSkeletonById(id: string): Nullable<Skeleton>;
  98300. /**
  98301. * Gets a skeleton using a given name
  98302. * @param name defines the name to search for
  98303. * @return the found skeleton or null if not found at all.
  98304. */
  98305. getSkeletonByName(name: string): Nullable<Skeleton>;
  98306. /**
  98307. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  98308. * @param id defines the id to search for
  98309. * @return the found morph target manager or null if not found at all.
  98310. */
  98311. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  98312. /**
  98313. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  98314. * @param id defines the id to search for
  98315. * @return the found morph target or null if not found at all.
  98316. */
  98317. getMorphTargetById(id: string): Nullable<MorphTarget>;
  98318. /**
  98319. * Gets a boolean indicating if the given mesh is active
  98320. * @param mesh defines the mesh to look for
  98321. * @returns true if the mesh is in the active list
  98322. */
  98323. isActiveMesh(mesh: AbstractMesh): boolean;
  98324. /**
  98325. * Return a unique id as a string which can serve as an identifier for the scene
  98326. */
  98327. readonly uid: string;
  98328. /**
  98329. * Add an externaly attached data from its key.
  98330. * This method call will fail and return false, if such key already exists.
  98331. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  98332. * @param key the unique key that identifies the data
  98333. * @param data the data object to associate to the key for this Engine instance
  98334. * @return true if no such key were already present and the data was added successfully, false otherwise
  98335. */
  98336. addExternalData<T>(key: string, data: T): boolean;
  98337. /**
  98338. * Get an externaly attached data from its key
  98339. * @param key the unique key that identifies the data
  98340. * @return the associated data, if present (can be null), or undefined if not present
  98341. */
  98342. getExternalData<T>(key: string): Nullable<T>;
  98343. /**
  98344. * Get an externaly attached data from its key, create it using a factory if it's not already present
  98345. * @param key the unique key that identifies the data
  98346. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  98347. * @return the associated data, can be null if the factory returned null.
  98348. */
  98349. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  98350. /**
  98351. * Remove an externaly attached data from the Engine instance
  98352. * @param key the unique key that identifies the data
  98353. * @return true if the data was successfully removed, false if it doesn't exist
  98354. */
  98355. removeExternalData(key: string): boolean;
  98356. private _evaluateSubMesh;
  98357. /**
  98358. * Clear the processed materials smart array preventing retention point in material dispose.
  98359. */
  98360. freeProcessedMaterials(): void;
  98361. private _preventFreeActiveMeshesAndRenderingGroups;
  98362. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  98363. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98364. * when disposing several meshes in a row or a hierarchy of meshes.
  98365. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98366. */
  98367. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98368. /**
  98369. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98370. */
  98371. freeActiveMeshes(): void;
  98372. /**
  98373. * Clear the info related to rendering groups preventing retention points during dispose.
  98374. */
  98375. freeRenderingGroups(): void;
  98376. /** @hidden */
  98377. _isInIntermediateRendering(): boolean;
  98378. /**
  98379. * Lambda returning the list of potentially active meshes.
  98380. */
  98381. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98382. /**
  98383. * Lambda returning the list of potentially active sub meshes.
  98384. */
  98385. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98386. /**
  98387. * Lambda returning the list of potentially intersecting sub meshes.
  98388. */
  98389. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98390. /**
  98391. * Lambda returning the list of potentially colliding sub meshes.
  98392. */
  98393. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98394. private _activeMeshesFrozen;
  98395. /**
  98396. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98397. * @returns the current scene
  98398. */
  98399. freezeActiveMeshes(): Scene;
  98400. /**
  98401. * Use this function to restart evaluating active meshes on every frame
  98402. * @returns the current scene
  98403. */
  98404. unfreezeActiveMeshes(): Scene;
  98405. private _evaluateActiveMeshes;
  98406. private _activeMesh;
  98407. /**
  98408. * Update the transform matrix to update from the current active camera
  98409. * @param force defines a boolean used to force the update even if cache is up to date
  98410. */
  98411. updateTransformMatrix(force?: boolean): void;
  98412. private _bindFrameBuffer;
  98413. /** @hidden */
  98414. _allowPostProcessClearColor: boolean;
  98415. /** @hidden */
  98416. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98417. private _processSubCameras;
  98418. private _checkIntersections;
  98419. /** @hidden */
  98420. _advancePhysicsEngineStep(step: number): void;
  98421. /**
  98422. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98423. */
  98424. getDeterministicFrameTime: () => number;
  98425. /** @hidden */
  98426. _animate(): void;
  98427. /** Execute all animations (for a frame) */
  98428. animate(): void;
  98429. /**
  98430. * Render the scene
  98431. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98432. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98433. */
  98434. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98435. /**
  98436. * Freeze all materials
  98437. * A frozen material will not be updatable but should be faster to render
  98438. */
  98439. freezeMaterials(): void;
  98440. /**
  98441. * Unfreeze all materials
  98442. * A frozen material will not be updatable but should be faster to render
  98443. */
  98444. unfreezeMaterials(): void;
  98445. /**
  98446. * Releases all held ressources
  98447. */
  98448. dispose(): void;
  98449. /**
  98450. * Gets if the scene is already disposed
  98451. */
  98452. readonly isDisposed: boolean;
  98453. /**
  98454. * Call this function to reduce memory footprint of the scene.
  98455. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98456. */
  98457. clearCachedVertexData(): void;
  98458. /**
  98459. * This function will remove the local cached buffer data from texture.
  98460. * It will save memory but will prevent the texture from being rebuilt
  98461. */
  98462. cleanCachedTextureBuffer(): void;
  98463. /**
  98464. * Get the world extend vectors with an optional filter
  98465. *
  98466. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98467. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98468. */
  98469. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98470. min: Vector3;
  98471. max: Vector3;
  98472. };
  98473. /**
  98474. * Creates a ray that can be used to pick in the scene
  98475. * @param x defines the x coordinate of the origin (on-screen)
  98476. * @param y defines the y coordinate of the origin (on-screen)
  98477. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98478. * @param camera defines the camera to use for the picking
  98479. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98480. * @returns a Ray
  98481. */
  98482. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98483. /**
  98484. * Creates a ray that can be used to pick in the scene
  98485. * @param x defines the x coordinate of the origin (on-screen)
  98486. * @param y defines the y coordinate of the origin (on-screen)
  98487. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98488. * @param result defines the ray where to store the picking ray
  98489. * @param camera defines the camera to use for the picking
  98490. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98491. * @returns the current scene
  98492. */
  98493. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98494. /**
  98495. * Creates a ray that can be used to pick in the scene
  98496. * @param x defines the x coordinate of the origin (on-screen)
  98497. * @param y defines the y coordinate of the origin (on-screen)
  98498. * @param camera defines the camera to use for the picking
  98499. * @returns a Ray
  98500. */
  98501. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98502. /**
  98503. * Creates a ray that can be used to pick in the scene
  98504. * @param x defines the x coordinate of the origin (on-screen)
  98505. * @param y defines the y coordinate of the origin (on-screen)
  98506. * @param result defines the ray where to store the picking ray
  98507. * @param camera defines the camera to use for the picking
  98508. * @returns the current scene
  98509. */
  98510. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98511. /** Launch a ray to try to pick a mesh in the scene
  98512. * @param x position on screen
  98513. * @param y position on screen
  98514. * @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
  98515. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98516. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98517. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98518. * @returns a PickingInfo
  98519. */
  98520. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98521. /** Use the given ray to pick a mesh in the scene
  98522. * @param ray The ray to use to pick meshes
  98523. * @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
  98524. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98525. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98526. * @returns a PickingInfo
  98527. */
  98528. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98529. /**
  98530. * Launch a ray to try to pick a mesh in the scene
  98531. * @param x X position on screen
  98532. * @param y Y position on screen
  98533. * @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
  98534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98535. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98536. * @returns an array of PickingInfo
  98537. */
  98538. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98539. /**
  98540. * Launch a ray to try to pick a mesh in the scene
  98541. * @param ray Ray to use
  98542. * @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
  98543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98544. * @returns an array of PickingInfo
  98545. */
  98546. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98547. /**
  98548. * Force the value of meshUnderPointer
  98549. * @param mesh defines the mesh to use
  98550. */
  98551. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98552. /**
  98553. * Gets the mesh under the pointer
  98554. * @returns a Mesh or null if no mesh is under the pointer
  98555. */
  98556. getPointerOverMesh(): Nullable<AbstractMesh>;
  98557. /** @hidden */
  98558. _rebuildGeometries(): void;
  98559. /** @hidden */
  98560. _rebuildTextures(): void;
  98561. private _getByTags;
  98562. /**
  98563. * Get a list of meshes by tags
  98564. * @param tagsQuery defines the tags query to use
  98565. * @param forEach defines a predicate used to filter results
  98566. * @returns an array of Mesh
  98567. */
  98568. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98569. /**
  98570. * Get a list of cameras by tags
  98571. * @param tagsQuery defines the tags query to use
  98572. * @param forEach defines a predicate used to filter results
  98573. * @returns an array of Camera
  98574. */
  98575. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98576. /**
  98577. * Get a list of lights by tags
  98578. * @param tagsQuery defines the tags query to use
  98579. * @param forEach defines a predicate used to filter results
  98580. * @returns an array of Light
  98581. */
  98582. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98583. /**
  98584. * Get a list of materials by tags
  98585. * @param tagsQuery defines the tags query to use
  98586. * @param forEach defines a predicate used to filter results
  98587. * @returns an array of Material
  98588. */
  98589. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98590. /**
  98591. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98592. * This allowed control for front to back rendering or reversly depending of the special needs.
  98593. *
  98594. * @param renderingGroupId The rendering group id corresponding to its index
  98595. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98596. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98597. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98598. */
  98599. 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;
  98600. /**
  98601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98602. *
  98603. * @param renderingGroupId The rendering group id corresponding to its index
  98604. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98605. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98606. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98607. */
  98608. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98609. /**
  98610. * Gets the current auto clear configuration for one rendering group of the rendering
  98611. * manager.
  98612. * @param index the rendering group index to get the information for
  98613. * @returns The auto clear setup for the requested rendering group
  98614. */
  98615. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98616. private _blockMaterialDirtyMechanism;
  98617. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98618. blockMaterialDirtyMechanism: boolean;
  98619. /**
  98620. * Will flag all materials as dirty to trigger new shader compilation
  98621. * @param flag defines the flag used to specify which material part must be marked as dirty
  98622. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98623. */
  98624. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98625. /** @hidden */
  98626. _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;
  98627. /** @hidden */
  98628. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98629. }
  98630. }
  98631. declare module BABYLON {
  98632. /**
  98633. * Set of assets to keep when moving a scene into an asset container.
  98634. */
  98635. export class KeepAssets extends AbstractScene {
  98636. }
  98637. /**
  98638. * Container with a set of assets that can be added or removed from a scene.
  98639. */
  98640. export class AssetContainer extends AbstractScene {
  98641. /**
  98642. * The scene the AssetContainer belongs to.
  98643. */
  98644. scene: Scene;
  98645. /**
  98646. * Instantiates an AssetContainer.
  98647. * @param scene The scene the AssetContainer belongs to.
  98648. */
  98649. constructor(scene: Scene);
  98650. /**
  98651. * Adds all the assets from the container to the scene.
  98652. */
  98653. addAllToScene(): void;
  98654. /**
  98655. * Removes all the assets in the container from the scene
  98656. */
  98657. removeAllFromScene(): void;
  98658. /**
  98659. * Disposes all the assets in the container
  98660. */
  98661. dispose(): void;
  98662. private _moveAssets;
  98663. /**
  98664. * Removes all the assets contained in the scene and adds them to the container.
  98665. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98666. */
  98667. moveAllFromScene(keepAssets?: KeepAssets): void;
  98668. /**
  98669. * 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.
  98670. * @returns the root mesh
  98671. */
  98672. createRootMesh(): Mesh;
  98673. }
  98674. }
  98675. declare module BABYLON {
  98676. /**
  98677. * Defines how the parser contract is defined.
  98678. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98679. */
  98680. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98681. /**
  98682. * Defines how the individual parser contract is defined.
  98683. * These parser can parse an individual asset
  98684. */
  98685. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98686. /**
  98687. * Base class of the scene acting as a container for the different elements composing a scene.
  98688. * This class is dynamically extended by the different components of the scene increasing
  98689. * flexibility and reducing coupling
  98690. */
  98691. export abstract class AbstractScene {
  98692. /**
  98693. * Stores the list of available parsers in the application.
  98694. */
  98695. private static _BabylonFileParsers;
  98696. /**
  98697. * Stores the list of available individual parsers in the application.
  98698. */
  98699. private static _IndividualBabylonFileParsers;
  98700. /**
  98701. * Adds a parser in the list of available ones
  98702. * @param name Defines the name of the parser
  98703. * @param parser Defines the parser to add
  98704. */
  98705. static AddParser(name: string, parser: BabylonFileParser): void;
  98706. /**
  98707. * Gets a general parser from the list of avaialble ones
  98708. * @param name Defines the name of the parser
  98709. * @returns the requested parser or null
  98710. */
  98711. static GetParser(name: string): Nullable<BabylonFileParser>;
  98712. /**
  98713. * Adds n individual parser in the list of available ones
  98714. * @param name Defines the name of the parser
  98715. * @param parser Defines the parser to add
  98716. */
  98717. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98718. /**
  98719. * Gets an individual parser from the list of avaialble ones
  98720. * @param name Defines the name of the parser
  98721. * @returns the requested parser or null
  98722. */
  98723. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98724. /**
  98725. * Parser json data and populate both a scene and its associated container object
  98726. * @param jsonData Defines the data to parse
  98727. * @param scene Defines the scene to parse the data for
  98728. * @param container Defines the container attached to the parsing sequence
  98729. * @param rootUrl Defines the root url of the data
  98730. */
  98731. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98732. /**
  98733. * Gets the list of root nodes (ie. nodes with no parent)
  98734. */
  98735. rootNodes: Node[];
  98736. /** All of the cameras added to this scene
  98737. * @see http://doc.babylonjs.com/babylon101/cameras
  98738. */
  98739. cameras: Camera[];
  98740. /**
  98741. * All of the lights added to this scene
  98742. * @see http://doc.babylonjs.com/babylon101/lights
  98743. */
  98744. lights: Light[];
  98745. /**
  98746. * All of the (abstract) meshes added to this scene
  98747. */
  98748. meshes: AbstractMesh[];
  98749. /**
  98750. * The list of skeletons added to the scene
  98751. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98752. */
  98753. skeletons: Skeleton[];
  98754. /**
  98755. * All of the particle systems added to this scene
  98756. * @see http://doc.babylonjs.com/babylon101/particles
  98757. */
  98758. particleSystems: IParticleSystem[];
  98759. /**
  98760. * Gets a list of Animations associated with the scene
  98761. */
  98762. animations: Animation[];
  98763. /**
  98764. * All of the animation groups added to this scene
  98765. * @see http://doc.babylonjs.com/how_to/group
  98766. */
  98767. animationGroups: AnimationGroup[];
  98768. /**
  98769. * All of the multi-materials added to this scene
  98770. * @see http://doc.babylonjs.com/how_to/multi_materials
  98771. */
  98772. multiMaterials: MultiMaterial[];
  98773. /**
  98774. * All of the materials added to this scene
  98775. * In the context of a Scene, it is not supposed to be modified manually.
  98776. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98777. * Note also that the order of the Material wihin the array is not significant and might change.
  98778. * @see http://doc.babylonjs.com/babylon101/materials
  98779. */
  98780. materials: Material[];
  98781. /**
  98782. * The list of morph target managers added to the scene
  98783. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98784. */
  98785. morphTargetManagers: MorphTargetManager[];
  98786. /**
  98787. * The list of geometries used in the scene.
  98788. */
  98789. geometries: Geometry[];
  98790. /**
  98791. * All of the tranform nodes added to this scene
  98792. * In the context of a Scene, it is not supposed to be modified manually.
  98793. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98794. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98795. * @see http://doc.babylonjs.com/how_to/transformnode
  98796. */
  98797. transformNodes: TransformNode[];
  98798. /**
  98799. * ActionManagers available on the scene.
  98800. */
  98801. actionManagers: AbstractActionManager[];
  98802. /**
  98803. * Textures to keep.
  98804. */
  98805. textures: BaseTexture[];
  98806. /**
  98807. * Environment texture for the scene
  98808. */
  98809. environmentTexture: Nullable<BaseTexture>;
  98810. }
  98811. }
  98812. declare module BABYLON {
  98813. /**
  98814. * Interface used to define options for Sound class
  98815. */
  98816. export interface ISoundOptions {
  98817. /**
  98818. * Does the sound autoplay once loaded.
  98819. */
  98820. autoplay?: boolean;
  98821. /**
  98822. * Does the sound loop after it finishes playing once.
  98823. */
  98824. loop?: boolean;
  98825. /**
  98826. * Sound's volume
  98827. */
  98828. volume?: number;
  98829. /**
  98830. * Is it a spatial sound?
  98831. */
  98832. spatialSound?: boolean;
  98833. /**
  98834. * Maximum distance to hear that sound
  98835. */
  98836. maxDistance?: number;
  98837. /**
  98838. * Uses user defined attenuation function
  98839. */
  98840. useCustomAttenuation?: boolean;
  98841. /**
  98842. * Define the roll off factor of spatial sounds.
  98843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98844. */
  98845. rolloffFactor?: number;
  98846. /**
  98847. * Define the reference distance the sound should be heard perfectly.
  98848. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98849. */
  98850. refDistance?: number;
  98851. /**
  98852. * Define the distance attenuation model the sound will follow.
  98853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98854. */
  98855. distanceModel?: string;
  98856. /**
  98857. * Defines the playback speed (1 by default)
  98858. */
  98859. playbackRate?: number;
  98860. /**
  98861. * Defines if the sound is from a streaming source
  98862. */
  98863. streaming?: boolean;
  98864. /**
  98865. * Defines an optional length (in seconds) inside the sound file
  98866. */
  98867. length?: number;
  98868. /**
  98869. * Defines an optional offset (in seconds) inside the sound file
  98870. */
  98871. offset?: number;
  98872. /**
  98873. * If true, URLs will not be required to state the audio file codec to use.
  98874. */
  98875. skipCodecCheck?: boolean;
  98876. }
  98877. /**
  98878. * Defines a sound that can be played in the application.
  98879. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98881. */
  98882. export class Sound {
  98883. /**
  98884. * The name of the sound in the scene.
  98885. */
  98886. name: string;
  98887. /**
  98888. * Does the sound autoplay once loaded.
  98889. */
  98890. autoplay: boolean;
  98891. /**
  98892. * Does the sound loop after it finishes playing once.
  98893. */
  98894. loop: boolean;
  98895. /**
  98896. * Does the sound use a custom attenuation curve to simulate the falloff
  98897. * happening when the source gets further away from the camera.
  98898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98899. */
  98900. useCustomAttenuation: boolean;
  98901. /**
  98902. * The sound track id this sound belongs to.
  98903. */
  98904. soundTrackId: number;
  98905. /**
  98906. * Is this sound currently played.
  98907. */
  98908. isPlaying: boolean;
  98909. /**
  98910. * Is this sound currently paused.
  98911. */
  98912. isPaused: boolean;
  98913. /**
  98914. * Does this sound enables spatial sound.
  98915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98916. */
  98917. spatialSound: boolean;
  98918. /**
  98919. * Define the reference distance the sound should be heard perfectly.
  98920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98921. */
  98922. refDistance: number;
  98923. /**
  98924. * Define the roll off factor of spatial sounds.
  98925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98926. */
  98927. rolloffFactor: number;
  98928. /**
  98929. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98931. */
  98932. maxDistance: number;
  98933. /**
  98934. * Define the distance attenuation model the sound will follow.
  98935. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98936. */
  98937. distanceModel: string;
  98938. /**
  98939. * @hidden
  98940. * Back Compat
  98941. **/
  98942. onended: () => any;
  98943. /**
  98944. * Observable event when the current playing sound finishes.
  98945. */
  98946. onEndedObservable: Observable<Sound>;
  98947. private _panningModel;
  98948. private _playbackRate;
  98949. private _streaming;
  98950. private _startTime;
  98951. private _startOffset;
  98952. private _position;
  98953. /** @hidden */
  98954. _positionInEmitterSpace: boolean;
  98955. private _localDirection;
  98956. private _volume;
  98957. private _isReadyToPlay;
  98958. private _isDirectional;
  98959. private _readyToPlayCallback;
  98960. private _audioBuffer;
  98961. private _soundSource;
  98962. private _streamingSource;
  98963. private _soundPanner;
  98964. private _soundGain;
  98965. private _inputAudioNode;
  98966. private _outputAudioNode;
  98967. private _coneInnerAngle;
  98968. private _coneOuterAngle;
  98969. private _coneOuterGain;
  98970. private _scene;
  98971. private _connectedTransformNode;
  98972. private _customAttenuationFunction;
  98973. private _registerFunc;
  98974. private _isOutputConnected;
  98975. private _htmlAudioElement;
  98976. private _urlType;
  98977. private _length?;
  98978. private _offset?;
  98979. /** @hidden */
  98980. static _SceneComponentInitialization: (scene: Scene) => void;
  98981. /**
  98982. * Create a sound and attach it to a scene
  98983. * @param name Name of your sound
  98984. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98985. * @param scene defines the scene the sound belongs to
  98986. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98987. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98988. */
  98989. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98990. /**
  98991. * Release the sound and its associated resources
  98992. */
  98993. dispose(): void;
  98994. /**
  98995. * Gets if the sounds is ready to be played or not.
  98996. * @returns true if ready, otherwise false
  98997. */
  98998. isReady(): boolean;
  98999. private _soundLoaded;
  99000. /**
  99001. * Sets the data of the sound from an audiobuffer
  99002. * @param audioBuffer The audioBuffer containing the data
  99003. */
  99004. setAudioBuffer(audioBuffer: AudioBuffer): void;
  99005. /**
  99006. * Updates the current sounds options such as maxdistance, loop...
  99007. * @param options A JSON object containing values named as the object properties
  99008. */
  99009. updateOptions(options: ISoundOptions): void;
  99010. private _createSpatialParameters;
  99011. private _updateSpatialParameters;
  99012. /**
  99013. * Switch the panning model to HRTF:
  99014. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99016. */
  99017. switchPanningModelToHRTF(): void;
  99018. /**
  99019. * Switch the panning model to Equal Power:
  99020. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99021. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99022. */
  99023. switchPanningModelToEqualPower(): void;
  99024. private _switchPanningModel;
  99025. /**
  99026. * Connect this sound to a sound track audio node like gain...
  99027. * @param soundTrackAudioNode the sound track audio node to connect to
  99028. */
  99029. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  99030. /**
  99031. * Transform this sound into a directional source
  99032. * @param coneInnerAngle Size of the inner cone in degree
  99033. * @param coneOuterAngle Size of the outer cone in degree
  99034. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  99035. */
  99036. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  99037. /**
  99038. * Gets or sets the inner angle for the directional cone.
  99039. */
  99040. /**
  99041. * Gets or sets the inner angle for the directional cone.
  99042. */
  99043. directionalConeInnerAngle: number;
  99044. /**
  99045. * Gets or sets the outer angle for the directional cone.
  99046. */
  99047. /**
  99048. * Gets or sets the outer angle for the directional cone.
  99049. */
  99050. directionalConeOuterAngle: number;
  99051. /**
  99052. * Sets the position of the emitter if spatial sound is enabled
  99053. * @param newPosition Defines the new posisiton
  99054. */
  99055. setPosition(newPosition: Vector3): void;
  99056. /**
  99057. * Sets the local direction of the emitter if spatial sound is enabled
  99058. * @param newLocalDirection Defines the new local direction
  99059. */
  99060. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  99061. private _updateDirection;
  99062. /** @hidden */
  99063. updateDistanceFromListener(): void;
  99064. /**
  99065. * Sets a new custom attenuation function for the sound.
  99066. * @param callback Defines the function used for the attenuation
  99067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  99068. */
  99069. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  99070. /**
  99071. * Play the sound
  99072. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  99073. * @param offset (optional) Start the sound at a specific time in seconds
  99074. * @param length (optional) Sound duration (in seconds)
  99075. */
  99076. play(time?: number, offset?: number, length?: number): void;
  99077. private _onended;
  99078. /**
  99079. * Stop the sound
  99080. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  99081. */
  99082. stop(time?: number): void;
  99083. /**
  99084. * Put the sound in pause
  99085. */
  99086. pause(): void;
  99087. /**
  99088. * Sets a dedicated volume for this sounds
  99089. * @param newVolume Define the new volume of the sound
  99090. * @param time Define time for gradual change to new volume
  99091. */
  99092. setVolume(newVolume: number, time?: number): void;
  99093. /**
  99094. * Set the sound play back rate
  99095. * @param newPlaybackRate Define the playback rate the sound should be played at
  99096. */
  99097. setPlaybackRate(newPlaybackRate: number): void;
  99098. /**
  99099. * Gets the volume of the sound.
  99100. * @returns the volume of the sound
  99101. */
  99102. getVolume(): number;
  99103. /**
  99104. * Attach the sound to a dedicated mesh
  99105. * @param transformNode The transform node to connect the sound with
  99106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99107. */
  99108. attachToMesh(transformNode: TransformNode): void;
  99109. /**
  99110. * Detach the sound from the previously attached mesh
  99111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  99112. */
  99113. detachFromMesh(): void;
  99114. private _onRegisterAfterWorldMatrixUpdate;
  99115. /**
  99116. * Clone the current sound in the scene.
  99117. * @returns the new sound clone
  99118. */
  99119. clone(): Nullable<Sound>;
  99120. /**
  99121. * Gets the current underlying audio buffer containing the data
  99122. * @returns the audio buffer
  99123. */
  99124. getAudioBuffer(): Nullable<AudioBuffer>;
  99125. /**
  99126. * Serializes the Sound in a JSON representation
  99127. * @returns the JSON representation of the sound
  99128. */
  99129. serialize(): any;
  99130. /**
  99131. * Parse a JSON representation of a sound to innstantiate in a given scene
  99132. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  99133. * @param scene Define the scene the new parsed sound should be created in
  99134. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  99135. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  99136. * @returns the newly parsed sound
  99137. */
  99138. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  99139. }
  99140. }
  99141. declare module BABYLON {
  99142. /**
  99143. * This defines an action helpful to play a defined sound on a triggered action.
  99144. */
  99145. export class PlaySoundAction extends Action {
  99146. private _sound;
  99147. /**
  99148. * Instantiate the action
  99149. * @param triggerOptions defines the trigger options
  99150. * @param sound defines the sound to play
  99151. * @param condition defines the trigger related conditions
  99152. */
  99153. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99154. /** @hidden */
  99155. _prepare(): void;
  99156. /**
  99157. * Execute the action and play the sound.
  99158. */
  99159. execute(): void;
  99160. /**
  99161. * Serializes the actions and its related information.
  99162. * @param parent defines the object to serialize in
  99163. * @returns the serialized object
  99164. */
  99165. serialize(parent: any): any;
  99166. }
  99167. /**
  99168. * This defines an action helpful to stop a defined sound on a triggered action.
  99169. */
  99170. export class StopSoundAction extends Action {
  99171. private _sound;
  99172. /**
  99173. * Instantiate the action
  99174. * @param triggerOptions defines the trigger options
  99175. * @param sound defines the sound to stop
  99176. * @param condition defines the trigger related conditions
  99177. */
  99178. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  99179. /** @hidden */
  99180. _prepare(): void;
  99181. /**
  99182. * Execute the action and stop the sound.
  99183. */
  99184. execute(): void;
  99185. /**
  99186. * Serializes the actions and its related information.
  99187. * @param parent defines the object to serialize in
  99188. * @returns the serialized object
  99189. */
  99190. serialize(parent: any): any;
  99191. }
  99192. }
  99193. declare module BABYLON {
  99194. /**
  99195. * This defines an action responsible to change the value of a property
  99196. * by interpolating between its current value and the newly set one once triggered.
  99197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99198. */
  99199. export class InterpolateValueAction extends Action {
  99200. /**
  99201. * Defines the path of the property where the value should be interpolated
  99202. */
  99203. propertyPath: string;
  99204. /**
  99205. * Defines the target value at the end of the interpolation.
  99206. */
  99207. value: any;
  99208. /**
  99209. * Defines the time it will take for the property to interpolate to the value.
  99210. */
  99211. duration: number;
  99212. /**
  99213. * Defines if the other scene animations should be stopped when the action has been triggered
  99214. */
  99215. stopOtherAnimations?: boolean;
  99216. /**
  99217. * Defines a callback raised once the interpolation animation has been done.
  99218. */
  99219. onInterpolationDone?: () => void;
  99220. /**
  99221. * Observable triggered once the interpolation animation has been done.
  99222. */
  99223. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  99224. private _target;
  99225. private _effectiveTarget;
  99226. private _property;
  99227. /**
  99228. * Instantiate the action
  99229. * @param triggerOptions defines the trigger options
  99230. * @param target defines the object containing the value to interpolate
  99231. * @param propertyPath defines the path to the property in the target object
  99232. * @param value defines the target value at the end of the interpolation
  99233. * @param duration deines the time it will take for the property to interpolate to the value.
  99234. * @param condition defines the trigger related conditions
  99235. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  99236. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  99237. */
  99238. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  99239. /** @hidden */
  99240. _prepare(): void;
  99241. /**
  99242. * Execute the action starts the value interpolation.
  99243. */
  99244. execute(): void;
  99245. /**
  99246. * Serializes the actions and its related information.
  99247. * @param parent defines the object to serialize in
  99248. * @returns the serialized object
  99249. */
  99250. serialize(parent: any): any;
  99251. }
  99252. }
  99253. declare module BABYLON {
  99254. /**
  99255. * Options allowed during the creation of a sound track.
  99256. */
  99257. export interface ISoundTrackOptions {
  99258. /**
  99259. * The volume the sound track should take during creation
  99260. */
  99261. volume?: number;
  99262. /**
  99263. * Define if the sound track is the main sound track of the scene
  99264. */
  99265. mainTrack?: boolean;
  99266. }
  99267. /**
  99268. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  99269. * It will be also used in a future release to apply effects on a specific track.
  99270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99271. */
  99272. export class SoundTrack {
  99273. /**
  99274. * The unique identifier of the sound track in the scene.
  99275. */
  99276. id: number;
  99277. /**
  99278. * The list of sounds included in the sound track.
  99279. */
  99280. soundCollection: Array<Sound>;
  99281. private _outputAudioNode;
  99282. private _scene;
  99283. private _isMainTrack;
  99284. private _connectedAnalyser;
  99285. private _options;
  99286. private _isInitialized;
  99287. /**
  99288. * Creates a new sound track.
  99289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  99290. * @param scene Define the scene the sound track belongs to
  99291. * @param options
  99292. */
  99293. constructor(scene: Scene, options?: ISoundTrackOptions);
  99294. private _initializeSoundTrackAudioGraph;
  99295. /**
  99296. * Release the sound track and its associated resources
  99297. */
  99298. dispose(): void;
  99299. /**
  99300. * Adds a sound to this sound track
  99301. * @param sound define the cound to add
  99302. * @ignoreNaming
  99303. */
  99304. AddSound(sound: Sound): void;
  99305. /**
  99306. * Removes a sound to this sound track
  99307. * @param sound define the cound to remove
  99308. * @ignoreNaming
  99309. */
  99310. RemoveSound(sound: Sound): void;
  99311. /**
  99312. * Set a global volume for the full sound track.
  99313. * @param newVolume Define the new volume of the sound track
  99314. */
  99315. setVolume(newVolume: number): void;
  99316. /**
  99317. * Switch the panning model to HRTF:
  99318. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  99319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99320. */
  99321. switchPanningModelToHRTF(): void;
  99322. /**
  99323. * Switch the panning model to Equal Power:
  99324. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  99325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  99326. */
  99327. switchPanningModelToEqualPower(): void;
  99328. /**
  99329. * Connect the sound track to an audio analyser allowing some amazing
  99330. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99332. * @param analyser The analyser to connect to the engine
  99333. */
  99334. connectToAnalyser(analyser: Analyser): void;
  99335. }
  99336. }
  99337. declare module BABYLON {
  99338. interface AbstractScene {
  99339. /**
  99340. * The list of sounds used in the scene.
  99341. */
  99342. sounds: Nullable<Array<Sound>>;
  99343. }
  99344. interface Scene {
  99345. /**
  99346. * @hidden
  99347. * Backing field
  99348. */
  99349. _mainSoundTrack: SoundTrack;
  99350. /**
  99351. * The main sound track played by the scene.
  99352. * It cotains your primary collection of sounds.
  99353. */
  99354. mainSoundTrack: SoundTrack;
  99355. /**
  99356. * The list of sound tracks added to the scene
  99357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99358. */
  99359. soundTracks: Nullable<Array<SoundTrack>>;
  99360. /**
  99361. * Gets a sound using a given name
  99362. * @param name defines the name to search for
  99363. * @return the found sound or null if not found at all.
  99364. */
  99365. getSoundByName(name: string): Nullable<Sound>;
  99366. /**
  99367. * Gets or sets if audio support is enabled
  99368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99369. */
  99370. audioEnabled: boolean;
  99371. /**
  99372. * Gets or sets if audio will be output to headphones
  99373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99374. */
  99375. headphone: boolean;
  99376. }
  99377. /**
  99378. * Defines the sound scene component responsible to manage any sounds
  99379. * in a given scene.
  99380. */
  99381. export class AudioSceneComponent implements ISceneSerializableComponent {
  99382. /**
  99383. * The component name helpfull to identify the component in the list of scene components.
  99384. */
  99385. readonly name: string;
  99386. /**
  99387. * The scene the component belongs to.
  99388. */
  99389. scene: Scene;
  99390. private _audioEnabled;
  99391. /**
  99392. * Gets whether audio is enabled or not.
  99393. * Please use related enable/disable method to switch state.
  99394. */
  99395. readonly audioEnabled: boolean;
  99396. private _headphone;
  99397. /**
  99398. * Gets whether audio is outputing to headphone or not.
  99399. * Please use the according Switch methods to change output.
  99400. */
  99401. readonly headphone: boolean;
  99402. /**
  99403. * Creates a new instance of the component for the given scene
  99404. * @param scene Defines the scene to register the component in
  99405. */
  99406. constructor(scene: Scene);
  99407. /**
  99408. * Registers the component in a given scene
  99409. */
  99410. register(): void;
  99411. /**
  99412. * Rebuilds the elements related to this component in case of
  99413. * context lost for instance.
  99414. */
  99415. rebuild(): void;
  99416. /**
  99417. * Serializes the component data to the specified json object
  99418. * @param serializationObject The object to serialize to
  99419. */
  99420. serialize(serializationObject: any): void;
  99421. /**
  99422. * Adds all the elements from the container to the scene
  99423. * @param container the container holding the elements
  99424. */
  99425. addFromContainer(container: AbstractScene): void;
  99426. /**
  99427. * Removes all the elements in the container from the scene
  99428. * @param container contains the elements to remove
  99429. * @param dispose if the removed element should be disposed (default: false)
  99430. */
  99431. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99432. /**
  99433. * Disposes the component and the associated ressources.
  99434. */
  99435. dispose(): void;
  99436. /**
  99437. * Disables audio in the associated scene.
  99438. */
  99439. disableAudio(): void;
  99440. /**
  99441. * Enables audio in the associated scene.
  99442. */
  99443. enableAudio(): void;
  99444. /**
  99445. * Switch audio to headphone output.
  99446. */
  99447. switchAudioModeForHeadphones(): void;
  99448. /**
  99449. * Switch audio to normal speakers.
  99450. */
  99451. switchAudioModeForNormalSpeakers(): void;
  99452. private _afterRender;
  99453. }
  99454. }
  99455. declare module BABYLON {
  99456. /**
  99457. * Wraps one or more Sound objects and selects one with random weight for playback.
  99458. */
  99459. export class WeightedSound {
  99460. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99461. loop: boolean;
  99462. private _coneInnerAngle;
  99463. private _coneOuterAngle;
  99464. private _volume;
  99465. /** A Sound is currently playing. */
  99466. isPlaying: boolean;
  99467. /** A Sound is currently paused. */
  99468. isPaused: boolean;
  99469. private _sounds;
  99470. private _weights;
  99471. private _currentIndex?;
  99472. /**
  99473. * Creates a new WeightedSound from the list of sounds given.
  99474. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99475. * @param sounds Array of Sounds that will be selected from.
  99476. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99477. */
  99478. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99479. /**
  99480. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99481. */
  99482. /**
  99483. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99484. */
  99485. directionalConeInnerAngle: number;
  99486. /**
  99487. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99488. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99489. */
  99490. /**
  99491. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99492. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99493. */
  99494. directionalConeOuterAngle: number;
  99495. /**
  99496. * Playback volume.
  99497. */
  99498. /**
  99499. * Playback volume.
  99500. */
  99501. volume: number;
  99502. private _onended;
  99503. /**
  99504. * Suspend playback
  99505. */
  99506. pause(): void;
  99507. /**
  99508. * Stop playback
  99509. */
  99510. stop(): void;
  99511. /**
  99512. * Start playback.
  99513. * @param startOffset Position the clip head at a specific time in seconds.
  99514. */
  99515. play(startOffset?: number): void;
  99516. }
  99517. }
  99518. declare module BABYLON {
  99519. /**
  99520. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99521. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99522. */
  99523. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99524. /**
  99525. * Gets the name of the behavior.
  99526. */
  99527. readonly name: string;
  99528. /**
  99529. * The easing function used by animations
  99530. */
  99531. static EasingFunction: BackEase;
  99532. /**
  99533. * The easing mode used by animations
  99534. */
  99535. static EasingMode: number;
  99536. /**
  99537. * The duration of the animation, in milliseconds
  99538. */
  99539. transitionDuration: number;
  99540. /**
  99541. * Length of the distance animated by the transition when lower radius is reached
  99542. */
  99543. lowerRadiusTransitionRange: number;
  99544. /**
  99545. * Length of the distance animated by the transition when upper radius is reached
  99546. */
  99547. upperRadiusTransitionRange: number;
  99548. private _autoTransitionRange;
  99549. /**
  99550. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99551. */
  99552. /**
  99553. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99554. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99555. */
  99556. autoTransitionRange: boolean;
  99557. private _attachedCamera;
  99558. private _onAfterCheckInputsObserver;
  99559. private _onMeshTargetChangedObserver;
  99560. /**
  99561. * Initializes the behavior.
  99562. */
  99563. init(): void;
  99564. /**
  99565. * Attaches the behavior to its arc rotate camera.
  99566. * @param camera Defines the camera to attach the behavior to
  99567. */
  99568. attach(camera: ArcRotateCamera): void;
  99569. /**
  99570. * Detaches the behavior from its current arc rotate camera.
  99571. */
  99572. detach(): void;
  99573. private _radiusIsAnimating;
  99574. private _radiusBounceTransition;
  99575. private _animatables;
  99576. private _cachedWheelPrecision;
  99577. /**
  99578. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99579. * @param radiusLimit The limit to check against.
  99580. * @return Bool to indicate if at limit.
  99581. */
  99582. private _isRadiusAtLimit;
  99583. /**
  99584. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99585. * @param radiusDelta The delta by which to animate to. Can be negative.
  99586. */
  99587. private _applyBoundRadiusAnimation;
  99588. /**
  99589. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99590. */
  99591. protected _clearAnimationLocks(): void;
  99592. /**
  99593. * Stops and removes all animations that have been applied to the camera
  99594. */
  99595. stopAllAnimations(): void;
  99596. }
  99597. }
  99598. declare module BABYLON {
  99599. /**
  99600. * 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.
  99601. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99602. */
  99603. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99604. /**
  99605. * Gets the name of the behavior.
  99606. */
  99607. readonly name: string;
  99608. private _mode;
  99609. private _radiusScale;
  99610. private _positionScale;
  99611. private _defaultElevation;
  99612. private _elevationReturnTime;
  99613. private _elevationReturnWaitTime;
  99614. private _zoomStopsAnimation;
  99615. private _framingTime;
  99616. /**
  99617. * The easing function used by animations
  99618. */
  99619. static EasingFunction: ExponentialEase;
  99620. /**
  99621. * The easing mode used by animations
  99622. */
  99623. static EasingMode: number;
  99624. /**
  99625. * Sets the current mode used by the behavior
  99626. */
  99627. /**
  99628. * Gets current mode used by the behavior.
  99629. */
  99630. mode: number;
  99631. /**
  99632. * Sets the scale applied to the radius (1 by default)
  99633. */
  99634. /**
  99635. * Gets the scale applied to the radius
  99636. */
  99637. radiusScale: number;
  99638. /**
  99639. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99640. */
  99641. /**
  99642. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99643. */
  99644. positionScale: number;
  99645. /**
  99646. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99647. * behaviour is triggered, in radians.
  99648. */
  99649. /**
  99650. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99651. * behaviour is triggered, in radians.
  99652. */
  99653. defaultElevation: number;
  99654. /**
  99655. * Sets the time (in milliseconds) taken to return to the default beta position.
  99656. * Negative value indicates camera should not return to default.
  99657. */
  99658. /**
  99659. * Gets the time (in milliseconds) taken to return to the default beta position.
  99660. * Negative value indicates camera should not return to default.
  99661. */
  99662. elevationReturnTime: number;
  99663. /**
  99664. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99665. */
  99666. /**
  99667. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99668. */
  99669. elevationReturnWaitTime: number;
  99670. /**
  99671. * Sets the flag that indicates if user zooming should stop animation.
  99672. */
  99673. /**
  99674. * Gets the flag that indicates if user zooming should stop animation.
  99675. */
  99676. zoomStopsAnimation: boolean;
  99677. /**
  99678. * Sets the transition time when framing the mesh, in milliseconds
  99679. */
  99680. /**
  99681. * Gets the transition time when framing the mesh, in milliseconds
  99682. */
  99683. framingTime: number;
  99684. /**
  99685. * Define if the behavior should automatically change the configured
  99686. * camera limits and sensibilities.
  99687. */
  99688. autoCorrectCameraLimitsAndSensibility: boolean;
  99689. private _onPrePointerObservableObserver;
  99690. private _onAfterCheckInputsObserver;
  99691. private _onMeshTargetChangedObserver;
  99692. private _attachedCamera;
  99693. private _isPointerDown;
  99694. private _lastInteractionTime;
  99695. /**
  99696. * Initializes the behavior.
  99697. */
  99698. init(): void;
  99699. /**
  99700. * Attaches the behavior to its arc rotate camera.
  99701. * @param camera Defines the camera to attach the behavior to
  99702. */
  99703. attach(camera: ArcRotateCamera): void;
  99704. /**
  99705. * Detaches the behavior from its current arc rotate camera.
  99706. */
  99707. detach(): void;
  99708. private _animatables;
  99709. private _betaIsAnimating;
  99710. private _betaTransition;
  99711. private _radiusTransition;
  99712. private _vectorTransition;
  99713. /**
  99714. * Targets the given mesh and updates zoom level accordingly.
  99715. * @param mesh The mesh to target.
  99716. * @param radius Optional. If a cached radius position already exists, overrides default.
  99717. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99718. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99719. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99720. */
  99721. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99722. /**
  99723. * Targets the given mesh with its children and updates zoom level accordingly.
  99724. * @param mesh The mesh to target.
  99725. * @param radius Optional. If a cached radius position already exists, overrides default.
  99726. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99727. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99728. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99729. */
  99730. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99731. /**
  99732. * Targets the given meshes with their children and updates zoom level accordingly.
  99733. * @param meshes The mesh to target.
  99734. * @param radius Optional. If a cached radius position already exists, overrides default.
  99735. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99736. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99737. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99738. */
  99739. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99740. /**
  99741. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99742. * @param minimumWorld Determines the smaller position of the bounding box extend
  99743. * @param maximumWorld Determines the bigger position of the bounding box extend
  99744. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99745. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99746. */
  99747. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99748. /**
  99749. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99750. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99751. * frustum width.
  99752. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99753. * to fully enclose the mesh in the viewing frustum.
  99754. */
  99755. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99756. /**
  99757. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99758. * is automatically returned to its default position (expected to be above ground plane).
  99759. */
  99760. private _maintainCameraAboveGround;
  99761. /**
  99762. * Returns the frustum slope based on the canvas ratio and camera FOV
  99763. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99764. */
  99765. private _getFrustumSlope;
  99766. /**
  99767. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99768. */
  99769. private _clearAnimationLocks;
  99770. /**
  99771. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99772. */
  99773. private _applyUserInteraction;
  99774. /**
  99775. * Stops and removes all animations that have been applied to the camera
  99776. */
  99777. stopAllAnimations(): void;
  99778. /**
  99779. * Gets a value indicating if the user is moving the camera
  99780. */
  99781. readonly isUserIsMoving: boolean;
  99782. /**
  99783. * The camera can move all the way towards the mesh.
  99784. */
  99785. static IgnoreBoundsSizeMode: number;
  99786. /**
  99787. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99788. */
  99789. static FitFrustumSidesMode: number;
  99790. }
  99791. }
  99792. declare module BABYLON {
  99793. /**
  99794. * Base class for Camera Pointer Inputs.
  99795. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99796. * for example usage.
  99797. */
  99798. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99799. /**
  99800. * Defines the camera the input is attached to.
  99801. */
  99802. abstract camera: Camera;
  99803. /**
  99804. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99805. */
  99806. protected _altKey: boolean;
  99807. protected _ctrlKey: boolean;
  99808. protected _metaKey: boolean;
  99809. protected _shiftKey: boolean;
  99810. /**
  99811. * Which mouse buttons were pressed at time of last mouse event.
  99812. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99813. */
  99814. protected _buttonsPressed: number;
  99815. /**
  99816. * Defines the buttons associated with the input to handle camera move.
  99817. */
  99818. buttons: number[];
  99819. /**
  99820. * Attach the input controls to a specific dom element to get the input from.
  99821. * @param element Defines the element the controls should be listened from
  99822. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99823. */
  99824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99825. /**
  99826. * Detach the current controls from the specified dom element.
  99827. * @param element Defines the element to stop listening the inputs from
  99828. */
  99829. detachControl(element: Nullable<HTMLElement>): void;
  99830. /**
  99831. * Gets the class name of the current input.
  99832. * @returns the class name
  99833. */
  99834. getClassName(): string;
  99835. /**
  99836. * Get the friendly name associated with the input class.
  99837. * @returns the input friendly name
  99838. */
  99839. getSimpleName(): string;
  99840. /**
  99841. * Called on pointer POINTERDOUBLETAP event.
  99842. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99843. */
  99844. protected onDoubleTap(type: string): void;
  99845. /**
  99846. * Called on pointer POINTERMOVE event if only a single touch is active.
  99847. * Override this method to provide functionality.
  99848. */
  99849. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99850. /**
  99851. * Called on pointer POINTERMOVE event if multiple touches are active.
  99852. * Override this method to provide functionality.
  99853. */
  99854. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99855. /**
  99856. * Called on JS contextmenu event.
  99857. * Override this method to provide functionality.
  99858. */
  99859. protected onContextMenu(evt: PointerEvent): void;
  99860. /**
  99861. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99862. * press.
  99863. * Override this method to provide functionality.
  99864. */
  99865. protected onButtonDown(evt: PointerEvent): void;
  99866. /**
  99867. * Called each time a new POINTERUP event occurs. Ie, for each button
  99868. * release.
  99869. * Override this method to provide functionality.
  99870. */
  99871. protected onButtonUp(evt: PointerEvent): void;
  99872. /**
  99873. * Called when window becomes inactive.
  99874. * Override this method to provide functionality.
  99875. */
  99876. protected onLostFocus(): void;
  99877. private _pointerInput;
  99878. private _observer;
  99879. private _onLostFocus;
  99880. private pointA;
  99881. private pointB;
  99882. }
  99883. }
  99884. declare module BABYLON {
  99885. /**
  99886. * Manage the pointers inputs to control an arc rotate camera.
  99887. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99888. */
  99889. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99890. /**
  99891. * Defines the camera the input is attached to.
  99892. */
  99893. camera: ArcRotateCamera;
  99894. /**
  99895. * Gets the class name of the current input.
  99896. * @returns the class name
  99897. */
  99898. getClassName(): string;
  99899. /**
  99900. * Defines the buttons associated with the input to handle camera move.
  99901. */
  99902. buttons: number[];
  99903. /**
  99904. * Defines the pointer angular sensibility along the X axis or how fast is
  99905. * the camera rotating.
  99906. */
  99907. angularSensibilityX: number;
  99908. /**
  99909. * Defines the pointer angular sensibility along the Y axis or how fast is
  99910. * the camera rotating.
  99911. */
  99912. angularSensibilityY: number;
  99913. /**
  99914. * Defines the pointer pinch precision or how fast is the camera zooming.
  99915. */
  99916. pinchPrecision: number;
  99917. /**
  99918. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99919. * from 0.
  99920. * It defines the percentage of current camera.radius to use as delta when
  99921. * pinch zoom is used.
  99922. */
  99923. pinchDeltaPercentage: number;
  99924. /**
  99925. * Defines the pointer panning sensibility or how fast is the camera moving.
  99926. */
  99927. panningSensibility: number;
  99928. /**
  99929. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99930. */
  99931. multiTouchPanning: boolean;
  99932. /**
  99933. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99934. * zoom (pinch) through multitouch.
  99935. */
  99936. multiTouchPanAndZoom: boolean;
  99937. /**
  99938. * Revers pinch action direction.
  99939. */
  99940. pinchInwards: boolean;
  99941. private _isPanClick;
  99942. private _twoFingerActivityCount;
  99943. private _isPinching;
  99944. /**
  99945. * Called on pointer POINTERMOVE event if only a single touch is active.
  99946. */
  99947. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99948. /**
  99949. * Called on pointer POINTERDOUBLETAP event.
  99950. */
  99951. protected onDoubleTap(type: string): void;
  99952. /**
  99953. * Called on pointer POINTERMOVE event if multiple touches are active.
  99954. */
  99955. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99956. /**
  99957. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99958. * press.
  99959. */
  99960. protected onButtonDown(evt: PointerEvent): void;
  99961. /**
  99962. * Called each time a new POINTERUP event occurs. Ie, for each button
  99963. * release.
  99964. */
  99965. protected onButtonUp(evt: PointerEvent): void;
  99966. /**
  99967. * Called when window becomes inactive.
  99968. */
  99969. protected onLostFocus(): void;
  99970. }
  99971. }
  99972. declare module BABYLON {
  99973. /**
  99974. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99976. */
  99977. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99978. /**
  99979. * Defines the camera the input is attached to.
  99980. */
  99981. camera: ArcRotateCamera;
  99982. /**
  99983. * Defines the list of key codes associated with the up action (increase alpha)
  99984. */
  99985. keysUp: number[];
  99986. /**
  99987. * Defines the list of key codes associated with the down action (decrease alpha)
  99988. */
  99989. keysDown: number[];
  99990. /**
  99991. * Defines the list of key codes associated with the left action (increase beta)
  99992. */
  99993. keysLeft: number[];
  99994. /**
  99995. * Defines the list of key codes associated with the right action (decrease beta)
  99996. */
  99997. keysRight: number[];
  99998. /**
  99999. * Defines the list of key codes associated with the reset action.
  100000. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  100001. */
  100002. keysReset: number[];
  100003. /**
  100004. * Defines the panning sensibility of the inputs.
  100005. * (How fast is the camera paning)
  100006. */
  100007. panningSensibility: number;
  100008. /**
  100009. * Defines the zooming sensibility of the inputs.
  100010. * (How fast is the camera zooming)
  100011. */
  100012. zoomingSensibility: number;
  100013. /**
  100014. * Defines wether maintaining the alt key down switch the movement mode from
  100015. * orientation to zoom.
  100016. */
  100017. useAltToZoom: boolean;
  100018. /**
  100019. * Rotation speed of the camera
  100020. */
  100021. angularSpeed: number;
  100022. private _keys;
  100023. private _ctrlPressed;
  100024. private _altPressed;
  100025. private _onCanvasBlurObserver;
  100026. private _onKeyboardObserver;
  100027. private _engine;
  100028. private _scene;
  100029. /**
  100030. * Attach the input controls to a specific dom element to get the input from.
  100031. * @param element Defines the element the controls should be listened from
  100032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100033. */
  100034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100035. /**
  100036. * Detach the current controls from the specified dom element.
  100037. * @param element Defines the element to stop listening the inputs from
  100038. */
  100039. detachControl(element: Nullable<HTMLElement>): void;
  100040. /**
  100041. * Update the current camera state depending on the inputs that have been used this frame.
  100042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100043. */
  100044. checkInputs(): void;
  100045. /**
  100046. * Gets the class name of the current intput.
  100047. * @returns the class name
  100048. */
  100049. getClassName(): string;
  100050. /**
  100051. * Get the friendly name associated with the input class.
  100052. * @returns the input friendly name
  100053. */
  100054. getSimpleName(): string;
  100055. }
  100056. }
  100057. declare module BABYLON {
  100058. /**
  100059. * Manage the mouse wheel inputs to control an arc rotate camera.
  100060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100061. */
  100062. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  100063. /**
  100064. * Defines the camera the input is attached to.
  100065. */
  100066. camera: ArcRotateCamera;
  100067. /**
  100068. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100069. */
  100070. wheelPrecision: number;
  100071. /**
  100072. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  100073. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  100074. */
  100075. wheelDeltaPercentage: number;
  100076. private _wheel;
  100077. private _observer;
  100078. private computeDeltaFromMouseWheelLegacyEvent;
  100079. /**
  100080. * Attach the input controls to a specific dom element to get the input from.
  100081. * @param element Defines the element the controls should be listened from
  100082. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100083. */
  100084. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100085. /**
  100086. * Detach the current controls from the specified dom element.
  100087. * @param element Defines the element to stop listening the inputs from
  100088. */
  100089. detachControl(element: Nullable<HTMLElement>): void;
  100090. /**
  100091. * Gets the class name of the current intput.
  100092. * @returns the class name
  100093. */
  100094. getClassName(): string;
  100095. /**
  100096. * Get the friendly name associated with the input class.
  100097. * @returns the input friendly name
  100098. */
  100099. getSimpleName(): string;
  100100. }
  100101. }
  100102. declare module BABYLON {
  100103. /**
  100104. * Default Inputs manager for the ArcRotateCamera.
  100105. * It groups all the default supported inputs for ease of use.
  100106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100107. */
  100108. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  100109. /**
  100110. * Instantiates a new ArcRotateCameraInputsManager.
  100111. * @param camera Defines the camera the inputs belong to
  100112. */
  100113. constructor(camera: ArcRotateCamera);
  100114. /**
  100115. * Add mouse wheel input support to the input manager.
  100116. * @returns the current input manager
  100117. */
  100118. addMouseWheel(): ArcRotateCameraInputsManager;
  100119. /**
  100120. * Add pointers input support to the input manager.
  100121. * @returns the current input manager
  100122. */
  100123. addPointers(): ArcRotateCameraInputsManager;
  100124. /**
  100125. * Add keyboard input support to the input manager.
  100126. * @returns the current input manager
  100127. */
  100128. addKeyboard(): ArcRotateCameraInputsManager;
  100129. }
  100130. }
  100131. declare module BABYLON {
  100132. /**
  100133. * This represents an orbital type of camera.
  100134. *
  100135. * 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.
  100136. * 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.
  100137. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  100138. */
  100139. export class ArcRotateCamera extends TargetCamera {
  100140. /**
  100141. * Defines the rotation angle of the camera along the longitudinal axis.
  100142. */
  100143. alpha: number;
  100144. /**
  100145. * Defines the rotation angle of the camera along the latitudinal axis.
  100146. */
  100147. beta: number;
  100148. /**
  100149. * Defines the radius of the camera from it s target point.
  100150. */
  100151. radius: number;
  100152. protected _target: Vector3;
  100153. protected _targetHost: Nullable<AbstractMesh>;
  100154. /**
  100155. * Defines the target point of the camera.
  100156. * The camera looks towards it form the radius distance.
  100157. */
  100158. target: Vector3;
  100159. /**
  100160. * Define the current local position of the camera in the scene
  100161. */
  100162. position: Vector3;
  100163. protected _upVector: Vector3;
  100164. protected _upToYMatrix: Matrix;
  100165. protected _YToUpMatrix: Matrix;
  100166. /**
  100167. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  100168. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  100169. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  100170. */
  100171. upVector: Vector3;
  100172. /**
  100173. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  100174. */
  100175. setMatUp(): void;
  100176. /**
  100177. * Current inertia value on the longitudinal axis.
  100178. * The bigger this number the longer it will take for the camera to stop.
  100179. */
  100180. inertialAlphaOffset: number;
  100181. /**
  100182. * Current inertia value on the latitudinal axis.
  100183. * The bigger this number the longer it will take for the camera to stop.
  100184. */
  100185. inertialBetaOffset: number;
  100186. /**
  100187. * Current inertia value on the radius axis.
  100188. * The bigger this number the longer it will take for the camera to stop.
  100189. */
  100190. inertialRadiusOffset: number;
  100191. /**
  100192. * Minimum allowed angle on the longitudinal axis.
  100193. * This can help limiting how the Camera is able to move in the scene.
  100194. */
  100195. lowerAlphaLimit: Nullable<number>;
  100196. /**
  100197. * Maximum allowed angle on the longitudinal axis.
  100198. * This can help limiting how the Camera is able to move in the scene.
  100199. */
  100200. upperAlphaLimit: Nullable<number>;
  100201. /**
  100202. * Minimum allowed angle on the latitudinal axis.
  100203. * This can help limiting how the Camera is able to move in the scene.
  100204. */
  100205. lowerBetaLimit: number;
  100206. /**
  100207. * Maximum allowed angle on the latitudinal axis.
  100208. * This can help limiting how the Camera is able to move in the scene.
  100209. */
  100210. upperBetaLimit: number;
  100211. /**
  100212. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  100213. * This can help limiting how the Camera is able to move in the scene.
  100214. */
  100215. lowerRadiusLimit: Nullable<number>;
  100216. /**
  100217. * Maximum allowed distance of the camera to the target (The camera can not get further).
  100218. * This can help limiting how the Camera is able to move in the scene.
  100219. */
  100220. upperRadiusLimit: Nullable<number>;
  100221. /**
  100222. * Defines the current inertia value used during panning of the camera along the X axis.
  100223. */
  100224. inertialPanningX: number;
  100225. /**
  100226. * Defines the current inertia value used during panning of the camera along the Y axis.
  100227. */
  100228. inertialPanningY: number;
  100229. /**
  100230. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  100231. * Basically if your fingers moves away from more than this distance you will be considered
  100232. * in pinch mode.
  100233. */
  100234. pinchToPanMaxDistance: number;
  100235. /**
  100236. * Defines the maximum distance the camera can pan.
  100237. * This could help keeping the cammera always in your scene.
  100238. */
  100239. panningDistanceLimit: Nullable<number>;
  100240. /**
  100241. * Defines the target of the camera before paning.
  100242. */
  100243. panningOriginTarget: Vector3;
  100244. /**
  100245. * Defines the value of the inertia used during panning.
  100246. * 0 would mean stop inertia and one would mean no decelleration at all.
  100247. */
  100248. panningInertia: number;
  100249. /**
  100250. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  100251. */
  100252. angularSensibilityX: number;
  100253. /**
  100254. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  100255. */
  100256. angularSensibilityY: number;
  100257. /**
  100258. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  100259. */
  100260. pinchPrecision: number;
  100261. /**
  100262. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  100263. * It will be used instead of pinchDeltaPrecision if different from 0.
  100264. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100265. */
  100266. pinchDeltaPercentage: number;
  100267. /**
  100268. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  100269. */
  100270. panningSensibility: number;
  100271. /**
  100272. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  100273. */
  100274. keysUp: number[];
  100275. /**
  100276. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  100277. */
  100278. keysDown: number[];
  100279. /**
  100280. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  100281. */
  100282. keysLeft: number[];
  100283. /**
  100284. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  100285. */
  100286. keysRight: number[];
  100287. /**
  100288. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  100289. */
  100290. wheelPrecision: number;
  100291. /**
  100292. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  100293. * It will be used instead of pinchDeltaPrecision if different from 0.
  100294. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  100295. */
  100296. wheelDeltaPercentage: number;
  100297. /**
  100298. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  100299. */
  100300. zoomOnFactor: number;
  100301. /**
  100302. * Defines a screen offset for the camera position.
  100303. */
  100304. targetScreenOffset: Vector2;
  100305. /**
  100306. * Allows the camera to be completely reversed.
  100307. * If false the camera can not arrive upside down.
  100308. */
  100309. allowUpsideDown: boolean;
  100310. /**
  100311. * Define if double tap/click is used to restore the previously saved state of the camera.
  100312. */
  100313. useInputToRestoreState: boolean;
  100314. /** @hidden */
  100315. _viewMatrix: Matrix;
  100316. /** @hidden */
  100317. _useCtrlForPanning: boolean;
  100318. /** @hidden */
  100319. _panningMouseButton: number;
  100320. /**
  100321. * Defines the input associated to the camera.
  100322. */
  100323. inputs: ArcRotateCameraInputsManager;
  100324. /** @hidden */
  100325. _reset: () => void;
  100326. /**
  100327. * Defines the allowed panning axis.
  100328. */
  100329. panningAxis: Vector3;
  100330. protected _localDirection: Vector3;
  100331. protected _transformedDirection: Vector3;
  100332. private _bouncingBehavior;
  100333. /**
  100334. * Gets the bouncing behavior of the camera if it has been enabled.
  100335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100336. */
  100337. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  100338. /**
  100339. * Defines if the bouncing behavior of the camera is enabled on the camera.
  100340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  100341. */
  100342. useBouncingBehavior: boolean;
  100343. private _framingBehavior;
  100344. /**
  100345. * Gets the framing behavior of the camera if it has been enabled.
  100346. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100347. */
  100348. readonly framingBehavior: Nullable<FramingBehavior>;
  100349. /**
  100350. * Defines if the framing behavior of the camera is enabled on the camera.
  100351. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  100352. */
  100353. useFramingBehavior: boolean;
  100354. private _autoRotationBehavior;
  100355. /**
  100356. * Gets the auto rotation behavior of the camera if it has been enabled.
  100357. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100358. */
  100359. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  100360. /**
  100361. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  100362. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100363. */
  100364. useAutoRotationBehavior: boolean;
  100365. /**
  100366. * Observable triggered when the mesh target has been changed on the camera.
  100367. */
  100368. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100369. /**
  100370. * Event raised when the camera is colliding with a mesh.
  100371. */
  100372. onCollide: (collidedMesh: AbstractMesh) => void;
  100373. /**
  100374. * Defines whether the camera should check collision with the objects oh the scene.
  100375. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100376. */
  100377. checkCollisions: boolean;
  100378. /**
  100379. * Defines the collision radius of the camera.
  100380. * This simulates a sphere around the camera.
  100381. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100382. */
  100383. collisionRadius: Vector3;
  100384. protected _collider: Collider;
  100385. protected _previousPosition: Vector3;
  100386. protected _collisionVelocity: Vector3;
  100387. protected _newPosition: Vector3;
  100388. protected _previousAlpha: number;
  100389. protected _previousBeta: number;
  100390. protected _previousRadius: number;
  100391. protected _collisionTriggered: boolean;
  100392. protected _targetBoundingCenter: Nullable<Vector3>;
  100393. private _computationVector;
  100394. /**
  100395. * Instantiates a new ArcRotateCamera in a given scene
  100396. * @param name Defines the name of the camera
  100397. * @param alpha Defines the camera rotation along the logitudinal axis
  100398. * @param beta Defines the camera rotation along the latitudinal axis
  100399. * @param radius Defines the camera distance from its target
  100400. * @param target Defines the camera target
  100401. * @param scene Defines the scene the camera belongs to
  100402. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100403. */
  100404. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100405. /** @hidden */
  100406. _initCache(): void;
  100407. /** @hidden */
  100408. _updateCache(ignoreParentClass?: boolean): void;
  100409. protected _getTargetPosition(): Vector3;
  100410. private _storedAlpha;
  100411. private _storedBeta;
  100412. private _storedRadius;
  100413. private _storedTarget;
  100414. /**
  100415. * Stores the current state of the camera (alpha, beta, radius and target)
  100416. * @returns the camera itself
  100417. */
  100418. storeState(): Camera;
  100419. /**
  100420. * @hidden
  100421. * Restored camera state. You must call storeState() first
  100422. */
  100423. _restoreStateValues(): boolean;
  100424. /** @hidden */
  100425. _isSynchronizedViewMatrix(): boolean;
  100426. /**
  100427. * Attached controls to the current camera.
  100428. * @param element Defines the element the controls should be listened from
  100429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100430. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100431. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100432. */
  100433. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100434. /**
  100435. * Detach the current controls from the camera.
  100436. * The camera will stop reacting to inputs.
  100437. * @param element Defines the element to stop listening the inputs from
  100438. */
  100439. detachControl(element: HTMLElement): void;
  100440. /** @hidden */
  100441. _checkInputs(): void;
  100442. protected _checkLimits(): void;
  100443. /**
  100444. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100445. */
  100446. rebuildAnglesAndRadius(): void;
  100447. /**
  100448. * Use a position to define the current camera related information like aplha, beta and radius
  100449. * @param position Defines the position to set the camera at
  100450. */
  100451. setPosition(position: Vector3): void;
  100452. /**
  100453. * Defines the target the camera should look at.
  100454. * This will automatically adapt alpha beta and radius to fit within the new target.
  100455. * @param target Defines the new target as a Vector or a mesh
  100456. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100457. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100458. */
  100459. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100460. /** @hidden */
  100461. _getViewMatrix(): Matrix;
  100462. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100463. /**
  100464. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100465. * @param meshes Defines the mesh to zoom on
  100466. * @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)
  100467. */
  100468. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100469. /**
  100470. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100471. * The target will be changed but the radius
  100472. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100473. * @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)
  100474. */
  100475. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100476. min: Vector3;
  100477. max: Vector3;
  100478. distance: number;
  100479. }, doNotUpdateMaxZ?: boolean): void;
  100480. /**
  100481. * @override
  100482. * Override Camera.createRigCamera
  100483. */
  100484. createRigCamera(name: string, cameraIndex: number): Camera;
  100485. /**
  100486. * @hidden
  100487. * @override
  100488. * Override Camera._updateRigCameras
  100489. */
  100490. _updateRigCameras(): void;
  100491. /**
  100492. * Destroy the camera and release the current resources hold by it.
  100493. */
  100494. dispose(): void;
  100495. /**
  100496. * Gets the current object class name.
  100497. * @return the class name
  100498. */
  100499. getClassName(): string;
  100500. }
  100501. }
  100502. declare module BABYLON {
  100503. /**
  100504. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100505. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100506. */
  100507. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100508. /**
  100509. * Gets the name of the behavior.
  100510. */
  100511. readonly name: string;
  100512. private _zoomStopsAnimation;
  100513. private _idleRotationSpeed;
  100514. private _idleRotationWaitTime;
  100515. private _idleRotationSpinupTime;
  100516. /**
  100517. * Sets the flag that indicates if user zooming should stop animation.
  100518. */
  100519. /**
  100520. * Gets the flag that indicates if user zooming should stop animation.
  100521. */
  100522. zoomStopsAnimation: boolean;
  100523. /**
  100524. * Sets the default speed at which the camera rotates around the model.
  100525. */
  100526. /**
  100527. * Gets the default speed at which the camera rotates around the model.
  100528. */
  100529. idleRotationSpeed: number;
  100530. /**
  100531. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100532. */
  100533. /**
  100534. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100535. */
  100536. idleRotationWaitTime: number;
  100537. /**
  100538. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100539. */
  100540. /**
  100541. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100542. */
  100543. idleRotationSpinupTime: number;
  100544. /**
  100545. * Gets a value indicating if the camera is currently rotating because of this behavior
  100546. */
  100547. readonly rotationInProgress: boolean;
  100548. private _onPrePointerObservableObserver;
  100549. private _onAfterCheckInputsObserver;
  100550. private _attachedCamera;
  100551. private _isPointerDown;
  100552. private _lastFrameTime;
  100553. private _lastInteractionTime;
  100554. private _cameraRotationSpeed;
  100555. /**
  100556. * Initializes the behavior.
  100557. */
  100558. init(): void;
  100559. /**
  100560. * Attaches the behavior to its arc rotate camera.
  100561. * @param camera Defines the camera to attach the behavior to
  100562. */
  100563. attach(camera: ArcRotateCamera): void;
  100564. /**
  100565. * Detaches the behavior from its current arc rotate camera.
  100566. */
  100567. detach(): void;
  100568. /**
  100569. * Returns true if user is scrolling.
  100570. * @return true if user is scrolling.
  100571. */
  100572. private _userIsZooming;
  100573. private _lastFrameRadius;
  100574. private _shouldAnimationStopForInteraction;
  100575. /**
  100576. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100577. */
  100578. private _applyUserInteraction;
  100579. private _userIsMoving;
  100580. }
  100581. }
  100582. declare module BABYLON {
  100583. /**
  100584. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100585. */
  100586. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100587. private ui;
  100588. /**
  100589. * The name of the behavior
  100590. */
  100591. name: string;
  100592. /**
  100593. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100594. */
  100595. distanceAwayFromFace: number;
  100596. /**
  100597. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100598. */
  100599. distanceAwayFromBottomOfFace: number;
  100600. private _faceVectors;
  100601. private _target;
  100602. private _scene;
  100603. private _onRenderObserver;
  100604. private _tmpMatrix;
  100605. private _tmpVector;
  100606. /**
  100607. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100608. * @param ui The transform node that should be attched to the mesh
  100609. */
  100610. constructor(ui: TransformNode);
  100611. /**
  100612. * Initializes the behavior
  100613. */
  100614. init(): void;
  100615. private _closestFace;
  100616. private _zeroVector;
  100617. private _lookAtTmpMatrix;
  100618. private _lookAtToRef;
  100619. /**
  100620. * Attaches the AttachToBoxBehavior to the passed in mesh
  100621. * @param target The mesh that the specified node will be attached to
  100622. */
  100623. attach(target: Mesh): void;
  100624. /**
  100625. * Detaches the behavior from the mesh
  100626. */
  100627. detach(): void;
  100628. }
  100629. }
  100630. declare module BABYLON {
  100631. /**
  100632. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100633. */
  100634. export class FadeInOutBehavior implements Behavior<Mesh> {
  100635. /**
  100636. * Time in milliseconds to delay before fading in (Default: 0)
  100637. */
  100638. delay: number;
  100639. /**
  100640. * Time in milliseconds for the mesh to fade in (Default: 300)
  100641. */
  100642. fadeInTime: number;
  100643. private _millisecondsPerFrame;
  100644. private _hovered;
  100645. private _hoverValue;
  100646. private _ownerNode;
  100647. /**
  100648. * Instatiates the FadeInOutBehavior
  100649. */
  100650. constructor();
  100651. /**
  100652. * The name of the behavior
  100653. */
  100654. readonly name: string;
  100655. /**
  100656. * Initializes the behavior
  100657. */
  100658. init(): void;
  100659. /**
  100660. * Attaches the fade behavior on the passed in mesh
  100661. * @param ownerNode The mesh that will be faded in/out once attached
  100662. */
  100663. attach(ownerNode: Mesh): void;
  100664. /**
  100665. * Detaches the behavior from the mesh
  100666. */
  100667. detach(): void;
  100668. /**
  100669. * Triggers the mesh to begin fading in or out
  100670. * @param value if the object should fade in or out (true to fade in)
  100671. */
  100672. fadeIn(value: boolean): void;
  100673. private _update;
  100674. private _setAllVisibility;
  100675. }
  100676. }
  100677. declare module BABYLON {
  100678. /**
  100679. * Class containing a set of static utilities functions for managing Pivots
  100680. * @hidden
  100681. */
  100682. export class PivotTools {
  100683. private static _PivotCached;
  100684. private static _OldPivotPoint;
  100685. private static _PivotTranslation;
  100686. private static _PivotTmpVector;
  100687. /** @hidden */
  100688. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100689. /** @hidden */
  100690. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /**
  100695. * Class containing static functions to help procedurally build meshes
  100696. */
  100697. export class PlaneBuilder {
  100698. /**
  100699. * Creates a plane mesh
  100700. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100701. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100702. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100706. * @param name defines the name of the mesh
  100707. * @param options defines the options used to create the mesh
  100708. * @param scene defines the hosting scene
  100709. * @returns the plane mesh
  100710. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100711. */
  100712. static CreatePlane(name: string, options: {
  100713. size?: number;
  100714. width?: number;
  100715. height?: number;
  100716. sideOrientation?: number;
  100717. frontUVs?: Vector4;
  100718. backUVs?: Vector4;
  100719. updatable?: boolean;
  100720. sourcePlane?: Plane;
  100721. }, scene?: Nullable<Scene>): Mesh;
  100722. }
  100723. }
  100724. declare module BABYLON {
  100725. /**
  100726. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100727. */
  100728. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100729. private static _AnyMouseID;
  100730. /**
  100731. * Abstract mesh the behavior is set on
  100732. */
  100733. attachedNode: AbstractMesh;
  100734. private _dragPlane;
  100735. private _scene;
  100736. private _pointerObserver;
  100737. private _beforeRenderObserver;
  100738. private static _planeScene;
  100739. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100740. /**
  100741. * 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)
  100742. */
  100743. maxDragAngle: number;
  100744. /**
  100745. * @hidden
  100746. */
  100747. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100748. /**
  100749. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100750. */
  100751. currentDraggingPointerID: number;
  100752. /**
  100753. * The last position where the pointer hit the drag plane in world space
  100754. */
  100755. lastDragPosition: Vector3;
  100756. /**
  100757. * If the behavior is currently in a dragging state
  100758. */
  100759. dragging: boolean;
  100760. /**
  100761. * 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)
  100762. */
  100763. dragDeltaRatio: number;
  100764. /**
  100765. * If the drag plane orientation should be updated during the dragging (Default: true)
  100766. */
  100767. updateDragPlane: boolean;
  100768. private _debugMode;
  100769. private _moving;
  100770. /**
  100771. * Fires each time the attached mesh is dragged with the pointer
  100772. * * delta between last drag position and current drag position in world space
  100773. * * dragDistance along the drag axis
  100774. * * dragPlaneNormal normal of the current drag plane used during the drag
  100775. * * dragPlanePoint in world space where the drag intersects the drag plane
  100776. */
  100777. onDragObservable: Observable<{
  100778. delta: Vector3;
  100779. dragPlanePoint: Vector3;
  100780. dragPlaneNormal: Vector3;
  100781. dragDistance: number;
  100782. pointerId: number;
  100783. }>;
  100784. /**
  100785. * Fires each time a drag begins (eg. mouse down on mesh)
  100786. */
  100787. onDragStartObservable: Observable<{
  100788. dragPlanePoint: Vector3;
  100789. pointerId: number;
  100790. }>;
  100791. /**
  100792. * Fires each time a drag ends (eg. mouse release after drag)
  100793. */
  100794. onDragEndObservable: Observable<{
  100795. dragPlanePoint: Vector3;
  100796. pointerId: number;
  100797. }>;
  100798. /**
  100799. * If the attached mesh should be moved when dragged
  100800. */
  100801. moveAttached: boolean;
  100802. /**
  100803. * If the drag behavior will react to drag events (Default: true)
  100804. */
  100805. enabled: boolean;
  100806. /**
  100807. * If pointer events should start and release the drag (Default: true)
  100808. */
  100809. startAndReleaseDragOnPointerEvents: boolean;
  100810. /**
  100811. * If camera controls should be detached during the drag
  100812. */
  100813. detachCameraControls: boolean;
  100814. /**
  100815. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100816. */
  100817. useObjectOrienationForDragging: boolean;
  100818. private _options;
  100819. /**
  100820. * Creates a pointer drag behavior that can be attached to a mesh
  100821. * @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)
  100822. */
  100823. constructor(options?: {
  100824. dragAxis?: Vector3;
  100825. dragPlaneNormal?: Vector3;
  100826. });
  100827. /**
  100828. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100829. */
  100830. validateDrag: (targetPosition: Vector3) => boolean;
  100831. /**
  100832. * The name of the behavior
  100833. */
  100834. readonly name: string;
  100835. /**
  100836. * Initializes the behavior
  100837. */
  100838. init(): void;
  100839. private _tmpVector;
  100840. private _alternatePickedPoint;
  100841. private _worldDragAxis;
  100842. private _targetPosition;
  100843. private _attachedElement;
  100844. /**
  100845. * Attaches the drag behavior the passed in mesh
  100846. * @param ownerNode The mesh that will be dragged around once attached
  100847. */
  100848. attach(ownerNode: AbstractMesh): void;
  100849. /**
  100850. * Force relase the drag action by code.
  100851. */
  100852. releaseDrag(): void;
  100853. private _startDragRay;
  100854. private _lastPointerRay;
  100855. /**
  100856. * Simulates the start of a pointer drag event on the behavior
  100857. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100858. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100859. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100860. */
  100861. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100862. private _startDrag;
  100863. private _dragDelta;
  100864. private _moveDrag;
  100865. private _pickWithRayOnDragPlane;
  100866. private _pointA;
  100867. private _pointB;
  100868. private _pointC;
  100869. private _lineA;
  100870. private _lineB;
  100871. private _localAxis;
  100872. private _lookAt;
  100873. private _updateDragPlanePosition;
  100874. /**
  100875. * Detaches the behavior from the mesh
  100876. */
  100877. detach(): void;
  100878. }
  100879. }
  100880. declare module BABYLON {
  100881. /**
  100882. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100883. */
  100884. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100885. private _dragBehaviorA;
  100886. private _dragBehaviorB;
  100887. private _startDistance;
  100888. private _initialScale;
  100889. private _targetScale;
  100890. private _ownerNode;
  100891. private _sceneRenderObserver;
  100892. /**
  100893. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100894. */
  100895. constructor();
  100896. /**
  100897. * The name of the behavior
  100898. */
  100899. readonly name: string;
  100900. /**
  100901. * Initializes the behavior
  100902. */
  100903. init(): void;
  100904. private _getCurrentDistance;
  100905. /**
  100906. * Attaches the scale behavior the passed in mesh
  100907. * @param ownerNode The mesh that will be scaled around once attached
  100908. */
  100909. attach(ownerNode: Mesh): void;
  100910. /**
  100911. * Detaches the behavior from the mesh
  100912. */
  100913. detach(): void;
  100914. }
  100915. }
  100916. declare module BABYLON {
  100917. /**
  100918. * 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
  100919. */
  100920. export class SixDofDragBehavior implements Behavior<Mesh> {
  100921. private static _virtualScene;
  100922. private _ownerNode;
  100923. private _sceneRenderObserver;
  100924. private _scene;
  100925. private _targetPosition;
  100926. private _virtualOriginMesh;
  100927. private _virtualDragMesh;
  100928. private _pointerObserver;
  100929. private _moving;
  100930. private _startingOrientation;
  100931. /**
  100932. * 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)
  100933. */
  100934. private zDragFactor;
  100935. /**
  100936. * If the object should rotate to face the drag origin
  100937. */
  100938. rotateDraggedObject: boolean;
  100939. /**
  100940. * If the behavior is currently in a dragging state
  100941. */
  100942. dragging: boolean;
  100943. /**
  100944. * 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)
  100945. */
  100946. dragDeltaRatio: number;
  100947. /**
  100948. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100949. */
  100950. currentDraggingPointerID: number;
  100951. /**
  100952. * If camera controls should be detached during the drag
  100953. */
  100954. detachCameraControls: boolean;
  100955. /**
  100956. * Fires each time a drag starts
  100957. */
  100958. onDragStartObservable: Observable<{}>;
  100959. /**
  100960. * Fires each time a drag ends (eg. mouse release after drag)
  100961. */
  100962. onDragEndObservable: Observable<{}>;
  100963. /**
  100964. * 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
  100965. */
  100966. constructor();
  100967. /**
  100968. * The name of the behavior
  100969. */
  100970. readonly name: string;
  100971. /**
  100972. * Initializes the behavior
  100973. */
  100974. init(): void;
  100975. /**
  100976. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100977. */
  100978. private readonly _pointerCamera;
  100979. /**
  100980. * Attaches the scale behavior the passed in mesh
  100981. * @param ownerNode The mesh that will be scaled around once attached
  100982. */
  100983. attach(ownerNode: Mesh): void;
  100984. /**
  100985. * Detaches the behavior from the mesh
  100986. */
  100987. detach(): void;
  100988. }
  100989. }
  100990. declare module BABYLON {
  100991. /**
  100992. * Class used to apply inverse kinematics to bones
  100993. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100994. */
  100995. export class BoneIKController {
  100996. private static _tmpVecs;
  100997. private static _tmpQuat;
  100998. private static _tmpMats;
  100999. /**
  101000. * Gets or sets the target mesh
  101001. */
  101002. targetMesh: AbstractMesh;
  101003. /** Gets or sets the mesh used as pole */
  101004. poleTargetMesh: AbstractMesh;
  101005. /**
  101006. * Gets or sets the bone used as pole
  101007. */
  101008. poleTargetBone: Nullable<Bone>;
  101009. /**
  101010. * Gets or sets the target position
  101011. */
  101012. targetPosition: Vector3;
  101013. /**
  101014. * Gets or sets the pole target position
  101015. */
  101016. poleTargetPosition: Vector3;
  101017. /**
  101018. * Gets or sets the pole target local offset
  101019. */
  101020. poleTargetLocalOffset: Vector3;
  101021. /**
  101022. * Gets or sets the pole angle
  101023. */
  101024. poleAngle: number;
  101025. /**
  101026. * Gets or sets the mesh associated with the controller
  101027. */
  101028. mesh: AbstractMesh;
  101029. /**
  101030. * 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)
  101031. */
  101032. slerpAmount: number;
  101033. private _bone1Quat;
  101034. private _bone1Mat;
  101035. private _bone2Ang;
  101036. private _bone1;
  101037. private _bone2;
  101038. private _bone1Length;
  101039. private _bone2Length;
  101040. private _maxAngle;
  101041. private _maxReach;
  101042. private _rightHandedSystem;
  101043. private _bendAxis;
  101044. private _slerping;
  101045. private _adjustRoll;
  101046. /**
  101047. * Gets or sets maximum allowed angle
  101048. */
  101049. maxAngle: number;
  101050. /**
  101051. * Creates a new BoneIKController
  101052. * @param mesh defines the mesh to control
  101053. * @param bone defines the bone to control
  101054. * @param options defines options to set up the controller
  101055. */
  101056. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  101057. targetMesh?: AbstractMesh;
  101058. poleTargetMesh?: AbstractMesh;
  101059. poleTargetBone?: Bone;
  101060. poleTargetLocalOffset?: Vector3;
  101061. poleAngle?: number;
  101062. bendAxis?: Vector3;
  101063. maxAngle?: number;
  101064. slerpAmount?: number;
  101065. });
  101066. private _setMaxAngle;
  101067. /**
  101068. * Force the controller to update the bones
  101069. */
  101070. update(): void;
  101071. }
  101072. }
  101073. declare module BABYLON {
  101074. /**
  101075. * Class used to make a bone look toward a point in space
  101076. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  101077. */
  101078. export class BoneLookController {
  101079. private static _tmpVecs;
  101080. private static _tmpQuat;
  101081. private static _tmpMats;
  101082. /**
  101083. * The target Vector3 that the bone will look at
  101084. */
  101085. target: Vector3;
  101086. /**
  101087. * The mesh that the bone is attached to
  101088. */
  101089. mesh: AbstractMesh;
  101090. /**
  101091. * The bone that will be looking to the target
  101092. */
  101093. bone: Bone;
  101094. /**
  101095. * The up axis of the coordinate system that is used when the bone is rotated
  101096. */
  101097. upAxis: Vector3;
  101098. /**
  101099. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  101100. */
  101101. upAxisSpace: Space;
  101102. /**
  101103. * Used to make an adjustment to the yaw of the bone
  101104. */
  101105. adjustYaw: number;
  101106. /**
  101107. * Used to make an adjustment to the pitch of the bone
  101108. */
  101109. adjustPitch: number;
  101110. /**
  101111. * Used to make an adjustment to the roll of the bone
  101112. */
  101113. adjustRoll: number;
  101114. /**
  101115. * 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)
  101116. */
  101117. slerpAmount: number;
  101118. private _minYaw;
  101119. private _maxYaw;
  101120. private _minPitch;
  101121. private _maxPitch;
  101122. private _minYawSin;
  101123. private _minYawCos;
  101124. private _maxYawSin;
  101125. private _maxYawCos;
  101126. private _midYawConstraint;
  101127. private _minPitchTan;
  101128. private _maxPitchTan;
  101129. private _boneQuat;
  101130. private _slerping;
  101131. private _transformYawPitch;
  101132. private _transformYawPitchInv;
  101133. private _firstFrameSkipped;
  101134. private _yawRange;
  101135. private _fowardAxis;
  101136. /**
  101137. * Gets or sets the minimum yaw angle that the bone can look to
  101138. */
  101139. minYaw: number;
  101140. /**
  101141. * Gets or sets the maximum yaw angle that the bone can look to
  101142. */
  101143. maxYaw: number;
  101144. /**
  101145. * Gets or sets the minimum pitch angle that the bone can look to
  101146. */
  101147. minPitch: number;
  101148. /**
  101149. * Gets or sets the maximum pitch angle that the bone can look to
  101150. */
  101151. maxPitch: number;
  101152. /**
  101153. * Create a BoneLookController
  101154. * @param mesh the mesh that the bone belongs to
  101155. * @param bone the bone that will be looking to the target
  101156. * @param target the target Vector3 to look at
  101157. * @param options optional settings:
  101158. * * maxYaw: the maximum angle the bone will yaw to
  101159. * * minYaw: the minimum angle the bone will yaw to
  101160. * * maxPitch: the maximum angle the bone will pitch to
  101161. * * minPitch: the minimum angle the bone will yaw to
  101162. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  101163. * * upAxis: the up axis of the coordinate system
  101164. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  101165. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  101166. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  101167. * * adjustYaw: used to make an adjustment to the yaw of the bone
  101168. * * adjustPitch: used to make an adjustment to the pitch of the bone
  101169. * * adjustRoll: used to make an adjustment to the roll of the bone
  101170. **/
  101171. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  101172. maxYaw?: number;
  101173. minYaw?: number;
  101174. maxPitch?: number;
  101175. minPitch?: number;
  101176. slerpAmount?: number;
  101177. upAxis?: Vector3;
  101178. upAxisSpace?: Space;
  101179. yawAxis?: Vector3;
  101180. pitchAxis?: Vector3;
  101181. adjustYaw?: number;
  101182. adjustPitch?: number;
  101183. adjustRoll?: number;
  101184. });
  101185. /**
  101186. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  101187. */
  101188. update(): void;
  101189. private _getAngleDiff;
  101190. private _getAngleBetween;
  101191. private _isAngleBetween;
  101192. }
  101193. }
  101194. declare module BABYLON {
  101195. /**
  101196. * Manage the gamepad inputs to control an arc rotate camera.
  101197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101198. */
  101199. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  101200. /**
  101201. * Defines the camera the input is attached to.
  101202. */
  101203. camera: ArcRotateCamera;
  101204. /**
  101205. * Defines the gamepad the input is gathering event from.
  101206. */
  101207. gamepad: Nullable<Gamepad>;
  101208. /**
  101209. * Defines the gamepad rotation sensiblity.
  101210. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101211. */
  101212. gamepadRotationSensibility: number;
  101213. /**
  101214. * Defines the gamepad move sensiblity.
  101215. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101216. */
  101217. gamepadMoveSensibility: number;
  101218. private _onGamepadConnectedObserver;
  101219. private _onGamepadDisconnectedObserver;
  101220. /**
  101221. * Attach the input controls to a specific dom element to get the input from.
  101222. * @param element Defines the element the controls should be listened from
  101223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101224. */
  101225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101226. /**
  101227. * Detach the current controls from the specified dom element.
  101228. * @param element Defines the element to stop listening the inputs from
  101229. */
  101230. detachControl(element: Nullable<HTMLElement>): void;
  101231. /**
  101232. * Update the current camera state depending on the inputs that have been used this frame.
  101233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101234. */
  101235. checkInputs(): void;
  101236. /**
  101237. * Gets the class name of the current intput.
  101238. * @returns the class name
  101239. */
  101240. getClassName(): string;
  101241. /**
  101242. * Get the friendly name associated with the input class.
  101243. * @returns the input friendly name
  101244. */
  101245. getSimpleName(): string;
  101246. }
  101247. }
  101248. declare module BABYLON {
  101249. interface ArcRotateCameraInputsManager {
  101250. /**
  101251. * Add orientation input support to the input manager.
  101252. * @returns the current input manager
  101253. */
  101254. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  101255. }
  101256. /**
  101257. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  101258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101259. */
  101260. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  101261. /**
  101262. * Defines the camera the input is attached to.
  101263. */
  101264. camera: ArcRotateCamera;
  101265. /**
  101266. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  101267. */
  101268. alphaCorrection: number;
  101269. /**
  101270. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  101271. */
  101272. gammaCorrection: number;
  101273. private _alpha;
  101274. private _gamma;
  101275. private _dirty;
  101276. private _deviceOrientationHandler;
  101277. /**
  101278. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  101279. */
  101280. constructor();
  101281. /**
  101282. * Attach the input controls to a specific dom element to get the input from.
  101283. * @param element Defines the element the controls should be listened from
  101284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101285. */
  101286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101287. /** @hidden */
  101288. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  101289. /**
  101290. * Update the current camera state depending on the inputs that have been used this frame.
  101291. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101292. */
  101293. checkInputs(): void;
  101294. /**
  101295. * Detach the current controls from the specified dom element.
  101296. * @param element Defines the element to stop listening the inputs from
  101297. */
  101298. detachControl(element: Nullable<HTMLElement>): void;
  101299. /**
  101300. * Gets the class name of the current intput.
  101301. * @returns the class name
  101302. */
  101303. getClassName(): string;
  101304. /**
  101305. * Get the friendly name associated with the input class.
  101306. * @returns the input friendly name
  101307. */
  101308. getSimpleName(): string;
  101309. }
  101310. }
  101311. declare module BABYLON {
  101312. /**
  101313. * Listen to mouse events to control the camera.
  101314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101315. */
  101316. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  101317. /**
  101318. * Defines the camera the input is attached to.
  101319. */
  101320. camera: FlyCamera;
  101321. /**
  101322. * Defines if touch is enabled. (Default is true.)
  101323. */
  101324. touchEnabled: boolean;
  101325. /**
  101326. * Defines the buttons associated with the input to handle camera rotation.
  101327. */
  101328. buttons: number[];
  101329. /**
  101330. * Assign buttons for Yaw control.
  101331. */
  101332. buttonsYaw: number[];
  101333. /**
  101334. * Assign buttons for Pitch control.
  101335. */
  101336. buttonsPitch: number[];
  101337. /**
  101338. * Assign buttons for Roll control.
  101339. */
  101340. buttonsRoll: number[];
  101341. /**
  101342. * Detect if any button is being pressed while mouse is moved.
  101343. * -1 = Mouse locked.
  101344. * 0 = Left button.
  101345. * 1 = Middle Button.
  101346. * 2 = Right Button.
  101347. */
  101348. activeButton: number;
  101349. /**
  101350. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  101351. * Higher values reduce its sensitivity.
  101352. */
  101353. angularSensibility: number;
  101354. private _mousemoveCallback;
  101355. private _observer;
  101356. private _rollObserver;
  101357. private previousPosition;
  101358. private noPreventDefault;
  101359. private element;
  101360. /**
  101361. * Listen to mouse events to control the camera.
  101362. * @param touchEnabled Define if touch is enabled. (Default is true.)
  101363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101364. */
  101365. constructor(touchEnabled?: boolean);
  101366. /**
  101367. * Attach the mouse control to the HTML DOM element.
  101368. * @param element Defines the element that listens to the input events.
  101369. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101370. */
  101371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101372. /**
  101373. * Detach the current controls from the specified dom element.
  101374. * @param element Defines the element to stop listening the inputs from
  101375. */
  101376. detachControl(element: Nullable<HTMLElement>): void;
  101377. /**
  101378. * Gets the class name of the current input.
  101379. * @returns the class name.
  101380. */
  101381. getClassName(): string;
  101382. /**
  101383. * Get the friendly name associated with the input class.
  101384. * @returns the input's friendly name.
  101385. */
  101386. getSimpleName(): string;
  101387. private _pointerInput;
  101388. private _onMouseMove;
  101389. /**
  101390. * Rotate camera by mouse offset.
  101391. */
  101392. private rotateCamera;
  101393. }
  101394. }
  101395. declare module BABYLON {
  101396. /**
  101397. * Default Inputs manager for the FlyCamera.
  101398. * It groups all the default supported inputs for ease of use.
  101399. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101400. */
  101401. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101402. /**
  101403. * Instantiates a new FlyCameraInputsManager.
  101404. * @param camera Defines the camera the inputs belong to.
  101405. */
  101406. constructor(camera: FlyCamera);
  101407. /**
  101408. * Add keyboard input support to the input manager.
  101409. * @returns the new FlyCameraKeyboardMoveInput().
  101410. */
  101411. addKeyboard(): FlyCameraInputsManager;
  101412. /**
  101413. * Add mouse input support to the input manager.
  101414. * @param touchEnabled Enable touch screen support.
  101415. * @returns the new FlyCameraMouseInput().
  101416. */
  101417. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101418. }
  101419. }
  101420. declare module BABYLON {
  101421. /**
  101422. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101423. * such as in a 3D Space Shooter or a Flight Simulator.
  101424. */
  101425. export class FlyCamera extends TargetCamera {
  101426. /**
  101427. * Define the collision ellipsoid of the camera.
  101428. * This is helpful for simulating a camera body, like a player's body.
  101429. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101430. */
  101431. ellipsoid: Vector3;
  101432. /**
  101433. * Define an offset for the position of the ellipsoid around the camera.
  101434. * This can be helpful if the camera is attached away from the player's body center,
  101435. * such as at its head.
  101436. */
  101437. ellipsoidOffset: Vector3;
  101438. /**
  101439. * Enable or disable collisions of the camera with the rest of the scene objects.
  101440. */
  101441. checkCollisions: boolean;
  101442. /**
  101443. * Enable or disable gravity on the camera.
  101444. */
  101445. applyGravity: boolean;
  101446. /**
  101447. * Define the current direction the camera is moving to.
  101448. */
  101449. cameraDirection: Vector3;
  101450. /**
  101451. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101452. * This overrides and empties cameraRotation.
  101453. */
  101454. rotationQuaternion: Quaternion;
  101455. /**
  101456. * Track Roll to maintain the wanted Rolling when looking around.
  101457. */
  101458. _trackRoll: number;
  101459. /**
  101460. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101461. */
  101462. rollCorrect: number;
  101463. /**
  101464. * Mimic a banked turn, Rolling the camera when Yawing.
  101465. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101466. */
  101467. bankedTurn: boolean;
  101468. /**
  101469. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101470. */
  101471. bankedTurnLimit: number;
  101472. /**
  101473. * Value of 0 disables the banked Roll.
  101474. * Value of 1 is equal to the Yaw angle in radians.
  101475. */
  101476. bankedTurnMultiplier: number;
  101477. /**
  101478. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101479. */
  101480. inputs: FlyCameraInputsManager;
  101481. /**
  101482. * Gets the input sensibility for mouse input.
  101483. * Higher values reduce sensitivity.
  101484. */
  101485. /**
  101486. * Sets the input sensibility for a mouse input.
  101487. * Higher values reduce sensitivity.
  101488. */
  101489. angularSensibility: number;
  101490. /**
  101491. * Get the keys for camera movement forward.
  101492. */
  101493. /**
  101494. * Set the keys for camera movement forward.
  101495. */
  101496. keysForward: number[];
  101497. /**
  101498. * Get the keys for camera movement backward.
  101499. */
  101500. keysBackward: number[];
  101501. /**
  101502. * Get the keys for camera movement up.
  101503. */
  101504. /**
  101505. * Set the keys for camera movement up.
  101506. */
  101507. keysUp: number[];
  101508. /**
  101509. * Get the keys for camera movement down.
  101510. */
  101511. /**
  101512. * Set the keys for camera movement down.
  101513. */
  101514. keysDown: number[];
  101515. /**
  101516. * Get the keys for camera movement left.
  101517. */
  101518. /**
  101519. * Set the keys for camera movement left.
  101520. */
  101521. keysLeft: number[];
  101522. /**
  101523. * Set the keys for camera movement right.
  101524. */
  101525. /**
  101526. * Set the keys for camera movement right.
  101527. */
  101528. keysRight: number[];
  101529. /**
  101530. * Event raised when the camera collides with a mesh in the scene.
  101531. */
  101532. onCollide: (collidedMesh: AbstractMesh) => void;
  101533. private _collider;
  101534. private _needMoveForGravity;
  101535. private _oldPosition;
  101536. private _diffPosition;
  101537. private _newPosition;
  101538. /** @hidden */
  101539. _localDirection: Vector3;
  101540. /** @hidden */
  101541. _transformedDirection: Vector3;
  101542. /**
  101543. * Instantiates a FlyCamera.
  101544. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101545. * such as in a 3D Space Shooter or a Flight Simulator.
  101546. * @param name Define the name of the camera in the scene.
  101547. * @param position Define the starting position of the camera in the scene.
  101548. * @param scene Define the scene the camera belongs to.
  101549. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101550. */
  101551. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101552. /**
  101553. * Attach a control to the HTML DOM element.
  101554. * @param element Defines the element that listens to the input events.
  101555. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101556. */
  101557. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101558. /**
  101559. * Detach a control from the HTML DOM element.
  101560. * The camera will stop reacting to that input.
  101561. * @param element Defines the element that listens to the input events.
  101562. */
  101563. detachControl(element: HTMLElement): void;
  101564. private _collisionMask;
  101565. /**
  101566. * Get the mask that the camera ignores in collision events.
  101567. */
  101568. /**
  101569. * Set the mask that the camera ignores in collision events.
  101570. */
  101571. collisionMask: number;
  101572. /** @hidden */
  101573. _collideWithWorld(displacement: Vector3): void;
  101574. /** @hidden */
  101575. private _onCollisionPositionChange;
  101576. /** @hidden */
  101577. _checkInputs(): void;
  101578. /** @hidden */
  101579. _decideIfNeedsToMove(): boolean;
  101580. /** @hidden */
  101581. _updatePosition(): void;
  101582. /**
  101583. * Restore the Roll to its target value at the rate specified.
  101584. * @param rate - Higher means slower restoring.
  101585. * @hidden
  101586. */
  101587. restoreRoll(rate: number): void;
  101588. /**
  101589. * Destroy the camera and release the current resources held by it.
  101590. */
  101591. dispose(): void;
  101592. /**
  101593. * Get the current object class name.
  101594. * @returns the class name.
  101595. */
  101596. getClassName(): string;
  101597. }
  101598. }
  101599. declare module BABYLON {
  101600. /**
  101601. * Listen to keyboard events to control the camera.
  101602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101603. */
  101604. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101605. /**
  101606. * Defines the camera the input is attached to.
  101607. */
  101608. camera: FlyCamera;
  101609. /**
  101610. * The list of keyboard keys used to control the forward move of the camera.
  101611. */
  101612. keysForward: number[];
  101613. /**
  101614. * The list of keyboard keys used to control the backward move of the camera.
  101615. */
  101616. keysBackward: number[];
  101617. /**
  101618. * The list of keyboard keys used to control the forward move of the camera.
  101619. */
  101620. keysUp: number[];
  101621. /**
  101622. * The list of keyboard keys used to control the backward move of the camera.
  101623. */
  101624. keysDown: number[];
  101625. /**
  101626. * The list of keyboard keys used to control the right strafe move of the camera.
  101627. */
  101628. keysRight: number[];
  101629. /**
  101630. * The list of keyboard keys used to control the left strafe move of the camera.
  101631. */
  101632. keysLeft: number[];
  101633. private _keys;
  101634. private _onCanvasBlurObserver;
  101635. private _onKeyboardObserver;
  101636. private _engine;
  101637. private _scene;
  101638. /**
  101639. * Attach the input controls to a specific dom element to get the input from.
  101640. * @param element Defines the element the controls should be listened from
  101641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101642. */
  101643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101644. /**
  101645. * Detach the current controls from the specified dom element.
  101646. * @param element Defines the element to stop listening the inputs from
  101647. */
  101648. detachControl(element: Nullable<HTMLElement>): void;
  101649. /**
  101650. * Gets the class name of the current intput.
  101651. * @returns the class name
  101652. */
  101653. getClassName(): string;
  101654. /** @hidden */
  101655. _onLostFocus(e: FocusEvent): void;
  101656. /**
  101657. * Get the friendly name associated with the input class.
  101658. * @returns the input friendly name
  101659. */
  101660. getSimpleName(): string;
  101661. /**
  101662. * Update the current camera state depending on the inputs that have been used this frame.
  101663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101664. */
  101665. checkInputs(): void;
  101666. }
  101667. }
  101668. declare module BABYLON {
  101669. /**
  101670. * Manage the mouse wheel inputs to control a follow camera.
  101671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101672. */
  101673. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101674. /**
  101675. * Defines the camera the input is attached to.
  101676. */
  101677. camera: FollowCamera;
  101678. /**
  101679. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101680. */
  101681. axisControlRadius: boolean;
  101682. /**
  101683. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101684. */
  101685. axisControlHeight: boolean;
  101686. /**
  101687. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101688. */
  101689. axisControlRotation: boolean;
  101690. /**
  101691. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101692. * relation to mouseWheel events.
  101693. */
  101694. wheelPrecision: number;
  101695. /**
  101696. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101697. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101698. */
  101699. wheelDeltaPercentage: number;
  101700. private _wheel;
  101701. private _observer;
  101702. /**
  101703. * Attach the input controls to a specific dom element to get the input from.
  101704. * @param element Defines the element the controls should be listened from
  101705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101706. */
  101707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101708. /**
  101709. * Detach the current controls from the specified dom element.
  101710. * @param element Defines the element to stop listening the inputs from
  101711. */
  101712. detachControl(element: Nullable<HTMLElement>): void;
  101713. /**
  101714. * Gets the class name of the current intput.
  101715. * @returns the class name
  101716. */
  101717. getClassName(): string;
  101718. /**
  101719. * Get the friendly name associated with the input class.
  101720. * @returns the input friendly name
  101721. */
  101722. getSimpleName(): string;
  101723. }
  101724. }
  101725. declare module BABYLON {
  101726. /**
  101727. * Manage the pointers inputs to control an follow camera.
  101728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101729. */
  101730. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101731. /**
  101732. * Defines the camera the input is attached to.
  101733. */
  101734. camera: FollowCamera;
  101735. /**
  101736. * Gets the class name of the current input.
  101737. * @returns the class name
  101738. */
  101739. getClassName(): string;
  101740. /**
  101741. * Defines the pointer angular sensibility along the X axis or how fast is
  101742. * the camera rotating.
  101743. * A negative number will reverse the axis direction.
  101744. */
  101745. angularSensibilityX: number;
  101746. /**
  101747. * Defines the pointer angular sensibility along the Y axis or how fast is
  101748. * the camera rotating.
  101749. * A negative number will reverse the axis direction.
  101750. */
  101751. angularSensibilityY: number;
  101752. /**
  101753. * Defines the pointer pinch precision or how fast is the camera zooming.
  101754. * A negative number will reverse the axis direction.
  101755. */
  101756. pinchPrecision: number;
  101757. /**
  101758. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101759. * from 0.
  101760. * It defines the percentage of current camera.radius to use as delta when
  101761. * pinch zoom is used.
  101762. */
  101763. pinchDeltaPercentage: number;
  101764. /**
  101765. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101766. */
  101767. axisXControlRadius: boolean;
  101768. /**
  101769. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101770. */
  101771. axisXControlHeight: boolean;
  101772. /**
  101773. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101774. */
  101775. axisXControlRotation: boolean;
  101776. /**
  101777. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101778. */
  101779. axisYControlRadius: boolean;
  101780. /**
  101781. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101782. */
  101783. axisYControlHeight: boolean;
  101784. /**
  101785. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101786. */
  101787. axisYControlRotation: boolean;
  101788. /**
  101789. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101790. */
  101791. axisPinchControlRadius: boolean;
  101792. /**
  101793. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101794. */
  101795. axisPinchControlHeight: boolean;
  101796. /**
  101797. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101798. */
  101799. axisPinchControlRotation: boolean;
  101800. /**
  101801. * Log error messages if basic misconfiguration has occurred.
  101802. */
  101803. warningEnable: boolean;
  101804. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101805. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101806. private _warningCounter;
  101807. private _warning;
  101808. }
  101809. }
  101810. declare module BABYLON {
  101811. /**
  101812. * Default Inputs manager for the FollowCamera.
  101813. * It groups all the default supported inputs for ease of use.
  101814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101815. */
  101816. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101817. /**
  101818. * Instantiates a new FollowCameraInputsManager.
  101819. * @param camera Defines the camera the inputs belong to
  101820. */
  101821. constructor(camera: FollowCamera);
  101822. /**
  101823. * Add keyboard input support to the input manager.
  101824. * @returns the current input manager
  101825. */
  101826. addKeyboard(): FollowCameraInputsManager;
  101827. /**
  101828. * Add mouse wheel input support to the input manager.
  101829. * @returns the current input manager
  101830. */
  101831. addMouseWheel(): FollowCameraInputsManager;
  101832. /**
  101833. * Add pointers input support to the input manager.
  101834. * @returns the current input manager
  101835. */
  101836. addPointers(): FollowCameraInputsManager;
  101837. /**
  101838. * Add orientation input support to the input manager.
  101839. * @returns the current input manager
  101840. */
  101841. addVRDeviceOrientation(): FollowCameraInputsManager;
  101842. }
  101843. }
  101844. declare module BABYLON {
  101845. /**
  101846. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101847. * an arc rotate version arcFollowCamera are available.
  101848. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101849. */
  101850. export class FollowCamera extends TargetCamera {
  101851. /**
  101852. * Distance the follow camera should follow an object at
  101853. */
  101854. radius: number;
  101855. /**
  101856. * Minimum allowed distance of the camera to the axis of rotation
  101857. * (The camera can not get closer).
  101858. * This can help limiting how the Camera is able to move in the scene.
  101859. */
  101860. lowerRadiusLimit: Nullable<number>;
  101861. /**
  101862. * Maximum allowed distance of the camera to the axis of rotation
  101863. * (The camera can not get further).
  101864. * This can help limiting how the Camera is able to move in the scene.
  101865. */
  101866. upperRadiusLimit: Nullable<number>;
  101867. /**
  101868. * Define a rotation offset between the camera and the object it follows
  101869. */
  101870. rotationOffset: number;
  101871. /**
  101872. * Minimum allowed angle to camera position relative to target object.
  101873. * This can help limiting how the Camera is able to move in the scene.
  101874. */
  101875. lowerRotationOffsetLimit: Nullable<number>;
  101876. /**
  101877. * Maximum allowed angle to camera position relative to target object.
  101878. * This can help limiting how the Camera is able to move in the scene.
  101879. */
  101880. upperRotationOffsetLimit: Nullable<number>;
  101881. /**
  101882. * Define a height offset between the camera and the object it follows.
  101883. * It can help following an object from the top (like a car chaing a plane)
  101884. */
  101885. heightOffset: number;
  101886. /**
  101887. * Minimum allowed height of camera position relative to target object.
  101888. * This can help limiting how the Camera is able to move in the scene.
  101889. */
  101890. lowerHeightOffsetLimit: Nullable<number>;
  101891. /**
  101892. * Maximum allowed height of camera position relative to target object.
  101893. * This can help limiting how the Camera is able to move in the scene.
  101894. */
  101895. upperHeightOffsetLimit: Nullable<number>;
  101896. /**
  101897. * Define how fast the camera can accelerate to follow it s target.
  101898. */
  101899. cameraAcceleration: number;
  101900. /**
  101901. * Define the speed limit of the camera following an object.
  101902. */
  101903. maxCameraSpeed: number;
  101904. /**
  101905. * Define the target of the camera.
  101906. */
  101907. lockedTarget: Nullable<AbstractMesh>;
  101908. /**
  101909. * Defines the input associated with the camera.
  101910. */
  101911. inputs: FollowCameraInputsManager;
  101912. /**
  101913. * Instantiates the follow camera.
  101914. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101915. * @param name Define the name of the camera in the scene
  101916. * @param position Define the position of the camera
  101917. * @param scene Define the scene the camera belong to
  101918. * @param lockedTarget Define the target of the camera
  101919. */
  101920. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101921. private _follow;
  101922. /**
  101923. * Attached controls to the current camera.
  101924. * @param element Defines the element the controls should be listened from
  101925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101926. */
  101927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101928. /**
  101929. * Detach the current controls from the camera.
  101930. * The camera will stop reacting to inputs.
  101931. * @param element Defines the element to stop listening the inputs from
  101932. */
  101933. detachControl(element: HTMLElement): void;
  101934. /** @hidden */
  101935. _checkInputs(): void;
  101936. private _checkLimits;
  101937. /**
  101938. * Gets the camera class name.
  101939. * @returns the class name
  101940. */
  101941. getClassName(): string;
  101942. }
  101943. /**
  101944. * Arc Rotate version of the follow camera.
  101945. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101946. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101947. */
  101948. export class ArcFollowCamera extends TargetCamera {
  101949. /** The longitudinal angle of the camera */
  101950. alpha: number;
  101951. /** The latitudinal angle of the camera */
  101952. beta: number;
  101953. /** The radius of the camera from its target */
  101954. radius: number;
  101955. /** Define the camera target (the messh it should follow) */
  101956. target: Nullable<AbstractMesh>;
  101957. private _cartesianCoordinates;
  101958. /**
  101959. * Instantiates a new ArcFollowCamera
  101960. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101961. * @param name Define the name of the camera
  101962. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101963. * @param beta Define the rotation angle of the camera around the elevation axis
  101964. * @param radius Define the radius of the camera from its target point
  101965. * @param target Define the target of the camera
  101966. * @param scene Define the scene the camera belongs to
  101967. */
  101968. constructor(name: string,
  101969. /** The longitudinal angle of the camera */
  101970. alpha: number,
  101971. /** The latitudinal angle of the camera */
  101972. beta: number,
  101973. /** The radius of the camera from its target */
  101974. radius: number,
  101975. /** Define the camera target (the messh it should follow) */
  101976. target: Nullable<AbstractMesh>, scene: Scene);
  101977. private _follow;
  101978. /** @hidden */
  101979. _checkInputs(): void;
  101980. /**
  101981. * Returns the class name of the object.
  101982. * It is mostly used internally for serialization purposes.
  101983. */
  101984. getClassName(): string;
  101985. }
  101986. }
  101987. declare module BABYLON {
  101988. /**
  101989. * Manage the keyboard inputs to control the movement of a follow camera.
  101990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101991. */
  101992. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101993. /**
  101994. * Defines the camera the input is attached to.
  101995. */
  101996. camera: FollowCamera;
  101997. /**
  101998. * Defines the list of key codes associated with the up action (increase heightOffset)
  101999. */
  102000. keysHeightOffsetIncr: number[];
  102001. /**
  102002. * Defines the list of key codes associated with the down action (decrease heightOffset)
  102003. */
  102004. keysHeightOffsetDecr: number[];
  102005. /**
  102006. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  102007. */
  102008. keysHeightOffsetModifierAlt: boolean;
  102009. /**
  102010. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  102011. */
  102012. keysHeightOffsetModifierCtrl: boolean;
  102013. /**
  102014. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  102015. */
  102016. keysHeightOffsetModifierShift: boolean;
  102017. /**
  102018. * Defines the list of key codes associated with the left action (increase rotationOffset)
  102019. */
  102020. keysRotationOffsetIncr: number[];
  102021. /**
  102022. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  102023. */
  102024. keysRotationOffsetDecr: number[];
  102025. /**
  102026. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  102027. */
  102028. keysRotationOffsetModifierAlt: boolean;
  102029. /**
  102030. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  102031. */
  102032. keysRotationOffsetModifierCtrl: boolean;
  102033. /**
  102034. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  102035. */
  102036. keysRotationOffsetModifierShift: boolean;
  102037. /**
  102038. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  102039. */
  102040. keysRadiusIncr: number[];
  102041. /**
  102042. * Defines the list of key codes associated with the zoom-out action (increase radius)
  102043. */
  102044. keysRadiusDecr: number[];
  102045. /**
  102046. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  102047. */
  102048. keysRadiusModifierAlt: boolean;
  102049. /**
  102050. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  102051. */
  102052. keysRadiusModifierCtrl: boolean;
  102053. /**
  102054. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  102055. */
  102056. keysRadiusModifierShift: boolean;
  102057. /**
  102058. * Defines the rate of change of heightOffset.
  102059. */
  102060. heightSensibility: number;
  102061. /**
  102062. * Defines the rate of change of rotationOffset.
  102063. */
  102064. rotationSensibility: number;
  102065. /**
  102066. * Defines the rate of change of radius.
  102067. */
  102068. radiusSensibility: number;
  102069. private _keys;
  102070. private _ctrlPressed;
  102071. private _altPressed;
  102072. private _shiftPressed;
  102073. private _onCanvasBlurObserver;
  102074. private _onKeyboardObserver;
  102075. private _engine;
  102076. private _scene;
  102077. /**
  102078. * Attach the input controls to a specific dom element to get the input from.
  102079. * @param element Defines the element the controls should be listened from
  102080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102081. */
  102082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102083. /**
  102084. * Detach the current controls from the specified dom element.
  102085. * @param element Defines the element to stop listening the inputs from
  102086. */
  102087. detachControl(element: Nullable<HTMLElement>): void;
  102088. /**
  102089. * Update the current camera state depending on the inputs that have been used this frame.
  102090. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102091. */
  102092. checkInputs(): void;
  102093. /**
  102094. * Gets the class name of the current input.
  102095. * @returns the class name
  102096. */
  102097. getClassName(): string;
  102098. /**
  102099. * Get the friendly name associated with the input class.
  102100. * @returns the input friendly name
  102101. */
  102102. getSimpleName(): string;
  102103. /**
  102104. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102105. * allow modification of the heightOffset value.
  102106. */
  102107. private _modifierHeightOffset;
  102108. /**
  102109. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102110. * allow modification of the rotationOffset value.
  102111. */
  102112. private _modifierRotationOffset;
  102113. /**
  102114. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  102115. * allow modification of the radius value.
  102116. */
  102117. private _modifierRadius;
  102118. }
  102119. }
  102120. declare module BABYLON {
  102121. interface FreeCameraInputsManager {
  102122. /**
  102123. * @hidden
  102124. */
  102125. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  102126. /**
  102127. * Add orientation input support to the input manager.
  102128. * @returns the current input manager
  102129. */
  102130. addDeviceOrientation(): FreeCameraInputsManager;
  102131. }
  102132. /**
  102133. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  102134. * Screen rotation is taken into account.
  102135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102136. */
  102137. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  102138. private _camera;
  102139. private _screenOrientationAngle;
  102140. private _constantTranform;
  102141. private _screenQuaternion;
  102142. private _alpha;
  102143. private _beta;
  102144. private _gamma;
  102145. /**
  102146. * Can be used to detect if a device orientation sensor is availible on a device
  102147. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  102148. * @returns a promise that will resolve on orientation change
  102149. */
  102150. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  102151. /**
  102152. * @hidden
  102153. */
  102154. _onDeviceOrientationChangedObservable: Observable<void>;
  102155. /**
  102156. * Instantiates a new input
  102157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102158. */
  102159. constructor();
  102160. /**
  102161. * Define the camera controlled by the input.
  102162. */
  102163. camera: FreeCamera;
  102164. /**
  102165. * Attach the input controls to a specific dom element to get the input from.
  102166. * @param element Defines the element the controls should be listened from
  102167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102168. */
  102169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102170. private _orientationChanged;
  102171. private _deviceOrientation;
  102172. /**
  102173. * Detach the current controls from the specified dom element.
  102174. * @param element Defines the element to stop listening the inputs from
  102175. */
  102176. detachControl(element: Nullable<HTMLElement>): void;
  102177. /**
  102178. * Update the current camera state depending on the inputs that have been used this frame.
  102179. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102180. */
  102181. checkInputs(): void;
  102182. /**
  102183. * Gets the class name of the current intput.
  102184. * @returns the class name
  102185. */
  102186. getClassName(): string;
  102187. /**
  102188. * Get the friendly name associated with the input class.
  102189. * @returns the input friendly name
  102190. */
  102191. getSimpleName(): string;
  102192. }
  102193. }
  102194. declare module BABYLON {
  102195. /**
  102196. * Manage the gamepad inputs to control a free camera.
  102197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102198. */
  102199. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  102200. /**
  102201. * Define the camera the input is attached to.
  102202. */
  102203. camera: FreeCamera;
  102204. /**
  102205. * Define the Gamepad controlling the input
  102206. */
  102207. gamepad: Nullable<Gamepad>;
  102208. /**
  102209. * Defines the gamepad rotation sensiblity.
  102210. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102211. */
  102212. gamepadAngularSensibility: number;
  102213. /**
  102214. * Defines the gamepad move sensiblity.
  102215. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102216. */
  102217. gamepadMoveSensibility: number;
  102218. private _onGamepadConnectedObserver;
  102219. private _onGamepadDisconnectedObserver;
  102220. private _cameraTransform;
  102221. private _deltaTransform;
  102222. private _vector3;
  102223. private _vector2;
  102224. /**
  102225. * Attach the input controls to a specific dom element to get the input from.
  102226. * @param element Defines the element the controls should be listened from
  102227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102228. */
  102229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102230. /**
  102231. * Detach the current controls from the specified dom element.
  102232. * @param element Defines the element to stop listening the inputs from
  102233. */
  102234. detachControl(element: Nullable<HTMLElement>): void;
  102235. /**
  102236. * Update the current camera state depending on the inputs that have been used this frame.
  102237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102238. */
  102239. checkInputs(): void;
  102240. /**
  102241. * Gets the class name of the current intput.
  102242. * @returns the class name
  102243. */
  102244. getClassName(): string;
  102245. /**
  102246. * Get the friendly name associated with the input class.
  102247. * @returns the input friendly name
  102248. */
  102249. getSimpleName(): string;
  102250. }
  102251. }
  102252. declare module BABYLON {
  102253. /**
  102254. * Defines the potential axis of a Joystick
  102255. */
  102256. export enum JoystickAxis {
  102257. /** X axis */
  102258. X = 0,
  102259. /** Y axis */
  102260. Y = 1,
  102261. /** Z axis */
  102262. Z = 2
  102263. }
  102264. /**
  102265. * Class used to define virtual joystick (used in touch mode)
  102266. */
  102267. export class VirtualJoystick {
  102268. /**
  102269. * Gets or sets a boolean indicating that left and right values must be inverted
  102270. */
  102271. reverseLeftRight: boolean;
  102272. /**
  102273. * Gets or sets a boolean indicating that up and down values must be inverted
  102274. */
  102275. reverseUpDown: boolean;
  102276. /**
  102277. * Gets the offset value for the position (ie. the change of the position value)
  102278. */
  102279. deltaPosition: Vector3;
  102280. /**
  102281. * Gets a boolean indicating if the virtual joystick was pressed
  102282. */
  102283. pressed: boolean;
  102284. /**
  102285. * Canvas the virtual joystick will render onto, default z-index of this is 5
  102286. */
  102287. static Canvas: Nullable<HTMLCanvasElement>;
  102288. private static _globalJoystickIndex;
  102289. private static vjCanvasContext;
  102290. private static vjCanvasWidth;
  102291. private static vjCanvasHeight;
  102292. private static halfWidth;
  102293. private _action;
  102294. private _axisTargetedByLeftAndRight;
  102295. private _axisTargetedByUpAndDown;
  102296. private _joystickSensibility;
  102297. private _inversedSensibility;
  102298. private _joystickPointerID;
  102299. private _joystickColor;
  102300. private _joystickPointerPos;
  102301. private _joystickPreviousPointerPos;
  102302. private _joystickPointerStartPos;
  102303. private _deltaJoystickVector;
  102304. private _leftJoystick;
  102305. private _touches;
  102306. private _onPointerDownHandlerRef;
  102307. private _onPointerMoveHandlerRef;
  102308. private _onPointerUpHandlerRef;
  102309. private _onResize;
  102310. /**
  102311. * Creates a new virtual joystick
  102312. * @param leftJoystick defines that the joystick is for left hand (false by default)
  102313. */
  102314. constructor(leftJoystick?: boolean);
  102315. /**
  102316. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  102317. * @param newJoystickSensibility defines the new sensibility
  102318. */
  102319. setJoystickSensibility(newJoystickSensibility: number): void;
  102320. private _onPointerDown;
  102321. private _onPointerMove;
  102322. private _onPointerUp;
  102323. /**
  102324. * Change the color of the virtual joystick
  102325. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  102326. */
  102327. setJoystickColor(newColor: string): void;
  102328. /**
  102329. * Defines a callback to call when the joystick is touched
  102330. * @param action defines the callback
  102331. */
  102332. setActionOnTouch(action: () => any): void;
  102333. /**
  102334. * Defines which axis you'd like to control for left & right
  102335. * @param axis defines the axis to use
  102336. */
  102337. setAxisForLeftRight(axis: JoystickAxis): void;
  102338. /**
  102339. * Defines which axis you'd like to control for up & down
  102340. * @param axis defines the axis to use
  102341. */
  102342. setAxisForUpDown(axis: JoystickAxis): void;
  102343. private _drawVirtualJoystick;
  102344. /**
  102345. * Release internal HTML canvas
  102346. */
  102347. releaseCanvas(): void;
  102348. }
  102349. }
  102350. declare module BABYLON {
  102351. interface FreeCameraInputsManager {
  102352. /**
  102353. * Add virtual joystick input support to the input manager.
  102354. * @returns the current input manager
  102355. */
  102356. addVirtualJoystick(): FreeCameraInputsManager;
  102357. }
  102358. /**
  102359. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  102360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102361. */
  102362. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  102363. /**
  102364. * Defines the camera the input is attached to.
  102365. */
  102366. camera: FreeCamera;
  102367. private _leftjoystick;
  102368. private _rightjoystick;
  102369. /**
  102370. * Gets the left stick of the virtual joystick.
  102371. * @returns The virtual Joystick
  102372. */
  102373. getLeftJoystick(): VirtualJoystick;
  102374. /**
  102375. * Gets the right stick of the virtual joystick.
  102376. * @returns The virtual Joystick
  102377. */
  102378. getRightJoystick(): VirtualJoystick;
  102379. /**
  102380. * Update the current camera state depending on the inputs that have been used this frame.
  102381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102382. */
  102383. checkInputs(): void;
  102384. /**
  102385. * Attach the input controls to a specific dom element to get the input from.
  102386. * @param element Defines the element the controls should be listened from
  102387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102388. */
  102389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102390. /**
  102391. * Detach the current controls from the specified dom element.
  102392. * @param element Defines the element to stop listening the inputs from
  102393. */
  102394. detachControl(element: Nullable<HTMLElement>): void;
  102395. /**
  102396. * Gets the class name of the current intput.
  102397. * @returns the class name
  102398. */
  102399. getClassName(): string;
  102400. /**
  102401. * Get the friendly name associated with the input class.
  102402. * @returns the input friendly name
  102403. */
  102404. getSimpleName(): string;
  102405. }
  102406. }
  102407. declare module BABYLON {
  102408. /**
  102409. * This represents a FPS type of camera controlled by touch.
  102410. * This is like a universal camera minus the Gamepad controls.
  102411. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102412. */
  102413. export class TouchCamera extends FreeCamera {
  102414. /**
  102415. * Defines the touch sensibility for rotation.
  102416. * The higher the faster.
  102417. */
  102418. touchAngularSensibility: number;
  102419. /**
  102420. * Defines the touch sensibility for move.
  102421. * The higher the faster.
  102422. */
  102423. touchMoveSensibility: number;
  102424. /**
  102425. * Instantiates a new touch camera.
  102426. * This represents a FPS type of camera controlled by touch.
  102427. * This is like a universal camera minus the Gamepad controls.
  102428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102429. * @param name Define the name of the camera in the scene
  102430. * @param position Define the start position of the camera in the scene
  102431. * @param scene Define the scene the camera belongs to
  102432. */
  102433. constructor(name: string, position: Vector3, scene: Scene);
  102434. /**
  102435. * Gets the current object class name.
  102436. * @return the class name
  102437. */
  102438. getClassName(): string;
  102439. /** @hidden */
  102440. _setupInputs(): void;
  102441. }
  102442. }
  102443. declare module BABYLON {
  102444. /**
  102445. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102446. * being tilted forward or back and left or right.
  102447. */
  102448. export class DeviceOrientationCamera extends FreeCamera {
  102449. private _initialQuaternion;
  102450. private _quaternionCache;
  102451. private _tmpDragQuaternion;
  102452. /**
  102453. * Creates a new device orientation camera
  102454. * @param name The name of the camera
  102455. * @param position The start position camera
  102456. * @param scene The scene the camera belongs to
  102457. */
  102458. constructor(name: string, position: Vector3, scene: Scene);
  102459. /**
  102460. * @hidden
  102461. * Disabled pointer input on first orientation sensor update (Default: true)
  102462. */
  102463. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  102464. private _dragFactor;
  102465. /**
  102466. * Enabled turning on the y axis when the orientation sensor is active
  102467. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102468. */
  102469. enableHorizontalDragging(dragFactor?: number): void;
  102470. /**
  102471. * Gets the current instance class name ("DeviceOrientationCamera").
  102472. * This helps avoiding instanceof at run time.
  102473. * @returns the class name
  102474. */
  102475. getClassName(): string;
  102476. /**
  102477. * @hidden
  102478. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102479. */
  102480. _checkInputs(): void;
  102481. /**
  102482. * Reset the camera to its default orientation on the specified axis only.
  102483. * @param axis The axis to reset
  102484. */
  102485. resetToCurrentRotation(axis?: Axis): void;
  102486. }
  102487. }
  102488. declare module BABYLON {
  102489. /**
  102490. * Defines supported buttons for XBox360 compatible gamepads
  102491. */
  102492. export enum Xbox360Button {
  102493. /** A */
  102494. A = 0,
  102495. /** B */
  102496. B = 1,
  102497. /** X */
  102498. X = 2,
  102499. /** Y */
  102500. Y = 3,
  102501. /** Start */
  102502. Start = 4,
  102503. /** Back */
  102504. Back = 5,
  102505. /** Left button */
  102506. LB = 6,
  102507. /** Right button */
  102508. RB = 7,
  102509. /** Left stick */
  102510. LeftStick = 8,
  102511. /** Right stick */
  102512. RightStick = 9
  102513. }
  102514. /** Defines values for XBox360 DPad */
  102515. export enum Xbox360Dpad {
  102516. /** Up */
  102517. Up = 0,
  102518. /** Down */
  102519. Down = 1,
  102520. /** Left */
  102521. Left = 2,
  102522. /** Right */
  102523. Right = 3
  102524. }
  102525. /**
  102526. * Defines a XBox360 gamepad
  102527. */
  102528. export class Xbox360Pad extends Gamepad {
  102529. private _leftTrigger;
  102530. private _rightTrigger;
  102531. private _onlefttriggerchanged;
  102532. private _onrighttriggerchanged;
  102533. private _onbuttondown;
  102534. private _onbuttonup;
  102535. private _ondpaddown;
  102536. private _ondpadup;
  102537. /** Observable raised when a button is pressed */
  102538. onButtonDownObservable: Observable<Xbox360Button>;
  102539. /** Observable raised when a button is released */
  102540. onButtonUpObservable: Observable<Xbox360Button>;
  102541. /** Observable raised when a pad is pressed */
  102542. onPadDownObservable: Observable<Xbox360Dpad>;
  102543. /** Observable raised when a pad is released */
  102544. onPadUpObservable: Observable<Xbox360Dpad>;
  102545. private _buttonA;
  102546. private _buttonB;
  102547. private _buttonX;
  102548. private _buttonY;
  102549. private _buttonBack;
  102550. private _buttonStart;
  102551. private _buttonLB;
  102552. private _buttonRB;
  102553. private _buttonLeftStick;
  102554. private _buttonRightStick;
  102555. private _dPadUp;
  102556. private _dPadDown;
  102557. private _dPadLeft;
  102558. private _dPadRight;
  102559. private _isXboxOnePad;
  102560. /**
  102561. * Creates a new XBox360 gamepad object
  102562. * @param id defines the id of this gamepad
  102563. * @param index defines its index
  102564. * @param gamepad defines the internal HTML gamepad object
  102565. * @param xboxOne defines if it is a XBox One gamepad
  102566. */
  102567. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102568. /**
  102569. * Defines the callback to call when left trigger is pressed
  102570. * @param callback defines the callback to use
  102571. */
  102572. onlefttriggerchanged(callback: (value: number) => void): void;
  102573. /**
  102574. * Defines the callback to call when right trigger is pressed
  102575. * @param callback defines the callback to use
  102576. */
  102577. onrighttriggerchanged(callback: (value: number) => void): void;
  102578. /**
  102579. * Gets the left trigger value
  102580. */
  102581. /**
  102582. * Sets the left trigger value
  102583. */
  102584. leftTrigger: number;
  102585. /**
  102586. * Gets the right trigger value
  102587. */
  102588. /**
  102589. * Sets the right trigger value
  102590. */
  102591. rightTrigger: number;
  102592. /**
  102593. * Defines the callback to call when a button is pressed
  102594. * @param callback defines the callback to use
  102595. */
  102596. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102597. /**
  102598. * Defines the callback to call when a button is released
  102599. * @param callback defines the callback to use
  102600. */
  102601. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102602. /**
  102603. * Defines the callback to call when a pad is pressed
  102604. * @param callback defines the callback to use
  102605. */
  102606. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102607. /**
  102608. * Defines the callback to call when a pad is released
  102609. * @param callback defines the callback to use
  102610. */
  102611. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102612. private _setButtonValue;
  102613. private _setDPadValue;
  102614. /**
  102615. * Gets the value of the `A` button
  102616. */
  102617. /**
  102618. * Sets the value of the `A` button
  102619. */
  102620. buttonA: number;
  102621. /**
  102622. * Gets the value of the `B` button
  102623. */
  102624. /**
  102625. * Sets the value of the `B` button
  102626. */
  102627. buttonB: number;
  102628. /**
  102629. * Gets the value of the `X` button
  102630. */
  102631. /**
  102632. * Sets the value of the `X` button
  102633. */
  102634. buttonX: number;
  102635. /**
  102636. * Gets the value of the `Y` button
  102637. */
  102638. /**
  102639. * Sets the value of the `Y` button
  102640. */
  102641. buttonY: number;
  102642. /**
  102643. * Gets the value of the `Start` button
  102644. */
  102645. /**
  102646. * Sets the value of the `Start` button
  102647. */
  102648. buttonStart: number;
  102649. /**
  102650. * Gets the value of the `Back` button
  102651. */
  102652. /**
  102653. * Sets the value of the `Back` button
  102654. */
  102655. buttonBack: number;
  102656. /**
  102657. * Gets the value of the `Left` button
  102658. */
  102659. /**
  102660. * Sets the value of the `Left` button
  102661. */
  102662. buttonLB: number;
  102663. /**
  102664. * Gets the value of the `Right` button
  102665. */
  102666. /**
  102667. * Sets the value of the `Right` button
  102668. */
  102669. buttonRB: number;
  102670. /**
  102671. * Gets the value of the Left joystick
  102672. */
  102673. /**
  102674. * Sets the value of the Left joystick
  102675. */
  102676. buttonLeftStick: number;
  102677. /**
  102678. * Gets the value of the Right joystick
  102679. */
  102680. /**
  102681. * Sets the value of the Right joystick
  102682. */
  102683. buttonRightStick: number;
  102684. /**
  102685. * Gets the value of D-pad up
  102686. */
  102687. /**
  102688. * Sets the value of D-pad up
  102689. */
  102690. dPadUp: number;
  102691. /**
  102692. * Gets the value of D-pad down
  102693. */
  102694. /**
  102695. * Sets the value of D-pad down
  102696. */
  102697. dPadDown: number;
  102698. /**
  102699. * Gets the value of D-pad left
  102700. */
  102701. /**
  102702. * Sets the value of D-pad left
  102703. */
  102704. dPadLeft: number;
  102705. /**
  102706. * Gets the value of D-pad right
  102707. */
  102708. /**
  102709. * Sets the value of D-pad right
  102710. */
  102711. dPadRight: number;
  102712. /**
  102713. * Force the gamepad to synchronize with device values
  102714. */
  102715. update(): void;
  102716. /**
  102717. * Disposes the gamepad
  102718. */
  102719. dispose(): void;
  102720. }
  102721. }
  102722. declare module BABYLON {
  102723. /**
  102724. * Defines supported buttons for DualShock compatible gamepads
  102725. */
  102726. export enum DualShockButton {
  102727. /** Cross */
  102728. Cross = 0,
  102729. /** Circle */
  102730. Circle = 1,
  102731. /** Square */
  102732. Square = 2,
  102733. /** Triangle */
  102734. Triangle = 3,
  102735. /** Options */
  102736. Options = 4,
  102737. /** Share */
  102738. Share = 5,
  102739. /** L1 */
  102740. L1 = 6,
  102741. /** R1 */
  102742. R1 = 7,
  102743. /** Left stick */
  102744. LeftStick = 8,
  102745. /** Right stick */
  102746. RightStick = 9
  102747. }
  102748. /** Defines values for DualShock DPad */
  102749. export enum DualShockDpad {
  102750. /** Up */
  102751. Up = 0,
  102752. /** Down */
  102753. Down = 1,
  102754. /** Left */
  102755. Left = 2,
  102756. /** Right */
  102757. Right = 3
  102758. }
  102759. /**
  102760. * Defines a DualShock gamepad
  102761. */
  102762. export class DualShockPad extends Gamepad {
  102763. private _leftTrigger;
  102764. private _rightTrigger;
  102765. private _onlefttriggerchanged;
  102766. private _onrighttriggerchanged;
  102767. private _onbuttondown;
  102768. private _onbuttonup;
  102769. private _ondpaddown;
  102770. private _ondpadup;
  102771. /** Observable raised when a button is pressed */
  102772. onButtonDownObservable: Observable<DualShockButton>;
  102773. /** Observable raised when a button is released */
  102774. onButtonUpObservable: Observable<DualShockButton>;
  102775. /** Observable raised when a pad is pressed */
  102776. onPadDownObservable: Observable<DualShockDpad>;
  102777. /** Observable raised when a pad is released */
  102778. onPadUpObservable: Observable<DualShockDpad>;
  102779. private _buttonCross;
  102780. private _buttonCircle;
  102781. private _buttonSquare;
  102782. private _buttonTriangle;
  102783. private _buttonShare;
  102784. private _buttonOptions;
  102785. private _buttonL1;
  102786. private _buttonR1;
  102787. private _buttonLeftStick;
  102788. private _buttonRightStick;
  102789. private _dPadUp;
  102790. private _dPadDown;
  102791. private _dPadLeft;
  102792. private _dPadRight;
  102793. /**
  102794. * Creates a new DualShock gamepad object
  102795. * @param id defines the id of this gamepad
  102796. * @param index defines its index
  102797. * @param gamepad defines the internal HTML gamepad object
  102798. */
  102799. constructor(id: string, index: number, gamepad: any);
  102800. /**
  102801. * Defines the callback to call when left trigger is pressed
  102802. * @param callback defines the callback to use
  102803. */
  102804. onlefttriggerchanged(callback: (value: number) => void): void;
  102805. /**
  102806. * Defines the callback to call when right trigger is pressed
  102807. * @param callback defines the callback to use
  102808. */
  102809. onrighttriggerchanged(callback: (value: number) => void): void;
  102810. /**
  102811. * Gets the left trigger value
  102812. */
  102813. /**
  102814. * Sets the left trigger value
  102815. */
  102816. leftTrigger: number;
  102817. /**
  102818. * Gets the right trigger value
  102819. */
  102820. /**
  102821. * Sets the right trigger value
  102822. */
  102823. rightTrigger: number;
  102824. /**
  102825. * Defines the callback to call when a button is pressed
  102826. * @param callback defines the callback to use
  102827. */
  102828. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  102829. /**
  102830. * Defines the callback to call when a button is released
  102831. * @param callback defines the callback to use
  102832. */
  102833. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  102834. /**
  102835. * Defines the callback to call when a pad is pressed
  102836. * @param callback defines the callback to use
  102837. */
  102838. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  102839. /**
  102840. * Defines the callback to call when a pad is released
  102841. * @param callback defines the callback to use
  102842. */
  102843. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  102844. private _setButtonValue;
  102845. private _setDPadValue;
  102846. /**
  102847. * Gets the value of the `Cross` button
  102848. */
  102849. /**
  102850. * Sets the value of the `Cross` button
  102851. */
  102852. buttonCross: number;
  102853. /**
  102854. * Gets the value of the `Circle` button
  102855. */
  102856. /**
  102857. * Sets the value of the `Circle` button
  102858. */
  102859. buttonCircle: number;
  102860. /**
  102861. * Gets the value of the `Square` button
  102862. */
  102863. /**
  102864. * Sets the value of the `Square` button
  102865. */
  102866. buttonSquare: number;
  102867. /**
  102868. * Gets the value of the `Triangle` button
  102869. */
  102870. /**
  102871. * Sets the value of the `Triangle` button
  102872. */
  102873. buttonTriangle: number;
  102874. /**
  102875. * Gets the value of the `Options` button
  102876. */
  102877. /**
  102878. * Sets the value of the `Options` button
  102879. */
  102880. buttonOptions: number;
  102881. /**
  102882. * Gets the value of the `Share` button
  102883. */
  102884. /**
  102885. * Sets the value of the `Share` button
  102886. */
  102887. buttonShare: number;
  102888. /**
  102889. * Gets the value of the `L1` button
  102890. */
  102891. /**
  102892. * Sets the value of the `L1` button
  102893. */
  102894. buttonL1: number;
  102895. /**
  102896. * Gets the value of the `R1` button
  102897. */
  102898. /**
  102899. * Sets the value of the `R1` button
  102900. */
  102901. buttonR1: number;
  102902. /**
  102903. * Gets the value of the Left joystick
  102904. */
  102905. /**
  102906. * Sets the value of the Left joystick
  102907. */
  102908. buttonLeftStick: number;
  102909. /**
  102910. * Gets the value of the Right joystick
  102911. */
  102912. /**
  102913. * Sets the value of the Right joystick
  102914. */
  102915. buttonRightStick: number;
  102916. /**
  102917. * Gets the value of D-pad up
  102918. */
  102919. /**
  102920. * Sets the value of D-pad up
  102921. */
  102922. dPadUp: number;
  102923. /**
  102924. * Gets the value of D-pad down
  102925. */
  102926. /**
  102927. * Sets the value of D-pad down
  102928. */
  102929. dPadDown: number;
  102930. /**
  102931. * Gets the value of D-pad left
  102932. */
  102933. /**
  102934. * Sets the value of D-pad left
  102935. */
  102936. dPadLeft: number;
  102937. /**
  102938. * Gets the value of D-pad right
  102939. */
  102940. /**
  102941. * Sets the value of D-pad right
  102942. */
  102943. dPadRight: number;
  102944. /**
  102945. * Force the gamepad to synchronize with device values
  102946. */
  102947. update(): void;
  102948. /**
  102949. * Disposes the gamepad
  102950. */
  102951. dispose(): void;
  102952. }
  102953. }
  102954. declare module BABYLON {
  102955. /**
  102956. * Manager for handling gamepads
  102957. */
  102958. export class GamepadManager {
  102959. private _scene?;
  102960. private _babylonGamepads;
  102961. private _oneGamepadConnected;
  102962. /** @hidden */
  102963. _isMonitoring: boolean;
  102964. private _gamepadEventSupported;
  102965. private _gamepadSupport;
  102966. /**
  102967. * observable to be triggered when the gamepad controller has been connected
  102968. */
  102969. onGamepadConnectedObservable: Observable<Gamepad>;
  102970. /**
  102971. * observable to be triggered when the gamepad controller has been disconnected
  102972. */
  102973. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102974. private _onGamepadConnectedEvent;
  102975. private _onGamepadDisconnectedEvent;
  102976. /**
  102977. * Initializes the gamepad manager
  102978. * @param _scene BabylonJS scene
  102979. */
  102980. constructor(_scene?: Scene | undefined);
  102981. /**
  102982. * The gamepads in the game pad manager
  102983. */
  102984. readonly gamepads: Gamepad[];
  102985. /**
  102986. * Get the gamepad controllers based on type
  102987. * @param type The type of gamepad controller
  102988. * @returns Nullable gamepad
  102989. */
  102990. getGamepadByType(type?: number): Nullable<Gamepad>;
  102991. /**
  102992. * Disposes the gamepad manager
  102993. */
  102994. dispose(): void;
  102995. private _addNewGamepad;
  102996. private _startMonitoringGamepads;
  102997. private _stopMonitoringGamepads;
  102998. /** @hidden */
  102999. _checkGamepadsStatus(): void;
  103000. private _updateGamepadObjects;
  103001. }
  103002. }
  103003. declare module BABYLON {
  103004. interface Scene {
  103005. /** @hidden */
  103006. _gamepadManager: Nullable<GamepadManager>;
  103007. /**
  103008. * Gets the gamepad manager associated with the scene
  103009. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  103010. */
  103011. gamepadManager: GamepadManager;
  103012. }
  103013. /**
  103014. * Interface representing a free camera inputs manager
  103015. */
  103016. interface FreeCameraInputsManager {
  103017. /**
  103018. * Adds gamepad input support to the FreeCameraInputsManager.
  103019. * @returns the FreeCameraInputsManager
  103020. */
  103021. addGamepad(): FreeCameraInputsManager;
  103022. }
  103023. /**
  103024. * Interface representing an arc rotate camera inputs manager
  103025. */
  103026. interface ArcRotateCameraInputsManager {
  103027. /**
  103028. * Adds gamepad input support to the ArcRotateCamera InputManager.
  103029. * @returns the camera inputs manager
  103030. */
  103031. addGamepad(): ArcRotateCameraInputsManager;
  103032. }
  103033. /**
  103034. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  103035. */
  103036. export class GamepadSystemSceneComponent implements ISceneComponent {
  103037. /**
  103038. * The component name helpfull to identify the component in the list of scene components.
  103039. */
  103040. readonly name: string;
  103041. /**
  103042. * The scene the component belongs to.
  103043. */
  103044. scene: Scene;
  103045. /**
  103046. * Creates a new instance of the component for the given scene
  103047. * @param scene Defines the scene to register the component in
  103048. */
  103049. constructor(scene: Scene);
  103050. /**
  103051. * Registers the component in a given scene
  103052. */
  103053. register(): void;
  103054. /**
  103055. * Rebuilds the elements related to this component in case of
  103056. * context lost for instance.
  103057. */
  103058. rebuild(): void;
  103059. /**
  103060. * Disposes the component and the associated ressources
  103061. */
  103062. dispose(): void;
  103063. private _beforeCameraUpdate;
  103064. }
  103065. }
  103066. declare module BABYLON {
  103067. /**
  103068. * 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,
  103069. * which still works and will still be found in many Playgrounds.
  103070. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103071. */
  103072. export class UniversalCamera extends TouchCamera {
  103073. /**
  103074. * Defines the gamepad rotation sensiblity.
  103075. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103076. */
  103077. gamepadAngularSensibility: number;
  103078. /**
  103079. * Defines the gamepad move sensiblity.
  103080. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103081. */
  103082. gamepadMoveSensibility: number;
  103083. /**
  103084. * 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,
  103085. * which still works and will still be found in many Playgrounds.
  103086. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103087. * @param name Define the name of the camera in the scene
  103088. * @param position Define the start position of the camera in the scene
  103089. * @param scene Define the scene the camera belongs to
  103090. */
  103091. constructor(name: string, position: Vector3, scene: Scene);
  103092. /**
  103093. * Gets the current object class name.
  103094. * @return the class name
  103095. */
  103096. getClassName(): string;
  103097. }
  103098. }
  103099. declare module BABYLON {
  103100. /**
  103101. * This represents a FPS type of camera. This is only here for back compat purpose.
  103102. * Please use the UniversalCamera instead as both are identical.
  103103. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103104. */
  103105. export class GamepadCamera extends UniversalCamera {
  103106. /**
  103107. * Instantiates a new Gamepad Camera
  103108. * This represents a FPS type of camera. This is only here for back compat purpose.
  103109. * Please use the UniversalCamera instead as both are identical.
  103110. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  103111. * @param name Define the name of the camera in the scene
  103112. * @param position Define the start position of the camera in the scene
  103113. * @param scene Define the scene the camera belongs to
  103114. */
  103115. constructor(name: string, position: Vector3, scene: Scene);
  103116. /**
  103117. * Gets the current object class name.
  103118. * @return the class name
  103119. */
  103120. getClassName(): string;
  103121. }
  103122. }
  103123. declare module BABYLON {
  103124. /** @hidden */
  103125. export var passPixelShader: {
  103126. name: string;
  103127. shader: string;
  103128. };
  103129. }
  103130. declare module BABYLON {
  103131. /** @hidden */
  103132. export var passCubePixelShader: {
  103133. name: string;
  103134. shader: string;
  103135. };
  103136. }
  103137. declare module BABYLON {
  103138. /**
  103139. * PassPostProcess which produces an output the same as it's input
  103140. */
  103141. export class PassPostProcess extends PostProcess {
  103142. /**
  103143. * Creates the PassPostProcess
  103144. * @param name The name of the effect.
  103145. * @param options The required width/height ratio to downsize to before computing the render pass.
  103146. * @param camera The camera to apply the render pass to.
  103147. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103148. * @param engine The engine which the post process will be applied. (default: current engine)
  103149. * @param reusable If the post process can be reused on the same frame. (default: false)
  103150. * @param textureType The type of texture to be used when performing the post processing.
  103151. * @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)
  103152. */
  103153. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103154. }
  103155. /**
  103156. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  103157. */
  103158. export class PassCubePostProcess extends PostProcess {
  103159. private _face;
  103160. /**
  103161. * Gets or sets the cube face to display.
  103162. * * 0 is +X
  103163. * * 1 is -X
  103164. * * 2 is +Y
  103165. * * 3 is -Y
  103166. * * 4 is +Z
  103167. * * 5 is -Z
  103168. */
  103169. face: number;
  103170. /**
  103171. * Creates the PassCubePostProcess
  103172. * @param name The name of the effect.
  103173. * @param options The required width/height ratio to downsize to before computing the render pass.
  103174. * @param camera The camera to apply the render pass to.
  103175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103176. * @param engine The engine which the post process will be applied. (default: current engine)
  103177. * @param reusable If the post process can be reused on the same frame. (default: false)
  103178. * @param textureType The type of texture to be used when performing the post processing.
  103179. * @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)
  103180. */
  103181. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  103182. }
  103183. }
  103184. declare module BABYLON {
  103185. /** @hidden */
  103186. export var anaglyphPixelShader: {
  103187. name: string;
  103188. shader: string;
  103189. };
  103190. }
  103191. declare module BABYLON {
  103192. /**
  103193. * Postprocess used to generate anaglyphic rendering
  103194. */
  103195. export class AnaglyphPostProcess extends PostProcess {
  103196. private _passedProcess;
  103197. /**
  103198. * Creates a new AnaglyphPostProcess
  103199. * @param name defines postprocess name
  103200. * @param options defines creation options or target ratio scale
  103201. * @param rigCameras defines cameras using this postprocess
  103202. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  103203. * @param engine defines hosting engine
  103204. * @param reusable defines if the postprocess will be reused multiple times per frame
  103205. */
  103206. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  103207. }
  103208. }
  103209. declare module BABYLON {
  103210. /**
  103211. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  103212. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103213. */
  103214. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  103215. /**
  103216. * Creates a new AnaglyphArcRotateCamera
  103217. * @param name defines camera name
  103218. * @param alpha defines alpha angle (in radians)
  103219. * @param beta defines beta angle (in radians)
  103220. * @param radius defines radius
  103221. * @param target defines camera target
  103222. * @param interaxialDistance defines distance between each color axis
  103223. * @param scene defines the hosting scene
  103224. */
  103225. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  103226. /**
  103227. * Gets camera class name
  103228. * @returns AnaglyphArcRotateCamera
  103229. */
  103230. getClassName(): string;
  103231. }
  103232. }
  103233. declare module BABYLON {
  103234. /**
  103235. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  103236. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103237. */
  103238. export class AnaglyphFreeCamera extends FreeCamera {
  103239. /**
  103240. * Creates a new AnaglyphFreeCamera
  103241. * @param name defines camera name
  103242. * @param position defines initial position
  103243. * @param interaxialDistance defines distance between each color axis
  103244. * @param scene defines the hosting scene
  103245. */
  103246. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103247. /**
  103248. * Gets camera class name
  103249. * @returns AnaglyphFreeCamera
  103250. */
  103251. getClassName(): string;
  103252. }
  103253. }
  103254. declare module BABYLON {
  103255. /**
  103256. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  103257. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103258. */
  103259. export class AnaglyphGamepadCamera extends GamepadCamera {
  103260. /**
  103261. * Creates a new AnaglyphGamepadCamera
  103262. * @param name defines camera name
  103263. * @param position defines initial position
  103264. * @param interaxialDistance defines distance between each color axis
  103265. * @param scene defines the hosting scene
  103266. */
  103267. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103268. /**
  103269. * Gets camera class name
  103270. * @returns AnaglyphGamepadCamera
  103271. */
  103272. getClassName(): string;
  103273. }
  103274. }
  103275. declare module BABYLON {
  103276. /**
  103277. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  103278. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  103279. */
  103280. export class AnaglyphUniversalCamera extends UniversalCamera {
  103281. /**
  103282. * Creates a new AnaglyphUniversalCamera
  103283. * @param name defines camera name
  103284. * @param position defines initial position
  103285. * @param interaxialDistance defines distance between each color axis
  103286. * @param scene defines the hosting scene
  103287. */
  103288. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  103289. /**
  103290. * Gets camera class name
  103291. * @returns AnaglyphUniversalCamera
  103292. */
  103293. getClassName(): string;
  103294. }
  103295. }
  103296. declare module BABYLON {
  103297. /** @hidden */
  103298. export var stereoscopicInterlacePixelShader: {
  103299. name: string;
  103300. shader: string;
  103301. };
  103302. }
  103303. declare module BABYLON {
  103304. /**
  103305. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  103306. */
  103307. export class StereoscopicInterlacePostProcess extends PostProcess {
  103308. private _stepSize;
  103309. private _passedProcess;
  103310. /**
  103311. * Initializes a StereoscopicInterlacePostProcess
  103312. * @param name The name of the effect.
  103313. * @param rigCameras The rig cameras to be appled to the post process
  103314. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  103315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103316. * @param engine The engine which the post process will be applied. (default: current engine)
  103317. * @param reusable If the post process can be reused on the same frame. (default: false)
  103318. */
  103319. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  103320. }
  103321. }
  103322. declare module BABYLON {
  103323. /**
  103324. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  103325. * @see http://doc.babylonjs.com/features/cameras
  103326. */
  103327. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  103328. /**
  103329. * Creates a new StereoscopicArcRotateCamera
  103330. * @param name defines camera name
  103331. * @param alpha defines alpha angle (in radians)
  103332. * @param beta defines beta angle (in radians)
  103333. * @param radius defines radius
  103334. * @param target defines camera target
  103335. * @param interaxialDistance defines distance between each color axis
  103336. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103337. * @param scene defines the hosting scene
  103338. */
  103339. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103340. /**
  103341. * Gets camera class name
  103342. * @returns StereoscopicArcRotateCamera
  103343. */
  103344. getClassName(): string;
  103345. }
  103346. }
  103347. declare module BABYLON {
  103348. /**
  103349. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  103350. * @see http://doc.babylonjs.com/features/cameras
  103351. */
  103352. export class StereoscopicFreeCamera extends FreeCamera {
  103353. /**
  103354. * Creates a new StereoscopicFreeCamera
  103355. * @param name defines camera name
  103356. * @param position defines initial position
  103357. * @param interaxialDistance defines distance between each color axis
  103358. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103359. * @param scene defines the hosting scene
  103360. */
  103361. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103362. /**
  103363. * Gets camera class name
  103364. * @returns StereoscopicFreeCamera
  103365. */
  103366. getClassName(): string;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  103372. * @see http://doc.babylonjs.com/features/cameras
  103373. */
  103374. export class StereoscopicGamepadCamera extends GamepadCamera {
  103375. /**
  103376. * Creates a new StereoscopicGamepadCamera
  103377. * @param name defines camera name
  103378. * @param position defines initial position
  103379. * @param interaxialDistance defines distance between each color axis
  103380. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103381. * @param scene defines the hosting scene
  103382. */
  103383. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103384. /**
  103385. * Gets camera class name
  103386. * @returns StereoscopicGamepadCamera
  103387. */
  103388. getClassName(): string;
  103389. }
  103390. }
  103391. declare module BABYLON {
  103392. /**
  103393. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  103394. * @see http://doc.babylonjs.com/features/cameras
  103395. */
  103396. export class StereoscopicUniversalCamera extends UniversalCamera {
  103397. /**
  103398. * Creates a new StereoscopicUniversalCamera
  103399. * @param name defines camera name
  103400. * @param position defines initial position
  103401. * @param interaxialDistance defines distance between each color axis
  103402. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  103403. * @param scene defines the hosting scene
  103404. */
  103405. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  103406. /**
  103407. * Gets camera class name
  103408. * @returns StereoscopicUniversalCamera
  103409. */
  103410. getClassName(): string;
  103411. }
  103412. }
  103413. declare module BABYLON {
  103414. /**
  103415. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  103416. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103417. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103418. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103419. */
  103420. export class VirtualJoysticksCamera extends FreeCamera {
  103421. /**
  103422. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  103423. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  103424. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  103425. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  103426. * @param name Define the name of the camera in the scene
  103427. * @param position Define the start position of the camera in the scene
  103428. * @param scene Define the scene the camera belongs to
  103429. */
  103430. constructor(name: string, position: Vector3, scene: Scene);
  103431. /**
  103432. * Gets the current object class name.
  103433. * @return the class name
  103434. */
  103435. getClassName(): string;
  103436. }
  103437. }
  103438. declare module BABYLON {
  103439. /**
  103440. * This represents all the required metrics to create a VR camera.
  103441. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  103442. */
  103443. export class VRCameraMetrics {
  103444. /**
  103445. * Define the horizontal resolution off the screen.
  103446. */
  103447. hResolution: number;
  103448. /**
  103449. * Define the vertical resolution off the screen.
  103450. */
  103451. vResolution: number;
  103452. /**
  103453. * Define the horizontal screen size.
  103454. */
  103455. hScreenSize: number;
  103456. /**
  103457. * Define the vertical screen size.
  103458. */
  103459. vScreenSize: number;
  103460. /**
  103461. * Define the vertical screen center position.
  103462. */
  103463. vScreenCenter: number;
  103464. /**
  103465. * Define the distance of the eyes to the screen.
  103466. */
  103467. eyeToScreenDistance: number;
  103468. /**
  103469. * Define the distance between both lenses
  103470. */
  103471. lensSeparationDistance: number;
  103472. /**
  103473. * Define the distance between both viewer's eyes.
  103474. */
  103475. interpupillaryDistance: number;
  103476. /**
  103477. * Define the distortion factor of the VR postprocess.
  103478. * Please, touch with care.
  103479. */
  103480. distortionK: number[];
  103481. /**
  103482. * Define the chromatic aberration correction factors for the VR post process.
  103483. */
  103484. chromaAbCorrection: number[];
  103485. /**
  103486. * Define the scale factor of the post process.
  103487. * The smaller the better but the slower.
  103488. */
  103489. postProcessScaleFactor: number;
  103490. /**
  103491. * Define an offset for the lens center.
  103492. */
  103493. lensCenterOffset: number;
  103494. /**
  103495. * Define if the current vr camera should compensate the distortion of the lense or not.
  103496. */
  103497. compensateDistortion: boolean;
  103498. /**
  103499. * Defines if multiview should be enabled when rendering (Default: false)
  103500. */
  103501. multiviewEnabled: boolean;
  103502. /**
  103503. * Gets the rendering aspect ratio based on the provided resolutions.
  103504. */
  103505. readonly aspectRatio: number;
  103506. /**
  103507. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  103508. */
  103509. readonly aspectRatioFov: number;
  103510. /**
  103511. * @hidden
  103512. */
  103513. readonly leftHMatrix: Matrix;
  103514. /**
  103515. * @hidden
  103516. */
  103517. readonly rightHMatrix: Matrix;
  103518. /**
  103519. * @hidden
  103520. */
  103521. readonly leftPreViewMatrix: Matrix;
  103522. /**
  103523. * @hidden
  103524. */
  103525. readonly rightPreViewMatrix: Matrix;
  103526. /**
  103527. * Get the default VRMetrics based on the most generic setup.
  103528. * @returns the default vr metrics
  103529. */
  103530. static GetDefault(): VRCameraMetrics;
  103531. }
  103532. }
  103533. declare module BABYLON {
  103534. /** @hidden */
  103535. export var vrDistortionCorrectionPixelShader: {
  103536. name: string;
  103537. shader: string;
  103538. };
  103539. }
  103540. declare module BABYLON {
  103541. /**
  103542. * VRDistortionCorrectionPostProcess used for mobile VR
  103543. */
  103544. export class VRDistortionCorrectionPostProcess extends PostProcess {
  103545. private _isRightEye;
  103546. private _distortionFactors;
  103547. private _postProcessScaleFactor;
  103548. private _lensCenterOffset;
  103549. private _scaleIn;
  103550. private _scaleFactor;
  103551. private _lensCenter;
  103552. /**
  103553. * Initializes the VRDistortionCorrectionPostProcess
  103554. * @param name The name of the effect.
  103555. * @param camera The camera to apply the render pass to.
  103556. * @param isRightEye If this is for the right eye distortion
  103557. * @param vrMetrics All the required metrics for the VR camera
  103558. */
  103559. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  103560. }
  103561. }
  103562. declare module BABYLON {
  103563. /**
  103564. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  103565. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103566. */
  103567. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  103568. /**
  103569. * Creates a new VRDeviceOrientationArcRotateCamera
  103570. * @param name defines camera name
  103571. * @param alpha defines the camera rotation along the logitudinal axis
  103572. * @param beta defines the camera rotation along the latitudinal axis
  103573. * @param radius defines the camera distance from its target
  103574. * @param target defines the camera target
  103575. * @param scene defines the scene the camera belongs to
  103576. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103577. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103578. */
  103579. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103580. /**
  103581. * Gets camera class name
  103582. * @returns VRDeviceOrientationArcRotateCamera
  103583. */
  103584. getClassName(): string;
  103585. }
  103586. }
  103587. declare module BABYLON {
  103588. /**
  103589. * Camera used to simulate VR rendering (based on FreeCamera)
  103590. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103591. */
  103592. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  103593. /**
  103594. * Creates a new VRDeviceOrientationFreeCamera
  103595. * @param name defines camera name
  103596. * @param position defines the start position of the camera
  103597. * @param scene defines the scene the camera belongs to
  103598. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103599. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103600. */
  103601. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103602. /**
  103603. * Gets camera class name
  103604. * @returns VRDeviceOrientationFreeCamera
  103605. */
  103606. getClassName(): string;
  103607. }
  103608. }
  103609. declare module BABYLON {
  103610. /**
  103611. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103612. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103613. */
  103614. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103615. /**
  103616. * Creates a new VRDeviceOrientationGamepadCamera
  103617. * @param name defines camera name
  103618. * @param position defines the start position of the camera
  103619. * @param scene defines the scene the camera belongs to
  103620. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103621. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103622. */
  103623. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103624. /**
  103625. * Gets camera class name
  103626. * @returns VRDeviceOrientationGamepadCamera
  103627. */
  103628. getClassName(): string;
  103629. }
  103630. }
  103631. declare module BABYLON {
  103632. /**
  103633. * Base class of materials working in push mode in babylon JS
  103634. * @hidden
  103635. */
  103636. export class PushMaterial extends Material {
  103637. protected _activeEffect: Effect;
  103638. protected _normalMatrix: Matrix;
  103639. /**
  103640. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103641. * This means that the material can keep using a previous shader while a new one is being compiled.
  103642. * This is mostly used when shader parallel compilation is supported (true by default)
  103643. */
  103644. allowShaderHotSwapping: boolean;
  103645. constructor(name: string, scene: Scene);
  103646. getEffect(): Effect;
  103647. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103648. /**
  103649. * Binds the given world matrix to the active effect
  103650. *
  103651. * @param world the matrix to bind
  103652. */
  103653. bindOnlyWorldMatrix(world: Matrix): void;
  103654. /**
  103655. * Binds the given normal matrix to the active effect
  103656. *
  103657. * @param normalMatrix the matrix to bind
  103658. */
  103659. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103660. bind(world: Matrix, mesh?: Mesh): void;
  103661. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103662. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103663. }
  103664. }
  103665. declare module BABYLON {
  103666. /**
  103667. * This groups all the flags used to control the materials channel.
  103668. */
  103669. export class MaterialFlags {
  103670. private static _DiffuseTextureEnabled;
  103671. /**
  103672. * Are diffuse textures enabled in the application.
  103673. */
  103674. static DiffuseTextureEnabled: boolean;
  103675. private static _AmbientTextureEnabled;
  103676. /**
  103677. * Are ambient textures enabled in the application.
  103678. */
  103679. static AmbientTextureEnabled: boolean;
  103680. private static _OpacityTextureEnabled;
  103681. /**
  103682. * Are opacity textures enabled in the application.
  103683. */
  103684. static OpacityTextureEnabled: boolean;
  103685. private static _ReflectionTextureEnabled;
  103686. /**
  103687. * Are reflection textures enabled in the application.
  103688. */
  103689. static ReflectionTextureEnabled: boolean;
  103690. private static _EmissiveTextureEnabled;
  103691. /**
  103692. * Are emissive textures enabled in the application.
  103693. */
  103694. static EmissiveTextureEnabled: boolean;
  103695. private static _SpecularTextureEnabled;
  103696. /**
  103697. * Are specular textures enabled in the application.
  103698. */
  103699. static SpecularTextureEnabled: boolean;
  103700. private static _BumpTextureEnabled;
  103701. /**
  103702. * Are bump textures enabled in the application.
  103703. */
  103704. static BumpTextureEnabled: boolean;
  103705. private static _LightmapTextureEnabled;
  103706. /**
  103707. * Are lightmap textures enabled in the application.
  103708. */
  103709. static LightmapTextureEnabled: boolean;
  103710. private static _RefractionTextureEnabled;
  103711. /**
  103712. * Are refraction textures enabled in the application.
  103713. */
  103714. static RefractionTextureEnabled: boolean;
  103715. private static _ColorGradingTextureEnabled;
  103716. /**
  103717. * Are color grading textures enabled in the application.
  103718. */
  103719. static ColorGradingTextureEnabled: boolean;
  103720. private static _FresnelEnabled;
  103721. /**
  103722. * Are fresnels enabled in the application.
  103723. */
  103724. static FresnelEnabled: boolean;
  103725. private static _ClearCoatTextureEnabled;
  103726. /**
  103727. * Are clear coat textures enabled in the application.
  103728. */
  103729. static ClearCoatTextureEnabled: boolean;
  103730. private static _ClearCoatBumpTextureEnabled;
  103731. /**
  103732. * Are clear coat bump textures enabled in the application.
  103733. */
  103734. static ClearCoatBumpTextureEnabled: boolean;
  103735. private static _ClearCoatTintTextureEnabled;
  103736. /**
  103737. * Are clear coat tint textures enabled in the application.
  103738. */
  103739. static ClearCoatTintTextureEnabled: boolean;
  103740. private static _SheenTextureEnabled;
  103741. /**
  103742. * Are sheen textures enabled in the application.
  103743. */
  103744. static SheenTextureEnabled: boolean;
  103745. private static _AnisotropicTextureEnabled;
  103746. /**
  103747. * Are anisotropic textures enabled in the application.
  103748. */
  103749. static AnisotropicTextureEnabled: boolean;
  103750. private static _ThicknessTextureEnabled;
  103751. /**
  103752. * Are thickness textures enabled in the application.
  103753. */
  103754. static ThicknessTextureEnabled: boolean;
  103755. }
  103756. }
  103757. declare module BABYLON {
  103758. /** @hidden */
  103759. export var defaultFragmentDeclaration: {
  103760. name: string;
  103761. shader: string;
  103762. };
  103763. }
  103764. declare module BABYLON {
  103765. /** @hidden */
  103766. export var defaultUboDeclaration: {
  103767. name: string;
  103768. shader: string;
  103769. };
  103770. }
  103771. declare module BABYLON {
  103772. /** @hidden */
  103773. export var lightFragmentDeclaration: {
  103774. name: string;
  103775. shader: string;
  103776. };
  103777. }
  103778. declare module BABYLON {
  103779. /** @hidden */
  103780. export var lightUboDeclaration: {
  103781. name: string;
  103782. shader: string;
  103783. };
  103784. }
  103785. declare module BABYLON {
  103786. /** @hidden */
  103787. export var lightsFragmentFunctions: {
  103788. name: string;
  103789. shader: string;
  103790. };
  103791. }
  103792. declare module BABYLON {
  103793. /** @hidden */
  103794. export var shadowsFragmentFunctions: {
  103795. name: string;
  103796. shader: string;
  103797. };
  103798. }
  103799. declare module BABYLON {
  103800. /** @hidden */
  103801. export var fresnelFunction: {
  103802. name: string;
  103803. shader: string;
  103804. };
  103805. }
  103806. declare module BABYLON {
  103807. /** @hidden */
  103808. export var reflectionFunction: {
  103809. name: string;
  103810. shader: string;
  103811. };
  103812. }
  103813. declare module BABYLON {
  103814. /** @hidden */
  103815. export var bumpFragmentFunctions: {
  103816. name: string;
  103817. shader: string;
  103818. };
  103819. }
  103820. declare module BABYLON {
  103821. /** @hidden */
  103822. export var logDepthDeclaration: {
  103823. name: string;
  103824. shader: string;
  103825. };
  103826. }
  103827. declare module BABYLON {
  103828. /** @hidden */
  103829. export var bumpFragment: {
  103830. name: string;
  103831. shader: string;
  103832. };
  103833. }
  103834. declare module BABYLON {
  103835. /** @hidden */
  103836. export var depthPrePass: {
  103837. name: string;
  103838. shader: string;
  103839. };
  103840. }
  103841. declare module BABYLON {
  103842. /** @hidden */
  103843. export var lightFragment: {
  103844. name: string;
  103845. shader: string;
  103846. };
  103847. }
  103848. declare module BABYLON {
  103849. /** @hidden */
  103850. export var logDepthFragment: {
  103851. name: string;
  103852. shader: string;
  103853. };
  103854. }
  103855. declare module BABYLON {
  103856. /** @hidden */
  103857. export var defaultPixelShader: {
  103858. name: string;
  103859. shader: string;
  103860. };
  103861. }
  103862. declare module BABYLON {
  103863. /** @hidden */
  103864. export var defaultVertexDeclaration: {
  103865. name: string;
  103866. shader: string;
  103867. };
  103868. }
  103869. declare module BABYLON {
  103870. /** @hidden */
  103871. export var bumpVertexDeclaration: {
  103872. name: string;
  103873. shader: string;
  103874. };
  103875. }
  103876. declare module BABYLON {
  103877. /** @hidden */
  103878. export var bumpVertex: {
  103879. name: string;
  103880. shader: string;
  103881. };
  103882. }
  103883. declare module BABYLON {
  103884. /** @hidden */
  103885. export var fogVertex: {
  103886. name: string;
  103887. shader: string;
  103888. };
  103889. }
  103890. declare module BABYLON {
  103891. /** @hidden */
  103892. export var shadowsVertex: {
  103893. name: string;
  103894. shader: string;
  103895. };
  103896. }
  103897. declare module BABYLON {
  103898. /** @hidden */
  103899. export var pointCloudVertex: {
  103900. name: string;
  103901. shader: string;
  103902. };
  103903. }
  103904. declare module BABYLON {
  103905. /** @hidden */
  103906. export var logDepthVertex: {
  103907. name: string;
  103908. shader: string;
  103909. };
  103910. }
  103911. declare module BABYLON {
  103912. /** @hidden */
  103913. export var defaultVertexShader: {
  103914. name: string;
  103915. shader: string;
  103916. };
  103917. }
  103918. declare module BABYLON {
  103919. /** @hidden */
  103920. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103921. MAINUV1: boolean;
  103922. MAINUV2: boolean;
  103923. DIFFUSE: boolean;
  103924. DIFFUSEDIRECTUV: number;
  103925. AMBIENT: boolean;
  103926. AMBIENTDIRECTUV: number;
  103927. OPACITY: boolean;
  103928. OPACITYDIRECTUV: number;
  103929. OPACITYRGB: boolean;
  103930. REFLECTION: boolean;
  103931. EMISSIVE: boolean;
  103932. EMISSIVEDIRECTUV: number;
  103933. SPECULAR: boolean;
  103934. SPECULARDIRECTUV: number;
  103935. BUMP: boolean;
  103936. BUMPDIRECTUV: number;
  103937. PARALLAX: boolean;
  103938. PARALLAXOCCLUSION: boolean;
  103939. SPECULAROVERALPHA: boolean;
  103940. CLIPPLANE: boolean;
  103941. CLIPPLANE2: boolean;
  103942. CLIPPLANE3: boolean;
  103943. CLIPPLANE4: boolean;
  103944. ALPHATEST: boolean;
  103945. DEPTHPREPASS: boolean;
  103946. ALPHAFROMDIFFUSE: boolean;
  103947. POINTSIZE: boolean;
  103948. FOG: boolean;
  103949. SPECULARTERM: boolean;
  103950. DIFFUSEFRESNEL: boolean;
  103951. OPACITYFRESNEL: boolean;
  103952. REFLECTIONFRESNEL: boolean;
  103953. REFRACTIONFRESNEL: boolean;
  103954. EMISSIVEFRESNEL: boolean;
  103955. FRESNEL: boolean;
  103956. NORMAL: boolean;
  103957. UV1: boolean;
  103958. UV2: boolean;
  103959. VERTEXCOLOR: boolean;
  103960. VERTEXALPHA: boolean;
  103961. NUM_BONE_INFLUENCERS: number;
  103962. BonesPerMesh: number;
  103963. BONETEXTURE: boolean;
  103964. INSTANCES: boolean;
  103965. GLOSSINESS: boolean;
  103966. ROUGHNESS: boolean;
  103967. EMISSIVEASILLUMINATION: boolean;
  103968. LINKEMISSIVEWITHDIFFUSE: boolean;
  103969. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103970. LIGHTMAP: boolean;
  103971. LIGHTMAPDIRECTUV: number;
  103972. OBJECTSPACE_NORMALMAP: boolean;
  103973. USELIGHTMAPASSHADOWMAP: boolean;
  103974. REFLECTIONMAP_3D: boolean;
  103975. REFLECTIONMAP_SPHERICAL: boolean;
  103976. REFLECTIONMAP_PLANAR: boolean;
  103977. REFLECTIONMAP_CUBIC: boolean;
  103978. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103979. REFLECTIONMAP_PROJECTION: boolean;
  103980. REFLECTIONMAP_SKYBOX: boolean;
  103981. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103982. REFLECTIONMAP_EXPLICIT: boolean;
  103983. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103984. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103985. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103986. INVERTCUBICMAP: boolean;
  103987. LOGARITHMICDEPTH: boolean;
  103988. REFRACTION: boolean;
  103989. REFRACTIONMAP_3D: boolean;
  103990. REFLECTIONOVERALPHA: boolean;
  103991. TWOSIDEDLIGHTING: boolean;
  103992. SHADOWFLOAT: boolean;
  103993. MORPHTARGETS: boolean;
  103994. MORPHTARGETS_NORMAL: boolean;
  103995. MORPHTARGETS_TANGENT: boolean;
  103996. MORPHTARGETS_UV: boolean;
  103997. NUM_MORPH_INFLUENCERS: number;
  103998. NONUNIFORMSCALING: boolean;
  103999. PREMULTIPLYALPHA: boolean;
  104000. IMAGEPROCESSING: boolean;
  104001. VIGNETTE: boolean;
  104002. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104003. VIGNETTEBLENDMODEOPAQUE: boolean;
  104004. TONEMAPPING: boolean;
  104005. TONEMAPPING_ACES: boolean;
  104006. CONTRAST: boolean;
  104007. COLORCURVES: boolean;
  104008. COLORGRADING: boolean;
  104009. COLORGRADING3D: boolean;
  104010. SAMPLER3DGREENDEPTH: boolean;
  104011. SAMPLER3DBGRMAP: boolean;
  104012. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104013. MULTIVIEW: boolean;
  104014. /**
  104015. * If the reflection texture on this material is in linear color space
  104016. * @hidden
  104017. */
  104018. IS_REFLECTION_LINEAR: boolean;
  104019. /**
  104020. * If the refraction texture on this material is in linear color space
  104021. * @hidden
  104022. */
  104023. IS_REFRACTION_LINEAR: boolean;
  104024. EXPOSURE: boolean;
  104025. constructor();
  104026. setReflectionMode(modeToEnable: string): void;
  104027. }
  104028. /**
  104029. * This is the default material used in Babylon. It is the best trade off between quality
  104030. * and performances.
  104031. * @see http://doc.babylonjs.com/babylon101/materials
  104032. */
  104033. export class StandardMaterial extends PushMaterial {
  104034. private _diffuseTexture;
  104035. /**
  104036. * The basic texture of the material as viewed under a light.
  104037. */
  104038. diffuseTexture: Nullable<BaseTexture>;
  104039. private _ambientTexture;
  104040. /**
  104041. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  104042. */
  104043. ambientTexture: Nullable<BaseTexture>;
  104044. private _opacityTexture;
  104045. /**
  104046. * Define the transparency of the material from a texture.
  104047. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  104048. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  104049. */
  104050. opacityTexture: Nullable<BaseTexture>;
  104051. private _reflectionTexture;
  104052. /**
  104053. * Define the texture used to display the reflection.
  104054. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104055. */
  104056. reflectionTexture: Nullable<BaseTexture>;
  104057. private _emissiveTexture;
  104058. /**
  104059. * Define texture of the material as if self lit.
  104060. * This will be mixed in the final result even in the absence of light.
  104061. */
  104062. emissiveTexture: Nullable<BaseTexture>;
  104063. private _specularTexture;
  104064. /**
  104065. * Define how the color and intensity of the highlight given by the light in the material.
  104066. */
  104067. specularTexture: Nullable<BaseTexture>;
  104068. private _bumpTexture;
  104069. /**
  104070. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  104071. * 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.
  104072. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  104073. */
  104074. bumpTexture: Nullable<BaseTexture>;
  104075. private _lightmapTexture;
  104076. /**
  104077. * Complex lighting can be computationally expensive to compute at runtime.
  104078. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  104079. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  104080. */
  104081. lightmapTexture: Nullable<BaseTexture>;
  104082. private _refractionTexture;
  104083. /**
  104084. * Define the texture used to display the refraction.
  104085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104086. */
  104087. refractionTexture: Nullable<BaseTexture>;
  104088. /**
  104089. * The color of the material lit by the environmental background lighting.
  104090. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  104091. */
  104092. ambientColor: Color3;
  104093. /**
  104094. * The basic color of the material as viewed under a light.
  104095. */
  104096. diffuseColor: Color3;
  104097. /**
  104098. * Define how the color and intensity of the highlight given by the light in the material.
  104099. */
  104100. specularColor: Color3;
  104101. /**
  104102. * Define the color of the material as if self lit.
  104103. * This will be mixed in the final result even in the absence of light.
  104104. */
  104105. emissiveColor: Color3;
  104106. /**
  104107. * Defines how sharp are the highlights in the material.
  104108. * The bigger the value the sharper giving a more glossy feeling to the result.
  104109. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  104110. */
  104111. specularPower: number;
  104112. private _useAlphaFromDiffuseTexture;
  104113. /**
  104114. * Does the transparency come from the diffuse texture alpha channel.
  104115. */
  104116. useAlphaFromDiffuseTexture: boolean;
  104117. private _useEmissiveAsIllumination;
  104118. /**
  104119. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  104120. */
  104121. useEmissiveAsIllumination: boolean;
  104122. private _linkEmissiveWithDiffuse;
  104123. /**
  104124. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  104125. * the emissive level when the final color is close to one.
  104126. */
  104127. linkEmissiveWithDiffuse: boolean;
  104128. private _useSpecularOverAlpha;
  104129. /**
  104130. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104131. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104132. */
  104133. useSpecularOverAlpha: boolean;
  104134. private _useReflectionOverAlpha;
  104135. /**
  104136. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104137. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104138. */
  104139. useReflectionOverAlpha: boolean;
  104140. private _disableLighting;
  104141. /**
  104142. * Does lights from the scene impacts this material.
  104143. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  104144. */
  104145. disableLighting: boolean;
  104146. private _useObjectSpaceNormalMap;
  104147. /**
  104148. * Allows using an object space normal map (instead of tangent space).
  104149. */
  104150. useObjectSpaceNormalMap: boolean;
  104151. private _useParallax;
  104152. /**
  104153. * Is parallax enabled or not.
  104154. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104155. */
  104156. useParallax: boolean;
  104157. private _useParallaxOcclusion;
  104158. /**
  104159. * Is parallax occlusion enabled or not.
  104160. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  104161. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  104162. */
  104163. useParallaxOcclusion: boolean;
  104164. /**
  104165. * 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.
  104166. */
  104167. parallaxScaleBias: number;
  104168. private _roughness;
  104169. /**
  104170. * Helps to define how blurry the reflections should appears in the material.
  104171. */
  104172. roughness: number;
  104173. /**
  104174. * In case of refraction, define the value of the index of refraction.
  104175. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104176. */
  104177. indexOfRefraction: number;
  104178. /**
  104179. * Invert the refraction texture alongside the y axis.
  104180. * It can be useful with procedural textures or probe for instance.
  104181. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  104182. */
  104183. invertRefractionY: boolean;
  104184. /**
  104185. * Defines the alpha limits in alpha test mode.
  104186. */
  104187. alphaCutOff: number;
  104188. private _useLightmapAsShadowmap;
  104189. /**
  104190. * In case of light mapping, define whether the map contains light or shadow informations.
  104191. */
  104192. useLightmapAsShadowmap: boolean;
  104193. private _diffuseFresnelParameters;
  104194. /**
  104195. * Define the diffuse fresnel parameters of the material.
  104196. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104197. */
  104198. diffuseFresnelParameters: FresnelParameters;
  104199. private _opacityFresnelParameters;
  104200. /**
  104201. * Define the opacity fresnel parameters of the material.
  104202. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104203. */
  104204. opacityFresnelParameters: FresnelParameters;
  104205. private _reflectionFresnelParameters;
  104206. /**
  104207. * Define the reflection fresnel parameters of the material.
  104208. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104209. */
  104210. reflectionFresnelParameters: FresnelParameters;
  104211. private _refractionFresnelParameters;
  104212. /**
  104213. * Define the refraction fresnel parameters of the material.
  104214. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104215. */
  104216. refractionFresnelParameters: FresnelParameters;
  104217. private _emissiveFresnelParameters;
  104218. /**
  104219. * Define the emissive fresnel parameters of the material.
  104220. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104221. */
  104222. emissiveFresnelParameters: FresnelParameters;
  104223. private _useReflectionFresnelFromSpecular;
  104224. /**
  104225. * If true automatically deducts the fresnels values from the material specularity.
  104226. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104227. */
  104228. useReflectionFresnelFromSpecular: boolean;
  104229. private _useGlossinessFromSpecularMapAlpha;
  104230. /**
  104231. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  104232. */
  104233. useGlossinessFromSpecularMapAlpha: boolean;
  104234. private _maxSimultaneousLights;
  104235. /**
  104236. * Defines the maximum number of lights that can be used in the material
  104237. */
  104238. maxSimultaneousLights: number;
  104239. private _invertNormalMapX;
  104240. /**
  104241. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104242. */
  104243. invertNormalMapX: boolean;
  104244. private _invertNormalMapY;
  104245. /**
  104246. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104247. */
  104248. invertNormalMapY: boolean;
  104249. private _twoSidedLighting;
  104250. /**
  104251. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104252. */
  104253. twoSidedLighting: boolean;
  104254. /**
  104255. * Default configuration related to image processing available in the standard Material.
  104256. */
  104257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104258. /**
  104259. * Gets the image processing configuration used either in this material.
  104260. */
  104261. /**
  104262. * Sets the Default image processing configuration used either in the this material.
  104263. *
  104264. * If sets to null, the scene one is in use.
  104265. */
  104266. imageProcessingConfiguration: ImageProcessingConfiguration;
  104267. /**
  104268. * Keep track of the image processing observer to allow dispose and replace.
  104269. */
  104270. private _imageProcessingObserver;
  104271. /**
  104272. * Attaches a new image processing configuration to the Standard Material.
  104273. * @param configuration
  104274. */
  104275. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104276. /**
  104277. * Gets wether the color curves effect is enabled.
  104278. */
  104279. /**
  104280. * Sets wether the color curves effect is enabled.
  104281. */
  104282. cameraColorCurvesEnabled: boolean;
  104283. /**
  104284. * Gets wether the color grading effect is enabled.
  104285. */
  104286. /**
  104287. * Gets wether the color grading effect is enabled.
  104288. */
  104289. cameraColorGradingEnabled: boolean;
  104290. /**
  104291. * Gets wether tonemapping is enabled or not.
  104292. */
  104293. /**
  104294. * Sets wether tonemapping is enabled or not
  104295. */
  104296. cameraToneMappingEnabled: boolean;
  104297. /**
  104298. * The camera exposure used on this material.
  104299. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104300. * This corresponds to a photographic exposure.
  104301. */
  104302. /**
  104303. * The camera exposure used on this material.
  104304. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104305. * This corresponds to a photographic exposure.
  104306. */
  104307. cameraExposure: number;
  104308. /**
  104309. * Gets The camera contrast used on this material.
  104310. */
  104311. /**
  104312. * Sets The camera contrast used on this material.
  104313. */
  104314. cameraContrast: number;
  104315. /**
  104316. * Gets the Color Grading 2D Lookup Texture.
  104317. */
  104318. /**
  104319. * Sets the Color Grading 2D Lookup Texture.
  104320. */
  104321. cameraColorGradingTexture: Nullable<BaseTexture>;
  104322. /**
  104323. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104324. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104325. * 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;
  104326. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104327. */
  104328. /**
  104329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104331. * 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;
  104332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104333. */
  104334. cameraColorCurves: Nullable<ColorCurves>;
  104335. /**
  104336. * Custom callback helping to override the default shader used in the material.
  104337. */
  104338. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  104339. protected _renderTargets: SmartArray<RenderTargetTexture>;
  104340. protected _worldViewProjectionMatrix: Matrix;
  104341. protected _globalAmbientColor: Color3;
  104342. protected _useLogarithmicDepth: boolean;
  104343. /**
  104344. * Instantiates a new standard material.
  104345. * This is the default material used in Babylon. It is the best trade off between quality
  104346. * and performances.
  104347. * @see http://doc.babylonjs.com/babylon101/materials
  104348. * @param name Define the name of the material in the scene
  104349. * @param scene Define the scene the material belong to
  104350. */
  104351. constructor(name: string, scene: Scene);
  104352. /**
  104353. * Gets a boolean indicating that current material needs to register RTT
  104354. */
  104355. readonly hasRenderTargetTextures: boolean;
  104356. /**
  104357. * Gets the current class name of the material e.g. "StandardMaterial"
  104358. * Mainly use in serialization.
  104359. * @returns the class name
  104360. */
  104361. getClassName(): string;
  104362. /**
  104363. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  104364. * You can try switching to logarithmic depth.
  104365. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  104366. */
  104367. useLogarithmicDepth: boolean;
  104368. /**
  104369. * Specifies if the material will require alpha blending
  104370. * @returns a boolean specifying if alpha blending is needed
  104371. */
  104372. needAlphaBlending(): boolean;
  104373. /**
  104374. * Specifies if this material should be rendered in alpha test mode
  104375. * @returns a boolean specifying if an alpha test is needed.
  104376. */
  104377. needAlphaTesting(): boolean;
  104378. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  104379. /**
  104380. * Get the texture used for alpha test purpose.
  104381. * @returns the diffuse texture in case of the standard material.
  104382. */
  104383. getAlphaTestTexture(): Nullable<BaseTexture>;
  104384. /**
  104385. * Get if the submesh is ready to be used and all its information available.
  104386. * Child classes can use it to update shaders
  104387. * @param mesh defines the mesh to check
  104388. * @param subMesh defines which submesh to check
  104389. * @param useInstances specifies that instances should be used
  104390. * @returns a boolean indicating that the submesh is ready or not
  104391. */
  104392. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104393. /**
  104394. * Builds the material UBO layouts.
  104395. * Used internally during the effect preparation.
  104396. */
  104397. buildUniformLayout(): void;
  104398. /**
  104399. * Unbinds the material from the mesh
  104400. */
  104401. unbind(): void;
  104402. /**
  104403. * Binds the submesh to this material by preparing the effect and shader to draw
  104404. * @param world defines the world transformation matrix
  104405. * @param mesh defines the mesh containing the submesh
  104406. * @param subMesh defines the submesh to bind the material to
  104407. */
  104408. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104409. /**
  104410. * Get the list of animatables in the material.
  104411. * @returns the list of animatables object used in the material
  104412. */
  104413. getAnimatables(): IAnimatable[];
  104414. /**
  104415. * Gets the active textures from the material
  104416. * @returns an array of textures
  104417. */
  104418. getActiveTextures(): BaseTexture[];
  104419. /**
  104420. * Specifies if the material uses a texture
  104421. * @param texture defines the texture to check against the material
  104422. * @returns a boolean specifying if the material uses the texture
  104423. */
  104424. hasTexture(texture: BaseTexture): boolean;
  104425. /**
  104426. * Disposes the material
  104427. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104428. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104429. */
  104430. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104431. /**
  104432. * Makes a duplicate of the material, and gives it a new name
  104433. * @param name defines the new name for the duplicated material
  104434. * @returns the cloned material
  104435. */
  104436. clone(name: string): StandardMaterial;
  104437. /**
  104438. * Serializes this material in a JSON representation
  104439. * @returns the serialized material object
  104440. */
  104441. serialize(): any;
  104442. /**
  104443. * Creates a standard material from parsed material data
  104444. * @param source defines the JSON representation of the material
  104445. * @param scene defines the hosting scene
  104446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104447. * @returns a new standard material
  104448. */
  104449. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  104450. /**
  104451. * Are diffuse textures enabled in the application.
  104452. */
  104453. static DiffuseTextureEnabled: boolean;
  104454. /**
  104455. * Are ambient textures enabled in the application.
  104456. */
  104457. static AmbientTextureEnabled: boolean;
  104458. /**
  104459. * Are opacity textures enabled in the application.
  104460. */
  104461. static OpacityTextureEnabled: boolean;
  104462. /**
  104463. * Are reflection textures enabled in the application.
  104464. */
  104465. static ReflectionTextureEnabled: boolean;
  104466. /**
  104467. * Are emissive textures enabled in the application.
  104468. */
  104469. static EmissiveTextureEnabled: boolean;
  104470. /**
  104471. * Are specular textures enabled in the application.
  104472. */
  104473. static SpecularTextureEnabled: boolean;
  104474. /**
  104475. * Are bump textures enabled in the application.
  104476. */
  104477. static BumpTextureEnabled: boolean;
  104478. /**
  104479. * Are lightmap textures enabled in the application.
  104480. */
  104481. static LightmapTextureEnabled: boolean;
  104482. /**
  104483. * Are refraction textures enabled in the application.
  104484. */
  104485. static RefractionTextureEnabled: boolean;
  104486. /**
  104487. * Are color grading textures enabled in the application.
  104488. */
  104489. static ColorGradingTextureEnabled: boolean;
  104490. /**
  104491. * Are fresnels enabled in the application.
  104492. */
  104493. static FresnelEnabled: boolean;
  104494. }
  104495. }
  104496. declare module BABYLON {
  104497. /**
  104498. * A class extending Texture allowing drawing on a texture
  104499. * @see http://doc.babylonjs.com/how_to/dynamictexture
  104500. */
  104501. export class DynamicTexture extends Texture {
  104502. private _generateMipMaps;
  104503. private _canvas;
  104504. private _context;
  104505. private _engine;
  104506. /**
  104507. * Creates a DynamicTexture
  104508. * @param name defines the name of the texture
  104509. * @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
  104510. * @param scene defines the scene where you want the texture
  104511. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  104512. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  104513. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  104514. */
  104515. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  104516. /**
  104517. * Get the current class name of the texture useful for serialization or dynamic coding.
  104518. * @returns "DynamicTexture"
  104519. */
  104520. getClassName(): string;
  104521. /**
  104522. * Gets the current state of canRescale
  104523. */
  104524. readonly canRescale: boolean;
  104525. private _recreate;
  104526. /**
  104527. * Scales the texture
  104528. * @param ratio the scale factor to apply to both width and height
  104529. */
  104530. scale(ratio: number): void;
  104531. /**
  104532. * Resizes the texture
  104533. * @param width the new width
  104534. * @param height the new height
  104535. */
  104536. scaleTo(width: number, height: number): void;
  104537. /**
  104538. * Gets the context of the canvas used by the texture
  104539. * @returns the canvas context of the dynamic texture
  104540. */
  104541. getContext(): CanvasRenderingContext2D;
  104542. /**
  104543. * Clears the texture
  104544. */
  104545. clear(): void;
  104546. /**
  104547. * Updates the texture
  104548. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104549. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  104550. */
  104551. update(invertY?: boolean, premulAlpha?: boolean): void;
  104552. /**
  104553. * Draws text onto the texture
  104554. * @param text defines the text to be drawn
  104555. * @param x defines the placement of the text from the left
  104556. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  104557. * @param font defines the font to be used with font-style, font-size, font-name
  104558. * @param color defines the color used for the text
  104559. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  104560. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  104561. * @param update defines whether texture is immediately update (default is true)
  104562. */
  104563. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  104564. /**
  104565. * Clones the texture
  104566. * @returns the clone of the texture.
  104567. */
  104568. clone(): DynamicTexture;
  104569. /**
  104570. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  104571. * @returns a serialized dynamic texture object
  104572. */
  104573. serialize(): any;
  104574. /** @hidden */
  104575. _rebuild(): void;
  104576. }
  104577. }
  104578. declare module BABYLON {
  104579. /** @hidden */
  104580. export var imageProcessingPixelShader: {
  104581. name: string;
  104582. shader: string;
  104583. };
  104584. }
  104585. declare module BABYLON {
  104586. /**
  104587. * ImageProcessingPostProcess
  104588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104589. */
  104590. export class ImageProcessingPostProcess extends PostProcess {
  104591. /**
  104592. * Default configuration related to image processing available in the PBR Material.
  104593. */
  104594. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104595. /**
  104596. * Gets the image processing configuration used either in this material.
  104597. */
  104598. /**
  104599. * Sets the Default image processing configuration used either in the this material.
  104600. *
  104601. * If sets to null, the scene one is in use.
  104602. */
  104603. imageProcessingConfiguration: ImageProcessingConfiguration;
  104604. /**
  104605. * Keep track of the image processing observer to allow dispose and replace.
  104606. */
  104607. private _imageProcessingObserver;
  104608. /**
  104609. * Attaches a new image processing configuration to the PBR Material.
  104610. * @param configuration
  104611. */
  104612. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104613. /**
  104614. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104615. */
  104616. /**
  104617. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104618. */
  104619. colorCurves: Nullable<ColorCurves>;
  104620. /**
  104621. * Gets wether the color curves effect is enabled.
  104622. */
  104623. /**
  104624. * Sets wether the color curves effect is enabled.
  104625. */
  104626. colorCurvesEnabled: boolean;
  104627. /**
  104628. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104629. */
  104630. /**
  104631. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104632. */
  104633. colorGradingTexture: Nullable<BaseTexture>;
  104634. /**
  104635. * Gets wether the color grading effect is enabled.
  104636. */
  104637. /**
  104638. * Gets wether the color grading effect is enabled.
  104639. */
  104640. colorGradingEnabled: boolean;
  104641. /**
  104642. * Gets exposure used in the effect.
  104643. */
  104644. /**
  104645. * Sets exposure used in the effect.
  104646. */
  104647. exposure: number;
  104648. /**
  104649. * Gets wether tonemapping is enabled or not.
  104650. */
  104651. /**
  104652. * Sets wether tonemapping is enabled or not
  104653. */
  104654. toneMappingEnabled: boolean;
  104655. /**
  104656. * Gets the type of tone mapping effect.
  104657. */
  104658. /**
  104659. * Sets the type of tone mapping effect.
  104660. */
  104661. toneMappingType: number;
  104662. /**
  104663. * Gets contrast used in the effect.
  104664. */
  104665. /**
  104666. * Sets contrast used in the effect.
  104667. */
  104668. contrast: number;
  104669. /**
  104670. * Gets Vignette stretch size.
  104671. */
  104672. /**
  104673. * Sets Vignette stretch size.
  104674. */
  104675. vignetteStretch: number;
  104676. /**
  104677. * Gets Vignette centre X Offset.
  104678. */
  104679. /**
  104680. * Sets Vignette centre X Offset.
  104681. */
  104682. vignetteCentreX: number;
  104683. /**
  104684. * Gets Vignette centre Y Offset.
  104685. */
  104686. /**
  104687. * Sets Vignette centre Y Offset.
  104688. */
  104689. vignetteCentreY: number;
  104690. /**
  104691. * Gets Vignette weight or intensity of the vignette effect.
  104692. */
  104693. /**
  104694. * Sets Vignette weight or intensity of the vignette effect.
  104695. */
  104696. vignetteWeight: number;
  104697. /**
  104698. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104699. * if vignetteEnabled is set to true.
  104700. */
  104701. /**
  104702. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104703. * if vignetteEnabled is set to true.
  104704. */
  104705. vignetteColor: Color4;
  104706. /**
  104707. * Gets Camera field of view used by the Vignette effect.
  104708. */
  104709. /**
  104710. * Sets Camera field of view used by the Vignette effect.
  104711. */
  104712. vignetteCameraFov: number;
  104713. /**
  104714. * Gets the vignette blend mode allowing different kind of effect.
  104715. */
  104716. /**
  104717. * Sets the vignette blend mode allowing different kind of effect.
  104718. */
  104719. vignetteBlendMode: number;
  104720. /**
  104721. * Gets wether the vignette effect is enabled.
  104722. */
  104723. /**
  104724. * Sets wether the vignette effect is enabled.
  104725. */
  104726. vignetteEnabled: boolean;
  104727. private _fromLinearSpace;
  104728. /**
  104729. * Gets wether the input of the processing is in Gamma or Linear Space.
  104730. */
  104731. /**
  104732. * Sets wether the input of the processing is in Gamma or Linear Space.
  104733. */
  104734. fromLinearSpace: boolean;
  104735. /**
  104736. * Defines cache preventing GC.
  104737. */
  104738. private _defines;
  104739. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104740. /**
  104741. * "ImageProcessingPostProcess"
  104742. * @returns "ImageProcessingPostProcess"
  104743. */
  104744. getClassName(): string;
  104745. protected _updateParameters(): void;
  104746. dispose(camera?: Camera): void;
  104747. }
  104748. }
  104749. declare module BABYLON {
  104750. /**
  104751. * Class containing static functions to help procedurally build meshes
  104752. */
  104753. export class GroundBuilder {
  104754. /**
  104755. * Creates a ground mesh
  104756. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104757. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104759. * @param name defines the name of the mesh
  104760. * @param options defines the options used to create the mesh
  104761. * @param scene defines the hosting scene
  104762. * @returns the ground mesh
  104763. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104764. */
  104765. static CreateGround(name: string, options: {
  104766. width?: number;
  104767. height?: number;
  104768. subdivisions?: number;
  104769. subdivisionsX?: number;
  104770. subdivisionsY?: number;
  104771. updatable?: boolean;
  104772. }, scene: any): Mesh;
  104773. /**
  104774. * Creates a tiled ground mesh
  104775. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104776. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104777. * * 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
  104778. * * 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
  104779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104780. * @param name defines the name of the mesh
  104781. * @param options defines the options used to create the mesh
  104782. * @param scene defines the hosting scene
  104783. * @returns the tiled ground mesh
  104784. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104785. */
  104786. static CreateTiledGround(name: string, options: {
  104787. xmin: number;
  104788. zmin: number;
  104789. xmax: number;
  104790. zmax: number;
  104791. subdivisions?: {
  104792. w: number;
  104793. h: number;
  104794. };
  104795. precision?: {
  104796. w: number;
  104797. h: number;
  104798. };
  104799. updatable?: boolean;
  104800. }, scene?: Nullable<Scene>): Mesh;
  104801. /**
  104802. * Creates a ground mesh from a height map
  104803. * * The parameter `url` sets the URL of the height map image resource.
  104804. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104805. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104806. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104807. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104808. * * 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.
  104809. * * 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).
  104810. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104812. * @param name defines the name of the mesh
  104813. * @param url defines the url to the height map
  104814. * @param options defines the options used to create the mesh
  104815. * @param scene defines the hosting scene
  104816. * @returns the ground mesh
  104817. * @see https://doc.babylonjs.com/babylon101/height_map
  104818. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104819. */
  104820. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104821. width?: number;
  104822. height?: number;
  104823. subdivisions?: number;
  104824. minHeight?: number;
  104825. maxHeight?: number;
  104826. colorFilter?: Color3;
  104827. alphaFilter?: number;
  104828. updatable?: boolean;
  104829. onReady?: (mesh: GroundMesh) => void;
  104830. }, scene?: Nullable<Scene>): GroundMesh;
  104831. }
  104832. }
  104833. declare module BABYLON {
  104834. /**
  104835. * Class containing static functions to help procedurally build meshes
  104836. */
  104837. export class TorusBuilder {
  104838. /**
  104839. * Creates a torus mesh
  104840. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104841. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104842. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104846. * @param name defines the name of the mesh
  104847. * @param options defines the options used to create the mesh
  104848. * @param scene defines the hosting scene
  104849. * @returns the torus mesh
  104850. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104851. */
  104852. static CreateTorus(name: string, options: {
  104853. diameter?: number;
  104854. thickness?: number;
  104855. tessellation?: number;
  104856. updatable?: boolean;
  104857. sideOrientation?: number;
  104858. frontUVs?: Vector4;
  104859. backUVs?: Vector4;
  104860. }, scene: any): Mesh;
  104861. }
  104862. }
  104863. declare module BABYLON {
  104864. /**
  104865. * Class containing static functions to help procedurally build meshes
  104866. */
  104867. export class CylinderBuilder {
  104868. /**
  104869. * Creates a cylinder or a cone mesh
  104870. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104871. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104872. * * 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.
  104873. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104874. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104875. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104876. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104877. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  104878. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104879. * * 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).
  104880. * * 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
  104881. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104882. * * 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
  104883. * * 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.
  104884. * * If `enclose` is false, a ring surface is one element.
  104885. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104886. * * 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
  104887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104890. * @param name defines the name of the mesh
  104891. * @param options defines the options used to create the mesh
  104892. * @param scene defines the hosting scene
  104893. * @returns the cylinder mesh
  104894. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104895. */
  104896. static CreateCylinder(name: string, options: {
  104897. height?: number;
  104898. diameterTop?: number;
  104899. diameterBottom?: number;
  104900. diameter?: number;
  104901. tessellation?: number;
  104902. subdivisions?: number;
  104903. arc?: number;
  104904. faceColors?: Color4[];
  104905. faceUV?: Vector4[];
  104906. updatable?: boolean;
  104907. hasRings?: boolean;
  104908. enclose?: boolean;
  104909. cap?: number;
  104910. sideOrientation?: number;
  104911. frontUVs?: Vector4;
  104912. backUVs?: Vector4;
  104913. }, scene: any): Mesh;
  104914. }
  104915. }
  104916. declare module BABYLON {
  104917. /**
  104918. * Options to modify the vr teleportation behavior.
  104919. */
  104920. export interface VRTeleportationOptions {
  104921. /**
  104922. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104923. */
  104924. floorMeshName?: string;
  104925. /**
  104926. * A list of meshes to be used as the teleportation floor. (default: empty)
  104927. */
  104928. floorMeshes?: Mesh[];
  104929. }
  104930. /**
  104931. * Options to modify the vr experience helper's behavior.
  104932. */
  104933. export interface VRExperienceHelperOptions extends WebVROptions {
  104934. /**
  104935. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104936. */
  104937. createDeviceOrientationCamera?: boolean;
  104938. /**
  104939. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104940. */
  104941. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104942. /**
  104943. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104944. */
  104945. laserToggle?: boolean;
  104946. /**
  104947. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104948. */
  104949. floorMeshes?: Mesh[];
  104950. /**
  104951. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104952. */
  104953. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104954. }
  104955. /**
  104956. * Event containing information after VR has been entered
  104957. */
  104958. export class OnAfterEnteringVRObservableEvent {
  104959. /**
  104960. * If entering vr was successful
  104961. */
  104962. success: boolean;
  104963. }
  104964. /**
  104965. * Helps to quickly add VR support to an existing scene.
  104966. * See http://doc.babylonjs.com/how_to/webvr_helper
  104967. */
  104968. export class VRExperienceHelper {
  104969. /** Options to modify the vr experience helper's behavior. */
  104970. webVROptions: VRExperienceHelperOptions;
  104971. private _scene;
  104972. private _position;
  104973. private _btnVR;
  104974. private _btnVRDisplayed;
  104975. private _webVRsupported;
  104976. private _webVRready;
  104977. private _webVRrequesting;
  104978. private _webVRpresenting;
  104979. private _hasEnteredVR;
  104980. private _fullscreenVRpresenting;
  104981. private _canvas;
  104982. private _webVRCamera;
  104983. private _vrDeviceOrientationCamera;
  104984. private _deviceOrientationCamera;
  104985. private _existingCamera;
  104986. private _onKeyDown;
  104987. private _onVrDisplayPresentChange;
  104988. private _onVRDisplayChanged;
  104989. private _onVRRequestPresentStart;
  104990. private _onVRRequestPresentComplete;
  104991. /**
  104992. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  104993. */
  104994. enableGazeEvenWhenNoPointerLock: boolean;
  104995. /**
  104996. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104997. */
  104998. exitVROnDoubleTap: boolean;
  104999. /**
  105000. * Observable raised right before entering VR.
  105001. */
  105002. onEnteringVRObservable: Observable<VRExperienceHelper>;
  105003. /**
  105004. * Observable raised when entering VR has completed.
  105005. */
  105006. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  105007. /**
  105008. * Observable raised when exiting VR.
  105009. */
  105010. onExitingVRObservable: Observable<VRExperienceHelper>;
  105011. /**
  105012. * Observable raised when controller mesh is loaded.
  105013. */
  105014. onControllerMeshLoadedObservable: Observable<WebVRController>;
  105015. /** Return this.onEnteringVRObservable
  105016. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  105017. */
  105018. readonly onEnteringVR: Observable<VRExperienceHelper>;
  105019. /** Return this.onExitingVRObservable
  105020. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  105021. */
  105022. readonly onExitingVR: Observable<VRExperienceHelper>;
  105023. /** Return this.onControllerMeshLoadedObservable
  105024. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  105025. */
  105026. readonly onControllerMeshLoaded: Observable<WebVRController>;
  105027. private _rayLength;
  105028. private _useCustomVRButton;
  105029. private _teleportationRequested;
  105030. private _teleportActive;
  105031. private _floorMeshName;
  105032. private _floorMeshesCollection;
  105033. private _rotationAllowed;
  105034. private _teleportBackwardsVector;
  105035. private _teleportationTarget;
  105036. private _isDefaultTeleportationTarget;
  105037. private _postProcessMove;
  105038. private _teleportationFillColor;
  105039. private _teleportationBorderColor;
  105040. private _rotationAngle;
  105041. private _haloCenter;
  105042. private _cameraGazer;
  105043. private _padSensibilityUp;
  105044. private _padSensibilityDown;
  105045. private _leftController;
  105046. private _rightController;
  105047. /**
  105048. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  105049. */
  105050. onNewMeshSelected: Observable<AbstractMesh>;
  105051. /**
  105052. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  105053. */
  105054. onNewMeshPicked: Observable<PickingInfo>;
  105055. private _circleEase;
  105056. /**
  105057. * Observable raised before camera teleportation
  105058. */
  105059. onBeforeCameraTeleport: Observable<Vector3>;
  105060. /**
  105061. * Observable raised after camera teleportation
  105062. */
  105063. onAfterCameraTeleport: Observable<Vector3>;
  105064. /**
  105065. * Observable raised when current selected mesh gets unselected
  105066. */
  105067. onSelectedMeshUnselected: Observable<AbstractMesh>;
  105068. private _raySelectionPredicate;
  105069. /**
  105070. * To be optionaly changed by user to define custom ray selection
  105071. */
  105072. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  105073. /**
  105074. * To be optionaly changed by user to define custom selection logic (after ray selection)
  105075. */
  105076. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  105077. /**
  105078. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  105079. */
  105080. teleportationEnabled: boolean;
  105081. private _defaultHeight;
  105082. private _teleportationInitialized;
  105083. private _interactionsEnabled;
  105084. private _interactionsRequested;
  105085. private _displayGaze;
  105086. private _displayLaserPointer;
  105087. /**
  105088. * The mesh used to display where the user is going to teleport.
  105089. */
  105090. /**
  105091. * Sets the mesh to be used to display where the user is going to teleport.
  105092. */
  105093. teleportationTarget: Mesh;
  105094. /**
  105095. * 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
  105096. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  105097. * See http://doc.babylonjs.com/resources/baking_transformations
  105098. */
  105099. gazeTrackerMesh: Mesh;
  105100. /**
  105101. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  105102. */
  105103. updateGazeTrackerScale: boolean;
  105104. /**
  105105. * If the gaze trackers color should be updated when selecting meshes
  105106. */
  105107. updateGazeTrackerColor: boolean;
  105108. /**
  105109. * The gaze tracking mesh corresponding to the left controller
  105110. */
  105111. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  105112. /**
  105113. * The gaze tracking mesh corresponding to the right controller
  105114. */
  105115. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  105116. /**
  105117. * If the ray of the gaze should be displayed.
  105118. */
  105119. /**
  105120. * Sets if the ray of the gaze should be displayed.
  105121. */
  105122. displayGaze: boolean;
  105123. /**
  105124. * If the ray of the LaserPointer should be displayed.
  105125. */
  105126. /**
  105127. * Sets if the ray of the LaserPointer should be displayed.
  105128. */
  105129. displayLaserPointer: boolean;
  105130. /**
  105131. * The deviceOrientationCamera used as the camera when not in VR.
  105132. */
  105133. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  105134. /**
  105135. * Based on the current WebVR support, returns the current VR camera used.
  105136. */
  105137. readonly currentVRCamera: Nullable<Camera>;
  105138. /**
  105139. * The webVRCamera which is used when in VR.
  105140. */
  105141. readonly webVRCamera: WebVRFreeCamera;
  105142. /**
  105143. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  105144. */
  105145. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  105146. /**
  105147. * The html button that is used to trigger entering into VR.
  105148. */
  105149. readonly vrButton: Nullable<HTMLButtonElement>;
  105150. private readonly _teleportationRequestInitiated;
  105151. /**
  105152. * Defines wether or not Pointer lock should be requested when switching to
  105153. * full screen.
  105154. */
  105155. requestPointerLockOnFullScreen: boolean;
  105156. /**
  105157. * Instantiates a VRExperienceHelper.
  105158. * Helps to quickly add VR support to an existing scene.
  105159. * @param scene The scene the VRExperienceHelper belongs to.
  105160. * @param webVROptions Options to modify the vr experience helper's behavior.
  105161. */
  105162. constructor(scene: Scene,
  105163. /** Options to modify the vr experience helper's behavior. */
  105164. webVROptions?: VRExperienceHelperOptions);
  105165. private _onDefaultMeshLoaded;
  105166. private _onResize;
  105167. private _onFullscreenChange;
  105168. /**
  105169. * Gets a value indicating if we are currently in VR mode.
  105170. */
  105171. readonly isInVRMode: boolean;
  105172. private onVrDisplayPresentChange;
  105173. private onVRDisplayChanged;
  105174. private moveButtonToBottomRight;
  105175. private displayVRButton;
  105176. private updateButtonVisibility;
  105177. private _cachedAngularSensibility;
  105178. /**
  105179. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  105180. * Otherwise, will use the fullscreen API.
  105181. */
  105182. enterVR(): void;
  105183. /**
  105184. * Attempt to exit VR, or fullscreen.
  105185. */
  105186. exitVR(): void;
  105187. /**
  105188. * The position of the vr experience helper.
  105189. */
  105190. /**
  105191. * Sets the position of the vr experience helper.
  105192. */
  105193. position: Vector3;
  105194. /**
  105195. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  105196. */
  105197. enableInteractions(): void;
  105198. private readonly _noControllerIsActive;
  105199. private beforeRender;
  105200. private _isTeleportationFloor;
  105201. /**
  105202. * Adds a floor mesh to be used for teleportation.
  105203. * @param floorMesh the mesh to be used for teleportation.
  105204. */
  105205. addFloorMesh(floorMesh: Mesh): void;
  105206. /**
  105207. * Removes a floor mesh from being used for teleportation.
  105208. * @param floorMesh the mesh to be removed.
  105209. */
  105210. removeFloorMesh(floorMesh: Mesh): void;
  105211. /**
  105212. * Enables interactions and teleportation using the VR controllers and gaze.
  105213. * @param vrTeleportationOptions options to modify teleportation behavior.
  105214. */
  105215. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  105216. private _onNewGamepadConnected;
  105217. private _tryEnableInteractionOnController;
  105218. private _onNewGamepadDisconnected;
  105219. private _enableInteractionOnController;
  105220. private _checkTeleportWithRay;
  105221. private _checkRotate;
  105222. private _checkTeleportBackwards;
  105223. private _enableTeleportationOnController;
  105224. private _createTeleportationCircles;
  105225. private _displayTeleportationTarget;
  105226. private _hideTeleportationTarget;
  105227. private _rotateCamera;
  105228. private _moveTeleportationSelectorTo;
  105229. private _workingVector;
  105230. private _workingQuaternion;
  105231. private _workingMatrix;
  105232. /**
  105233. * Teleports the users feet to the desired location
  105234. * @param location The location where the user's feet should be placed
  105235. */
  105236. teleportCamera(location: Vector3): void;
  105237. private _convertNormalToDirectionOfRay;
  105238. private _castRayAndSelectObject;
  105239. private _notifySelectedMeshUnselected;
  105240. /**
  105241. * Sets the color of the laser ray from the vr controllers.
  105242. * @param color new color for the ray.
  105243. */
  105244. changeLaserColor(color: Color3): void;
  105245. /**
  105246. * Sets the color of the ray from the vr headsets gaze.
  105247. * @param color new color for the ray.
  105248. */
  105249. changeGazeColor(color: Color3): void;
  105250. /**
  105251. * Exits VR and disposes of the vr experience helper
  105252. */
  105253. dispose(): void;
  105254. /**
  105255. * Gets the name of the VRExperienceHelper class
  105256. * @returns "VRExperienceHelper"
  105257. */
  105258. getClassName(): string;
  105259. }
  105260. }
  105261. declare module BABYLON {
  105262. /**
  105263. * Manages an XRSession to work with Babylon's engine
  105264. * @see https://doc.babylonjs.com/how_to/webxr
  105265. */
  105266. export class WebXRSessionManager implements IDisposable {
  105267. private scene;
  105268. /**
  105269. * Fires every time a new xrFrame arrives which can be used to update the camera
  105270. */
  105271. onXRFrameObservable: Observable<any>;
  105272. /**
  105273. * Fires when the xr session is ended either by the device or manually done
  105274. */
  105275. onXRSessionEnded: Observable<any>;
  105276. /**
  105277. * Underlying xr session
  105278. */
  105279. session: XRSession;
  105280. /**
  105281. * Type of reference space used when creating the session
  105282. */
  105283. referenceSpace: XRReferenceSpace;
  105284. /** @hidden */
  105285. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  105286. /**
  105287. * Current XR frame
  105288. */
  105289. currentFrame: Nullable<XRFrame>;
  105290. private _xrNavigator;
  105291. private baseLayer;
  105292. /**
  105293. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  105294. * @param scene The scene which the session should be created for
  105295. */
  105296. constructor(scene: Scene);
  105297. /**
  105298. * Initializes the manager
  105299. * After initialization enterXR can be called to start an XR session
  105300. * @returns Promise which resolves after it is initialized
  105301. */
  105302. initializeAsync(): Promise<void>;
  105303. /**
  105304. * Initializes an xr session
  105305. * @param xrSessionMode mode to initialize
  105306. * @returns a promise which will resolve once the session has been initialized
  105307. */
  105308. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  105309. /**
  105310. * Sets the reference space on the xr session
  105311. * @param referenceSpace space to set
  105312. * @returns a promise that will resolve once the reference space has been set
  105313. */
  105314. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  105315. /**
  105316. * Updates the render state of the session
  105317. * @param state state to set
  105318. * @returns a promise that resolves once the render state has been updated
  105319. */
  105320. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  105321. /**
  105322. * Starts rendering to the xr layer
  105323. * @returns a promise that will resolve once rendering has started
  105324. */
  105325. startRenderingToXRAsync(): Promise<void>;
  105326. /**
  105327. * Stops the xrSession and restores the renderloop
  105328. * @returns Promise which resolves after it exits XR
  105329. */
  105330. exitXRAsync(): Promise<unknown>;
  105331. /**
  105332. * Checks if a session would be supported for the creation options specified
  105333. * @param sessionMode session mode to check if supported eg. immersive-vr
  105334. * @returns true if supported
  105335. */
  105336. supportsSessionAsync(sessionMode: XRSessionMode): any;
  105337. /**
  105338. * @hidden
  105339. * Converts the render layer of xrSession to a render target
  105340. * @param session session to create render target for
  105341. * @param scene scene the new render target should be created for
  105342. */
  105343. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  105344. /**
  105345. * Disposes of the session manager
  105346. */
  105347. dispose(): void;
  105348. }
  105349. }
  105350. declare module BABYLON {
  105351. /**
  105352. * WebXR Camera which holds the views for the xrSession
  105353. * @see https://doc.babylonjs.com/how_to/webxr
  105354. */
  105355. export class WebXRCamera extends FreeCamera {
  105356. private static _TmpMatrix;
  105357. /**
  105358. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  105359. * @param name the name of the camera
  105360. * @param scene the scene to add the camera to
  105361. */
  105362. constructor(name: string, scene: Scene);
  105363. private _updateNumberOfRigCameras;
  105364. /** @hidden */
  105365. _updateForDualEyeDebugging(pupilDistance?: number): void;
  105366. /**
  105367. * Updates the cameras position from the current pose information of the XR session
  105368. * @param xrSessionManager the session containing pose information
  105369. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  105370. */
  105371. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  105372. }
  105373. }
  105374. declare module BABYLON {
  105375. /**
  105376. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  105377. */
  105378. export class WebXRManagedOutputCanvas implements IDisposable {
  105379. private helper;
  105380. private _canvas;
  105381. /**
  105382. * xrpresent context of the canvas which can be used to display/mirror xr content
  105383. */
  105384. canvasContext: WebGLRenderingContext;
  105385. /**
  105386. * xr layer for the canvas
  105387. */
  105388. xrLayer: Nullable<XRWebGLLayer>;
  105389. /**
  105390. * Initializes the xr layer for the session
  105391. * @param xrSession xr session
  105392. * @returns a promise that will resolve once the XR Layer has been created
  105393. */
  105394. initializeXRLayerAsync(xrSession: any): any;
  105395. /**
  105396. * Initializes the canvas to be added/removed upon entering/exiting xr
  105397. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  105398. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  105399. */
  105400. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  105401. /**
  105402. * Disposes of the object
  105403. */
  105404. dispose(): void;
  105405. private _setManagedOutputCanvas;
  105406. private _addCanvas;
  105407. private _removeCanvas;
  105408. }
  105409. }
  105410. declare module BABYLON {
  105411. /**
  105412. * States of the webXR experience
  105413. */
  105414. export enum WebXRState {
  105415. /**
  105416. * Transitioning to being in XR mode
  105417. */
  105418. ENTERING_XR = 0,
  105419. /**
  105420. * Transitioning to non XR mode
  105421. */
  105422. EXITING_XR = 1,
  105423. /**
  105424. * In XR mode and presenting
  105425. */
  105426. IN_XR = 2,
  105427. /**
  105428. * Not entered XR mode
  105429. */
  105430. NOT_IN_XR = 3
  105431. }
  105432. /**
  105433. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  105434. * @see https://doc.babylonjs.com/how_to/webxr
  105435. */
  105436. export class WebXRExperienceHelper implements IDisposable {
  105437. private scene;
  105438. /**
  105439. * 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
  105440. */
  105441. container: AbstractMesh;
  105442. /**
  105443. * Camera used to render xr content
  105444. */
  105445. camera: WebXRCamera;
  105446. /**
  105447. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  105448. */
  105449. state: WebXRState;
  105450. private _setState;
  105451. private static _TmpVector;
  105452. /**
  105453. * Fires when the state of the experience helper has changed
  105454. */
  105455. onStateChangedObservable: Observable<WebXRState>;
  105456. /** Session manager used to keep track of xr session */
  105457. sessionManager: WebXRSessionManager;
  105458. private _nonVRCamera;
  105459. private _originalSceneAutoClear;
  105460. private _supported;
  105461. /**
  105462. * Creates the experience helper
  105463. * @param scene the scene to attach the experience helper to
  105464. * @returns a promise for the experience helper
  105465. */
  105466. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  105467. /**
  105468. * Creates a WebXRExperienceHelper
  105469. * @param scene The scene the helper should be created in
  105470. */
  105471. private constructor();
  105472. /**
  105473. * Exits XR mode and returns the scene to its original state
  105474. * @returns promise that resolves after xr mode has exited
  105475. */
  105476. exitXRAsync(): Promise<unknown>;
  105477. /**
  105478. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  105479. * @param sessionCreationOptions options for the XR session
  105480. * @param referenceSpaceType frame of reference of the XR session
  105481. * @param outputCanvas the output canvas that will be used to enter XR mode
  105482. * @returns promise that resolves after xr mode has entered
  105483. */
  105484. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  105485. /**
  105486. * Updates the global position of the camera by moving the camera's container
  105487. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  105488. * @param position The desired global position of the camera
  105489. */
  105490. setPositionOfCameraUsingContainer(position: Vector3): void;
  105491. /**
  105492. * Rotates the xr camera by rotating the camera's container around the camera's position
  105493. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  105494. * @param rotation the desired quaternion rotation to apply to the camera
  105495. */
  105496. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  105497. /**
  105498. * Disposes of the experience helper
  105499. */
  105500. dispose(): void;
  105501. }
  105502. }
  105503. declare module BABYLON {
  105504. /**
  105505. * Button which can be used to enter a different mode of XR
  105506. */
  105507. export class WebXREnterExitUIButton {
  105508. /** button element */
  105509. element: HTMLElement;
  105510. /** XR initialization options for the button */
  105511. sessionMode: XRSessionMode;
  105512. /** Reference space type */
  105513. referenceSpaceType: XRReferenceSpaceType;
  105514. /**
  105515. * Creates a WebXREnterExitUIButton
  105516. * @param element button element
  105517. * @param sessionMode XR initialization session mode
  105518. * @param referenceSpaceType the type of reference space to be used
  105519. */
  105520. constructor(
  105521. /** button element */
  105522. element: HTMLElement,
  105523. /** XR initialization options for the button */
  105524. sessionMode: XRSessionMode,
  105525. /** Reference space type */
  105526. referenceSpaceType: XRReferenceSpaceType);
  105527. /**
  105528. * Overwritable function which can be used to update the button's visuals when the state changes
  105529. * @param activeButton the current active button in the UI
  105530. */
  105531. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  105532. }
  105533. /**
  105534. * Options to create the webXR UI
  105535. */
  105536. export class WebXREnterExitUIOptions {
  105537. /**
  105538. * Context to enter xr with
  105539. */
  105540. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  105541. /**
  105542. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  105543. */
  105544. customButtons?: Array<WebXREnterExitUIButton>;
  105545. }
  105546. /**
  105547. * UI to allow the user to enter/exit XR mode
  105548. */
  105549. export class WebXREnterExitUI implements IDisposable {
  105550. private scene;
  105551. private _overlay;
  105552. private _buttons;
  105553. private _activeButton;
  105554. /**
  105555. * Fired every time the active button is changed.
  105556. *
  105557. * When xr is entered via a button that launches xr that button will be the callback parameter
  105558. *
  105559. * When exiting xr the callback parameter will be null)
  105560. */
  105561. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  105562. /**
  105563. * Creates UI to allow the user to enter/exit XR mode
  105564. * @param scene the scene to add the ui to
  105565. * @param helper the xr experience helper to enter/exit xr with
  105566. * @param options options to configure the UI
  105567. * @returns the created ui
  105568. */
  105569. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  105570. private constructor();
  105571. private _updateButtons;
  105572. /**
  105573. * Disposes of the object
  105574. */
  105575. dispose(): void;
  105576. }
  105577. }
  105578. declare module BABYLON {
  105579. /**
  105580. * Represents an XR input
  105581. */
  105582. export class WebXRController {
  105583. private scene;
  105584. /** The underlying input source for the controller */
  105585. inputSource: XRInputSource;
  105586. private parentContainer;
  105587. /**
  105588. * 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
  105589. */
  105590. grip?: AbstractMesh;
  105591. /**
  105592. * Pointer which can be used to select objects or attach a visible laser to
  105593. */
  105594. pointer: AbstractMesh;
  105595. /**
  105596. * Event that fires when the controller is removed/disposed
  105597. */
  105598. onDisposeObservable: Observable<{}>;
  105599. private _tmpMatrix;
  105600. private _tmpQuaternion;
  105601. private _tmpVector;
  105602. /**
  105603. * Creates the controller
  105604. * @see https://doc.babylonjs.com/how_to/webxr
  105605. * @param scene the scene which the controller should be associated to
  105606. * @param inputSource the underlying input source for the controller
  105607. * @param parentContainer parent that the controller meshes should be children of
  105608. */
  105609. constructor(scene: Scene,
  105610. /** The underlying input source for the controller */
  105611. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105612. /**
  105613. * Updates the controller pose based on the given XRFrame
  105614. * @param xrFrame xr frame to update the pose with
  105615. * @param referenceSpace reference space to use
  105616. */
  105617. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105618. /**
  105619. * Gets a world space ray coming from the controller
  105620. * @param result the resulting ray
  105621. */
  105622. getWorldPointerRayToRef(result: Ray): void;
  105623. /**
  105624. * Disposes of the object
  105625. */
  105626. dispose(): void;
  105627. }
  105628. }
  105629. declare module BABYLON {
  105630. /**
  105631. * XR input used to track XR inputs such as controllers/rays
  105632. */
  105633. export class WebXRInput implements IDisposable {
  105634. /**
  105635. * Base experience the input listens to
  105636. */
  105637. baseExperience: WebXRExperienceHelper;
  105638. /**
  105639. * XR controllers being tracked
  105640. */
  105641. controllers: Array<WebXRController>;
  105642. private _frameObserver;
  105643. private _stateObserver;
  105644. /**
  105645. * Event when a controller has been connected/added
  105646. */
  105647. onControllerAddedObservable: Observable<WebXRController>;
  105648. /**
  105649. * Event when a controller has been removed/disconnected
  105650. */
  105651. onControllerRemovedObservable: Observable<WebXRController>;
  105652. /**
  105653. * Initializes the WebXRInput
  105654. * @param baseExperience experience helper which the input should be created for
  105655. */
  105656. constructor(
  105657. /**
  105658. * Base experience the input listens to
  105659. */
  105660. baseExperience: WebXRExperienceHelper);
  105661. private _onInputSourcesChange;
  105662. private _addAndRemoveControllers;
  105663. /**
  105664. * Disposes of the object
  105665. */
  105666. dispose(): void;
  105667. }
  105668. }
  105669. declare module BABYLON {
  105670. /**
  105671. * Enables teleportation
  105672. */
  105673. export class WebXRControllerTeleportation {
  105674. private _teleportationFillColor;
  105675. private _teleportationBorderColor;
  105676. private _tmpRay;
  105677. private _tmpVector;
  105678. /**
  105679. * Creates a WebXRControllerTeleportation
  105680. * @param input input manager to add teleportation to
  105681. * @param floorMeshes floormeshes which can be teleported to
  105682. */
  105683. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  105684. }
  105685. }
  105686. declare module BABYLON {
  105687. /**
  105688. * Handles pointer input automatically for the pointer of XR controllers
  105689. */
  105690. export class WebXRControllerPointerSelection {
  105691. private static _idCounter;
  105692. private _tmpRay;
  105693. /**
  105694. * Creates a WebXRControllerPointerSelection
  105695. * @param input input manager to setup pointer selection
  105696. */
  105697. constructor(input: WebXRInput);
  105698. private _convertNormalToDirectionOfRay;
  105699. private _updatePointerDistance;
  105700. }
  105701. }
  105702. declare module BABYLON {
  105703. /**
  105704. * Class used to represent data loading progression
  105705. */
  105706. export class SceneLoaderProgressEvent {
  105707. /** defines if data length to load can be evaluated */
  105708. readonly lengthComputable: boolean;
  105709. /** defines the loaded data length */
  105710. readonly loaded: number;
  105711. /** defines the data length to load */
  105712. readonly total: number;
  105713. /**
  105714. * Create a new progress event
  105715. * @param lengthComputable defines if data length to load can be evaluated
  105716. * @param loaded defines the loaded data length
  105717. * @param total defines the data length to load
  105718. */
  105719. constructor(
  105720. /** defines if data length to load can be evaluated */
  105721. lengthComputable: boolean,
  105722. /** defines the loaded data length */
  105723. loaded: number,
  105724. /** defines the data length to load */
  105725. total: number);
  105726. /**
  105727. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105728. * @param event defines the source event
  105729. * @returns a new SceneLoaderProgressEvent
  105730. */
  105731. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105732. }
  105733. /**
  105734. * Interface used by SceneLoader plugins to define supported file extensions
  105735. */
  105736. export interface ISceneLoaderPluginExtensions {
  105737. /**
  105738. * Defines the list of supported extensions
  105739. */
  105740. [extension: string]: {
  105741. isBinary: boolean;
  105742. };
  105743. }
  105744. /**
  105745. * Interface used by SceneLoader plugin factory
  105746. */
  105747. export interface ISceneLoaderPluginFactory {
  105748. /**
  105749. * Defines the name of the factory
  105750. */
  105751. name: string;
  105752. /**
  105753. * Function called to create a new plugin
  105754. * @return the new plugin
  105755. */
  105756. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105757. /**
  105758. * Boolean indicating if the plugin can direct load specific data
  105759. */
  105760. canDirectLoad?: (data: string) => boolean;
  105761. }
  105762. /**
  105763. * Interface used to define a SceneLoader plugin
  105764. */
  105765. export interface ISceneLoaderPlugin {
  105766. /**
  105767. * The friendly name of this plugin.
  105768. */
  105769. name: string;
  105770. /**
  105771. * The file extensions supported by this plugin.
  105772. */
  105773. extensions: string | ISceneLoaderPluginExtensions;
  105774. /**
  105775. * Import meshes into a scene.
  105776. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105777. * @param scene The scene to import into
  105778. * @param data The data to import
  105779. * @param rootUrl The root url for scene and resources
  105780. * @param meshes The meshes array to import into
  105781. * @param particleSystems The particle systems array to import into
  105782. * @param skeletons The skeletons array to import into
  105783. * @param onError The callback when import fails
  105784. * @returns True if successful or false otherwise
  105785. */
  105786. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105787. /**
  105788. * Load into a scene.
  105789. * @param scene The scene to load into
  105790. * @param data The data to import
  105791. * @param rootUrl The root url for scene and resources
  105792. * @param onError The callback when import fails
  105793. * @returns true if successful or false otherwise
  105794. */
  105795. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105796. /**
  105797. * The callback that returns true if the data can be directly loaded.
  105798. */
  105799. canDirectLoad?: (data: string) => boolean;
  105800. /**
  105801. * The callback that allows custom handling of the root url based on the response url.
  105802. */
  105803. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105804. /**
  105805. * Load into an asset container.
  105806. * @param scene The scene to load into
  105807. * @param data The data to import
  105808. * @param rootUrl The root url for scene and resources
  105809. * @param onError The callback when import fails
  105810. * @returns The loaded asset container
  105811. */
  105812. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105813. }
  105814. /**
  105815. * Interface used to define an async SceneLoader plugin
  105816. */
  105817. export interface ISceneLoaderPluginAsync {
  105818. /**
  105819. * The friendly name of this plugin.
  105820. */
  105821. name: string;
  105822. /**
  105823. * The file extensions supported by this plugin.
  105824. */
  105825. extensions: string | ISceneLoaderPluginExtensions;
  105826. /**
  105827. * Import meshes into a scene.
  105828. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105829. * @param scene The scene to import into
  105830. * @param data The data to import
  105831. * @param rootUrl The root url for scene and resources
  105832. * @param onProgress The callback when the load progresses
  105833. * @param fileName Defines the name of the file to load
  105834. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105835. */
  105836. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105837. meshes: AbstractMesh[];
  105838. particleSystems: IParticleSystem[];
  105839. skeletons: Skeleton[];
  105840. animationGroups: AnimationGroup[];
  105841. }>;
  105842. /**
  105843. * Load into a scene.
  105844. * @param scene The scene to load into
  105845. * @param data The data to import
  105846. * @param rootUrl The root url for scene and resources
  105847. * @param onProgress The callback when the load progresses
  105848. * @param fileName Defines the name of the file to load
  105849. * @returns Nothing
  105850. */
  105851. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105852. /**
  105853. * The callback that returns true if the data can be directly loaded.
  105854. */
  105855. canDirectLoad?: (data: string) => boolean;
  105856. /**
  105857. * The callback that allows custom handling of the root url based on the response url.
  105858. */
  105859. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105860. /**
  105861. * Load into an asset container.
  105862. * @param scene The scene to load into
  105863. * @param data The data to import
  105864. * @param rootUrl The root url for scene and resources
  105865. * @param onProgress The callback when the load progresses
  105866. * @param fileName Defines the name of the file to load
  105867. * @returns The loaded asset container
  105868. */
  105869. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105870. }
  105871. /**
  105872. * Class used to load scene from various file formats using registered plugins
  105873. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105874. */
  105875. export class SceneLoader {
  105876. /**
  105877. * No logging while loading
  105878. */
  105879. static readonly NO_LOGGING: number;
  105880. /**
  105881. * Minimal logging while loading
  105882. */
  105883. static readonly MINIMAL_LOGGING: number;
  105884. /**
  105885. * Summary logging while loading
  105886. */
  105887. static readonly SUMMARY_LOGGING: number;
  105888. /**
  105889. * Detailled logging while loading
  105890. */
  105891. static readonly DETAILED_LOGGING: number;
  105892. /**
  105893. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105894. */
  105895. static ForceFullSceneLoadingForIncremental: boolean;
  105896. /**
  105897. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105898. */
  105899. static ShowLoadingScreen: boolean;
  105900. /**
  105901. * Defines the current logging level (while loading the scene)
  105902. * @ignorenaming
  105903. */
  105904. static loggingLevel: number;
  105905. /**
  105906. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105907. */
  105908. static CleanBoneMatrixWeights: boolean;
  105909. /**
  105910. * Event raised when a plugin is used to load a scene
  105911. */
  105912. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105913. private static _registeredPlugins;
  105914. private static _getDefaultPlugin;
  105915. private static _getPluginForExtension;
  105916. private static _getPluginForDirectLoad;
  105917. private static _getPluginForFilename;
  105918. private static _getDirectLoad;
  105919. private static _loadData;
  105920. private static _getFileInfo;
  105921. /**
  105922. * Gets a plugin that can load the given extension
  105923. * @param extension defines the extension to load
  105924. * @returns a plugin or null if none works
  105925. */
  105926. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105927. /**
  105928. * Gets a boolean indicating that the given extension can be loaded
  105929. * @param extension defines the extension to load
  105930. * @returns true if the extension is supported
  105931. */
  105932. static IsPluginForExtensionAvailable(extension: string): boolean;
  105933. /**
  105934. * Adds a new plugin to the list of registered plugins
  105935. * @param plugin defines the plugin to add
  105936. */
  105937. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105938. /**
  105939. * Import meshes into a scene
  105940. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105941. * @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)
  105942. * @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)
  105943. * @param scene the instance of BABYLON.Scene to append to
  105944. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105945. * @param onProgress a callback with a progress event for each file being loaded
  105946. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105947. * @param pluginExtension the extension used to determine the plugin
  105948. * @returns The loaded plugin
  105949. */
  105950. 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>;
  105951. /**
  105952. * Import meshes into a scene
  105953. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105954. * @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)
  105955. * @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)
  105956. * @param scene the instance of BABYLON.Scene to append to
  105957. * @param onProgress a callback with a progress event for each file being loaded
  105958. * @param pluginExtension the extension used to determine the plugin
  105959. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105960. */
  105961. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105962. meshes: AbstractMesh[];
  105963. particleSystems: IParticleSystem[];
  105964. skeletons: Skeleton[];
  105965. animationGroups: AnimationGroup[];
  105966. }>;
  105967. /**
  105968. * Load a scene
  105969. * @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)
  105970. * @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)
  105971. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105972. * @param onSuccess a callback with the scene when import succeeds
  105973. * @param onProgress a callback with a progress event for each file being loaded
  105974. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105975. * @param pluginExtension the extension used to determine the plugin
  105976. * @returns The loaded plugin
  105977. */
  105978. 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>;
  105979. /**
  105980. * Load a scene
  105981. * @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)
  105982. * @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)
  105983. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105984. * @param onProgress a callback with a progress event for each file being loaded
  105985. * @param pluginExtension the extension used to determine the plugin
  105986. * @returns The loaded scene
  105987. */
  105988. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105989. /**
  105990. * Append a scene
  105991. * @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)
  105992. * @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)
  105993. * @param scene is the instance of BABYLON.Scene to append to
  105994. * @param onSuccess a callback with the scene when import succeeds
  105995. * @param onProgress a callback with a progress event for each file being loaded
  105996. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105997. * @param pluginExtension the extension used to determine the plugin
  105998. * @returns The loaded plugin
  105999. */
  106000. 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>;
  106001. /**
  106002. * Append a scene
  106003. * @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)
  106004. * @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)
  106005. * @param scene is the instance of BABYLON.Scene to append to
  106006. * @param onProgress a callback with a progress event for each file being loaded
  106007. * @param pluginExtension the extension used to determine the plugin
  106008. * @returns The given scene
  106009. */
  106010. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  106011. /**
  106012. * Load a scene into an asset container
  106013. * @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)
  106014. * @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)
  106015. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  106016. * @param onSuccess a callback with the scene when import succeeds
  106017. * @param onProgress a callback with a progress event for each file being loaded
  106018. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  106019. * @param pluginExtension the extension used to determine the plugin
  106020. * @returns The loaded plugin
  106021. */
  106022. 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>;
  106023. /**
  106024. * Load a scene into an asset container
  106025. * @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)
  106026. * @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)
  106027. * @param scene is the instance of Scene to append to
  106028. * @param onProgress a callback with a progress event for each file being loaded
  106029. * @param pluginExtension the extension used to determine the plugin
  106030. * @returns The loaded asset container
  106031. */
  106032. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /**
  106037. * Generic Controller
  106038. */
  106039. export class GenericController extends WebVRController {
  106040. /**
  106041. * Base Url for the controller model.
  106042. */
  106043. static readonly MODEL_BASE_URL: string;
  106044. /**
  106045. * File name for the controller model.
  106046. */
  106047. static readonly MODEL_FILENAME: string;
  106048. /**
  106049. * Creates a new GenericController from a gamepad
  106050. * @param vrGamepad the gamepad that the controller should be created from
  106051. */
  106052. constructor(vrGamepad: any);
  106053. /**
  106054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106055. * @param scene scene in which to add meshes
  106056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106057. */
  106058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106059. /**
  106060. * Called once for each button that changed state since the last frame
  106061. * @param buttonIdx Which button index changed
  106062. * @param state New state of the button
  106063. * @param changes Which properties on the state changed since last frame
  106064. */
  106065. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106066. }
  106067. }
  106068. declare module BABYLON {
  106069. /**
  106070. * Defines the WindowsMotionController object that the state of the windows motion controller
  106071. */
  106072. export class WindowsMotionController extends WebVRController {
  106073. /**
  106074. * The base url used to load the left and right controller models
  106075. */
  106076. static MODEL_BASE_URL: string;
  106077. /**
  106078. * The name of the left controller model file
  106079. */
  106080. static MODEL_LEFT_FILENAME: string;
  106081. /**
  106082. * The name of the right controller model file
  106083. */
  106084. static MODEL_RIGHT_FILENAME: string;
  106085. /**
  106086. * The controller name prefix for this controller type
  106087. */
  106088. static readonly GAMEPAD_ID_PREFIX: string;
  106089. /**
  106090. * The controller id pattern for this controller type
  106091. */
  106092. private static readonly GAMEPAD_ID_PATTERN;
  106093. private _loadedMeshInfo;
  106094. private readonly _mapping;
  106095. /**
  106096. * Fired when the trackpad on this controller is clicked
  106097. */
  106098. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  106099. /**
  106100. * Fired when the trackpad on this controller is modified
  106101. */
  106102. onTrackpadValuesChangedObservable: Observable<StickValues>;
  106103. /**
  106104. * The current x and y values of this controller's trackpad
  106105. */
  106106. trackpad: StickValues;
  106107. /**
  106108. * Creates a new WindowsMotionController from a gamepad
  106109. * @param vrGamepad the gamepad that the controller should be created from
  106110. */
  106111. constructor(vrGamepad: any);
  106112. /**
  106113. * Fired when the trigger on this controller is modified
  106114. */
  106115. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106116. /**
  106117. * Fired when the menu button on this controller is modified
  106118. */
  106119. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106120. /**
  106121. * Fired when the grip button on this controller is modified
  106122. */
  106123. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106124. /**
  106125. * Fired when the thumbstick button on this controller is modified
  106126. */
  106127. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106128. /**
  106129. * Fired when the touchpad button on this controller is modified
  106130. */
  106131. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106132. /**
  106133. * Fired when the touchpad values on this controller are modified
  106134. */
  106135. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  106136. private _updateTrackpad;
  106137. /**
  106138. * Called once per frame by the engine.
  106139. */
  106140. update(): void;
  106141. /**
  106142. * Called once for each button that changed state since the last frame
  106143. * @param buttonIdx Which button index changed
  106144. * @param state New state of the button
  106145. * @param changes Which properties on the state changed since last frame
  106146. */
  106147. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106148. /**
  106149. * Moves the buttons on the controller mesh based on their current state
  106150. * @param buttonName the name of the button to move
  106151. * @param buttonValue the value of the button which determines the buttons new position
  106152. */
  106153. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  106154. /**
  106155. * Moves the axis on the controller mesh based on its current state
  106156. * @param axis the index of the axis
  106157. * @param axisValue the value of the axis which determines the meshes new position
  106158. * @hidden
  106159. */
  106160. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  106161. /**
  106162. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106163. * @param scene scene in which to add meshes
  106164. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106165. */
  106166. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  106167. /**
  106168. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  106169. * can be transformed by button presses and axes values, based on this._mapping.
  106170. *
  106171. * @param scene scene in which the meshes exist
  106172. * @param meshes list of meshes that make up the controller model to process
  106173. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  106174. */
  106175. private processModel;
  106176. private createMeshInfo;
  106177. /**
  106178. * Gets the ray of the controller in the direction the controller is pointing
  106179. * @param length the length the resulting ray should be
  106180. * @returns a ray in the direction the controller is pointing
  106181. */
  106182. getForwardRay(length?: number): Ray;
  106183. /**
  106184. * Disposes of the controller
  106185. */
  106186. dispose(): void;
  106187. }
  106188. }
  106189. declare module BABYLON {
  106190. /**
  106191. * Oculus Touch Controller
  106192. */
  106193. export class OculusTouchController extends WebVRController {
  106194. /**
  106195. * Base Url for the controller model.
  106196. */
  106197. static MODEL_BASE_URL: string;
  106198. /**
  106199. * File name for the left controller model.
  106200. */
  106201. static MODEL_LEFT_FILENAME: string;
  106202. /**
  106203. * File name for the right controller model.
  106204. */
  106205. static MODEL_RIGHT_FILENAME: string;
  106206. /**
  106207. * Base Url for the Quest controller model.
  106208. */
  106209. static QUEST_MODEL_BASE_URL: string;
  106210. /**
  106211. * @hidden
  106212. * If the controllers are running on a device that needs the updated Quest controller models
  106213. */
  106214. static _IsQuest: boolean;
  106215. /**
  106216. * Fired when the secondary trigger on this controller is modified
  106217. */
  106218. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  106219. /**
  106220. * Fired when the thumb rest on this controller is modified
  106221. */
  106222. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  106223. /**
  106224. * Creates a new OculusTouchController from a gamepad
  106225. * @param vrGamepad the gamepad that the controller should be created from
  106226. */
  106227. constructor(vrGamepad: any);
  106228. /**
  106229. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106230. * @param scene scene in which to add meshes
  106231. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106232. */
  106233. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106234. /**
  106235. * Fired when the A button on this controller is modified
  106236. */
  106237. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106238. /**
  106239. * Fired when the B button on this controller is modified
  106240. */
  106241. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106242. /**
  106243. * Fired when the X button on this controller is modified
  106244. */
  106245. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106246. /**
  106247. * Fired when the Y button on this controller is modified
  106248. */
  106249. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106250. /**
  106251. * Called once for each button that changed state since the last frame
  106252. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  106253. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  106254. * 2) secondary trigger (same)
  106255. * 3) A (right) X (left), touch, pressed = value
  106256. * 4) B / Y
  106257. * 5) thumb rest
  106258. * @param buttonIdx Which button index changed
  106259. * @param state New state of the button
  106260. * @param changes Which properties on the state changed since last frame
  106261. */
  106262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106263. }
  106264. }
  106265. declare module BABYLON {
  106266. /**
  106267. * Vive Controller
  106268. */
  106269. export class ViveController extends WebVRController {
  106270. /**
  106271. * Base Url for the controller model.
  106272. */
  106273. static MODEL_BASE_URL: string;
  106274. /**
  106275. * File name for the controller model.
  106276. */
  106277. static MODEL_FILENAME: string;
  106278. /**
  106279. * Creates a new ViveController from a gamepad
  106280. * @param vrGamepad the gamepad that the controller should be created from
  106281. */
  106282. constructor(vrGamepad: any);
  106283. /**
  106284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  106285. * @param scene scene in which to add meshes
  106286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  106287. */
  106288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  106289. /**
  106290. * Fired when the left button on this controller is modified
  106291. */
  106292. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106293. /**
  106294. * Fired when the right button on this controller is modified
  106295. */
  106296. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106297. /**
  106298. * Fired when the menu button on this controller is modified
  106299. */
  106300. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  106301. /**
  106302. * Called once for each button that changed state since the last frame
  106303. * Vive mapping:
  106304. * 0: touchpad
  106305. * 1: trigger
  106306. * 2: left AND right buttons
  106307. * 3: menu button
  106308. * @param buttonIdx Which button index changed
  106309. * @param state New state of the button
  106310. * @param changes Which properties on the state changed since last frame
  106311. */
  106312. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  106313. }
  106314. }
  106315. declare module BABYLON {
  106316. /**
  106317. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  106318. */
  106319. export class WebXRControllerModelLoader {
  106320. /**
  106321. * Creates the WebXRControllerModelLoader
  106322. * @param input xr input that creates the controllers
  106323. */
  106324. constructor(input: WebXRInput);
  106325. }
  106326. }
  106327. declare module BABYLON {
  106328. /**
  106329. * Contains an array of blocks representing the octree
  106330. */
  106331. export interface IOctreeContainer<T> {
  106332. /**
  106333. * Blocks within the octree
  106334. */
  106335. blocks: Array<OctreeBlock<T>>;
  106336. }
  106337. /**
  106338. * Class used to store a cell in an octree
  106339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106340. */
  106341. export class OctreeBlock<T> {
  106342. /**
  106343. * Gets the content of the current block
  106344. */
  106345. entries: T[];
  106346. /**
  106347. * Gets the list of block children
  106348. */
  106349. blocks: Array<OctreeBlock<T>>;
  106350. private _depth;
  106351. private _maxDepth;
  106352. private _capacity;
  106353. private _minPoint;
  106354. private _maxPoint;
  106355. private _boundingVectors;
  106356. private _creationFunc;
  106357. /**
  106358. * Creates a new block
  106359. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  106360. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  106361. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106362. * @param depth defines the current depth of this block in the octree
  106363. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  106364. * @param creationFunc defines a callback to call when an element is added to the block
  106365. */
  106366. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  106367. /**
  106368. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  106369. */
  106370. readonly capacity: number;
  106371. /**
  106372. * Gets the minimum vector (in world space) of the block's bounding box
  106373. */
  106374. readonly minPoint: Vector3;
  106375. /**
  106376. * Gets the maximum vector (in world space) of the block's bounding box
  106377. */
  106378. readonly maxPoint: Vector3;
  106379. /**
  106380. * Add a new element to this block
  106381. * @param entry defines the element to add
  106382. */
  106383. addEntry(entry: T): void;
  106384. /**
  106385. * Remove an element from this block
  106386. * @param entry defines the element to remove
  106387. */
  106388. removeEntry(entry: T): void;
  106389. /**
  106390. * Add an array of elements to this block
  106391. * @param entries defines the array of elements to add
  106392. */
  106393. addEntries(entries: T[]): void;
  106394. /**
  106395. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  106396. * @param frustumPlanes defines the frustum planes to test
  106397. * @param selection defines the array to store current content if selection is positive
  106398. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106399. */
  106400. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106401. /**
  106402. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  106403. * @param sphereCenter defines the bounding sphere center
  106404. * @param sphereRadius defines the bounding sphere radius
  106405. * @param selection defines the array to store current content if selection is positive
  106406. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106407. */
  106408. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  106409. /**
  106410. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  106411. * @param ray defines the ray to test with
  106412. * @param selection defines the array to store current content if selection is positive
  106413. */
  106414. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  106415. /**
  106416. * Subdivide the content into child blocks (this block will then be empty)
  106417. */
  106418. createInnerBlocks(): void;
  106419. /**
  106420. * @hidden
  106421. */
  106422. 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;
  106423. }
  106424. }
  106425. declare module BABYLON {
  106426. /**
  106427. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  106428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106429. */
  106430. export class Octree<T> {
  106431. /** 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.) */
  106432. maxDepth: number;
  106433. /**
  106434. * Blocks within the octree containing objects
  106435. */
  106436. blocks: Array<OctreeBlock<T>>;
  106437. /**
  106438. * Content stored in the octree
  106439. */
  106440. dynamicContent: T[];
  106441. private _maxBlockCapacity;
  106442. private _selectionContent;
  106443. private _creationFunc;
  106444. /**
  106445. * Creates a octree
  106446. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106447. * @param creationFunc function to be used to instatiate the octree
  106448. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  106449. * @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.)
  106450. */
  106451. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  106452. /** 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.) */
  106453. maxDepth?: number);
  106454. /**
  106455. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  106456. * @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);
  106457. * @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);
  106458. * @param entries meshes to be added to the octree blocks
  106459. */
  106460. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  106461. /**
  106462. * Adds a mesh to the octree
  106463. * @param entry Mesh to add to the octree
  106464. */
  106465. addMesh(entry: T): void;
  106466. /**
  106467. * Remove an element from the octree
  106468. * @param entry defines the element to remove
  106469. */
  106470. removeMesh(entry: T): void;
  106471. /**
  106472. * Selects an array of meshes within the frustum
  106473. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  106474. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  106475. * @returns array of meshes within the frustum
  106476. */
  106477. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  106478. /**
  106479. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  106480. * @param sphereCenter defines the bounding sphere center
  106481. * @param sphereRadius defines the bounding sphere radius
  106482. * @param allowDuplicate defines if the selection array can contains duplicated entries
  106483. * @returns an array of objects that intersect the sphere
  106484. */
  106485. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  106486. /**
  106487. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  106488. * @param ray defines the ray to test with
  106489. * @returns array of intersected objects
  106490. */
  106491. intersectsRay(ray: Ray): SmartArray<T>;
  106492. /**
  106493. * Adds a mesh into the octree block if it intersects the block
  106494. */
  106495. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  106496. /**
  106497. * Adds a submesh into the octree block if it intersects the block
  106498. */
  106499. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  106500. }
  106501. }
  106502. declare module BABYLON {
  106503. interface Scene {
  106504. /**
  106505. * @hidden
  106506. * Backing Filed
  106507. */
  106508. _selectionOctree: Octree<AbstractMesh>;
  106509. /**
  106510. * Gets the octree used to boost mesh selection (picking)
  106511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106512. */
  106513. selectionOctree: Octree<AbstractMesh>;
  106514. /**
  106515. * Creates or updates the octree used to boost selection (picking)
  106516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106517. * @param maxCapacity defines the maximum capacity per leaf
  106518. * @param maxDepth defines the maximum depth of the octree
  106519. * @returns an octree of AbstractMesh
  106520. */
  106521. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  106522. }
  106523. interface AbstractMesh {
  106524. /**
  106525. * @hidden
  106526. * Backing Field
  106527. */
  106528. _submeshesOctree: Octree<SubMesh>;
  106529. /**
  106530. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  106531. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106532. * @param maxCapacity defines the maximum size of each block (64 by default)
  106533. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  106534. * @returns the new octree
  106535. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  106536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  106537. */
  106538. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  106539. }
  106540. /**
  106541. * Defines the octree scene component responsible to manage any octrees
  106542. * in a given scene.
  106543. */
  106544. export class OctreeSceneComponent {
  106545. /**
  106546. * The component name help to identify the component in the list of scene components.
  106547. */
  106548. readonly name: string;
  106549. /**
  106550. * The scene the component belongs to.
  106551. */
  106552. scene: Scene;
  106553. /**
  106554. * Indicates if the meshes have been checked to make sure they are isEnabled()
  106555. */
  106556. readonly checksIsEnabled: boolean;
  106557. /**
  106558. * Creates a new instance of the component for the given scene
  106559. * @param scene Defines the scene to register the component in
  106560. */
  106561. constructor(scene: Scene);
  106562. /**
  106563. * Registers the component in a given scene
  106564. */
  106565. register(): void;
  106566. /**
  106567. * Return the list of active meshes
  106568. * @returns the list of active meshes
  106569. */
  106570. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  106571. /**
  106572. * Return the list of active sub meshes
  106573. * @param mesh The mesh to get the candidates sub meshes from
  106574. * @returns the list of active sub meshes
  106575. */
  106576. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  106577. private _tempRay;
  106578. /**
  106579. * Return the list of sub meshes intersecting with a given local ray
  106580. * @param mesh defines the mesh to find the submesh for
  106581. * @param localRay defines the ray in local space
  106582. * @returns the list of intersecting sub meshes
  106583. */
  106584. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  106585. /**
  106586. * Return the list of sub meshes colliding with a collider
  106587. * @param mesh defines the mesh to find the submesh for
  106588. * @param collider defines the collider to evaluate the collision against
  106589. * @returns the list of colliding sub meshes
  106590. */
  106591. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  106592. /**
  106593. * Rebuilds the elements related to this component in case of
  106594. * context lost for instance.
  106595. */
  106596. rebuild(): void;
  106597. /**
  106598. * Disposes the component and the associated ressources.
  106599. */
  106600. dispose(): void;
  106601. }
  106602. }
  106603. declare module BABYLON {
  106604. /**
  106605. * Renders a layer on top of an existing scene
  106606. */
  106607. export class UtilityLayerRenderer implements IDisposable {
  106608. /** the original scene that will be rendered on top of */
  106609. originalScene: Scene;
  106610. private _pointerCaptures;
  106611. private _lastPointerEvents;
  106612. private static _DefaultUtilityLayer;
  106613. private static _DefaultKeepDepthUtilityLayer;
  106614. private _sharedGizmoLight;
  106615. private _renderCamera;
  106616. /**
  106617. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106618. * @returns the camera that is used when rendering the utility layer
  106619. */
  106620. getRenderCamera(): Nullable<Camera>;
  106621. /**
  106622. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106623. * @param cam the camera that should be used when rendering the utility layer
  106624. */
  106625. setRenderCamera(cam: Nullable<Camera>): void;
  106626. /**
  106627. * @hidden
  106628. * Light which used by gizmos to get light shading
  106629. */
  106630. _getSharedGizmoLight(): HemisphericLight;
  106631. /**
  106632. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106633. */
  106634. pickUtilitySceneFirst: boolean;
  106635. /**
  106636. * 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)
  106637. */
  106638. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106639. /**
  106640. * 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)
  106641. */
  106642. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106643. /**
  106644. * The scene that is rendered on top of the original scene
  106645. */
  106646. utilityLayerScene: Scene;
  106647. /**
  106648. * If the utility layer should automatically be rendered on top of existing scene
  106649. */
  106650. shouldRender: boolean;
  106651. /**
  106652. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106653. */
  106654. onlyCheckPointerDownEvents: boolean;
  106655. /**
  106656. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  106657. */
  106658. processAllEvents: boolean;
  106659. /**
  106660. * Observable raised when the pointer move from the utility layer scene to the main scene
  106661. */
  106662. onPointerOutObservable: Observable<number>;
  106663. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  106664. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  106665. private _afterRenderObserver;
  106666. private _sceneDisposeObserver;
  106667. private _originalPointerObserver;
  106668. /**
  106669. * Instantiates a UtilityLayerRenderer
  106670. * @param originalScene the original scene that will be rendered on top of
  106671. * @param handleEvents boolean indicating if the utility layer should handle events
  106672. */
  106673. constructor(
  106674. /** the original scene that will be rendered on top of */
  106675. originalScene: Scene, handleEvents?: boolean);
  106676. private _notifyObservers;
  106677. /**
  106678. * Renders the utility layers scene on top of the original scene
  106679. */
  106680. render(): void;
  106681. /**
  106682. * Disposes of the renderer
  106683. */
  106684. dispose(): void;
  106685. private _updateCamera;
  106686. }
  106687. }
  106688. declare module BABYLON {
  106689. /**
  106690. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  106691. */
  106692. export class Gizmo implements IDisposable {
  106693. /** The utility layer the gizmo will be added to */
  106694. gizmoLayer: UtilityLayerRenderer;
  106695. /**
  106696. * The root mesh of the gizmo
  106697. */
  106698. _rootMesh: Mesh;
  106699. private _attachedMesh;
  106700. /**
  106701. * Ratio for the scale of the gizmo (Default: 1)
  106702. */
  106703. scaleRatio: number;
  106704. /**
  106705. * If a custom mesh has been set (Default: false)
  106706. */
  106707. protected _customMeshSet: boolean;
  106708. /**
  106709. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  106710. * * When set, interactions will be enabled
  106711. */
  106712. attachedMesh: Nullable<AbstractMesh>;
  106713. /**
  106714. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106715. * @param mesh The mesh to replace the default mesh of the gizmo
  106716. */
  106717. setCustomMesh(mesh: Mesh): void;
  106718. /**
  106719. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  106720. */
  106721. updateGizmoRotationToMatchAttachedMesh: boolean;
  106722. /**
  106723. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  106724. */
  106725. updateGizmoPositionToMatchAttachedMesh: boolean;
  106726. /**
  106727. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  106728. */
  106729. updateScale: boolean;
  106730. protected _interactionsEnabled: boolean;
  106731. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106732. private _beforeRenderObserver;
  106733. private _tempVector;
  106734. /**
  106735. * Creates a gizmo
  106736. * @param gizmoLayer The utility layer the gizmo will be added to
  106737. */
  106738. constructor(
  106739. /** The utility layer the gizmo will be added to */
  106740. gizmoLayer?: UtilityLayerRenderer);
  106741. /**
  106742. * Updates the gizmo to match the attached mesh's position/rotation
  106743. */
  106744. protected _update(): void;
  106745. /**
  106746. * Disposes of the gizmo
  106747. */
  106748. dispose(): void;
  106749. }
  106750. }
  106751. declare module BABYLON {
  106752. /**
  106753. * Single plane drag gizmo
  106754. */
  106755. export class PlaneDragGizmo extends Gizmo {
  106756. /**
  106757. * Drag behavior responsible for the gizmos dragging interactions
  106758. */
  106759. dragBehavior: PointerDragBehavior;
  106760. private _pointerObserver;
  106761. /**
  106762. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106763. */
  106764. snapDistance: number;
  106765. /**
  106766. * Event that fires each time the gizmo snaps to a new location.
  106767. * * snapDistance is the the change in distance
  106768. */
  106769. onSnapObservable: Observable<{
  106770. snapDistance: number;
  106771. }>;
  106772. private _plane;
  106773. private _coloredMaterial;
  106774. private _hoverMaterial;
  106775. private _isEnabled;
  106776. private _parent;
  106777. /** @hidden */
  106778. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106779. /** @hidden */
  106780. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106781. /**
  106782. * Creates a PlaneDragGizmo
  106783. * @param gizmoLayer The utility layer the gizmo will be added to
  106784. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106785. * @param color The color of the gizmo
  106786. */
  106787. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106789. /**
  106790. * If the gizmo is enabled
  106791. */
  106792. isEnabled: boolean;
  106793. /**
  106794. * Disposes of the gizmo
  106795. */
  106796. dispose(): void;
  106797. }
  106798. }
  106799. declare module BABYLON {
  106800. /**
  106801. * Gizmo that enables dragging a mesh along 3 axis
  106802. */
  106803. export class PositionGizmo extends Gizmo {
  106804. /**
  106805. * Internal gizmo used for interactions on the x axis
  106806. */
  106807. xGizmo: AxisDragGizmo;
  106808. /**
  106809. * Internal gizmo used for interactions on the y axis
  106810. */
  106811. yGizmo: AxisDragGizmo;
  106812. /**
  106813. * Internal gizmo used for interactions on the z axis
  106814. */
  106815. zGizmo: AxisDragGizmo;
  106816. /**
  106817. * Internal gizmo used for interactions on the yz plane
  106818. */
  106819. xPlaneGizmo: PlaneDragGizmo;
  106820. /**
  106821. * Internal gizmo used for interactions on the xz plane
  106822. */
  106823. yPlaneGizmo: PlaneDragGizmo;
  106824. /**
  106825. * Internal gizmo used for interactions on the xy plane
  106826. */
  106827. zPlaneGizmo: PlaneDragGizmo;
  106828. /**
  106829. * private variables
  106830. */
  106831. private _meshAttached;
  106832. private _updateGizmoRotationToMatchAttachedMesh;
  106833. private _snapDistance;
  106834. private _scaleRatio;
  106835. /** Fires an event when any of it's sub gizmos are dragged */
  106836. onDragStartObservable: Observable<unknown>;
  106837. /** Fires an event when any of it's sub gizmos are released from dragging */
  106838. onDragEndObservable: Observable<unknown>;
  106839. /**
  106840. * If set to true, planar drag is enabled
  106841. */
  106842. private _planarGizmoEnabled;
  106843. attachedMesh: Nullable<AbstractMesh>;
  106844. /**
  106845. * Creates a PositionGizmo
  106846. * @param gizmoLayer The utility layer the gizmo will be added to
  106847. */
  106848. constructor(gizmoLayer?: UtilityLayerRenderer);
  106849. /**
  106850. * If the planar drag gizmo is enabled
  106851. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106852. */
  106853. planarGizmoEnabled: boolean;
  106854. updateGizmoRotationToMatchAttachedMesh: boolean;
  106855. /**
  106856. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106857. */
  106858. snapDistance: number;
  106859. /**
  106860. * Ratio for the scale of the gizmo (Default: 1)
  106861. */
  106862. scaleRatio: number;
  106863. /**
  106864. * Disposes of the gizmo
  106865. */
  106866. dispose(): void;
  106867. /**
  106868. * CustomMeshes are not supported by this gizmo
  106869. * @param mesh The mesh to replace the default mesh of the gizmo
  106870. */
  106871. setCustomMesh(mesh: Mesh): void;
  106872. }
  106873. }
  106874. declare module BABYLON {
  106875. /**
  106876. * Single axis drag gizmo
  106877. */
  106878. export class AxisDragGizmo extends Gizmo {
  106879. /**
  106880. * Drag behavior responsible for the gizmos dragging interactions
  106881. */
  106882. dragBehavior: PointerDragBehavior;
  106883. private _pointerObserver;
  106884. /**
  106885. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106886. */
  106887. snapDistance: number;
  106888. /**
  106889. * Event that fires each time the gizmo snaps to a new location.
  106890. * * snapDistance is the the change in distance
  106891. */
  106892. onSnapObservable: Observable<{
  106893. snapDistance: number;
  106894. }>;
  106895. private _isEnabled;
  106896. private _parent;
  106897. private _arrow;
  106898. private _coloredMaterial;
  106899. private _hoverMaterial;
  106900. /** @hidden */
  106901. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106902. /** @hidden */
  106903. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106904. /**
  106905. * Creates an AxisDragGizmo
  106906. * @param gizmoLayer The utility layer the gizmo will be added to
  106907. * @param dragAxis The axis which the gizmo will be able to drag on
  106908. * @param color The color of the gizmo
  106909. */
  106910. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106911. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106912. /**
  106913. * If the gizmo is enabled
  106914. */
  106915. isEnabled: boolean;
  106916. /**
  106917. * Disposes of the gizmo
  106918. */
  106919. dispose(): void;
  106920. }
  106921. }
  106922. declare module BABYLON.Debug {
  106923. /**
  106924. * The Axes viewer will show 3 axes in a specific point in space
  106925. */
  106926. export class AxesViewer {
  106927. private _xAxis;
  106928. private _yAxis;
  106929. private _zAxis;
  106930. private _scaleLinesFactor;
  106931. private _instanced;
  106932. /**
  106933. * Gets the hosting scene
  106934. */
  106935. scene: Scene;
  106936. /**
  106937. * Gets or sets a number used to scale line length
  106938. */
  106939. scaleLines: number;
  106940. /** Gets the node hierarchy used to render x-axis */
  106941. readonly xAxis: TransformNode;
  106942. /** Gets the node hierarchy used to render y-axis */
  106943. readonly yAxis: TransformNode;
  106944. /** Gets the node hierarchy used to render z-axis */
  106945. readonly zAxis: TransformNode;
  106946. /**
  106947. * Creates a new AxesViewer
  106948. * @param scene defines the hosting scene
  106949. * @param scaleLines defines a number used to scale line length (1 by default)
  106950. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106951. * @param xAxis defines the node hierarchy used to render the x-axis
  106952. * @param yAxis defines the node hierarchy used to render the y-axis
  106953. * @param zAxis defines the node hierarchy used to render the z-axis
  106954. */
  106955. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106956. /**
  106957. * Force the viewer to update
  106958. * @param position defines the position of the viewer
  106959. * @param xaxis defines the x axis of the viewer
  106960. * @param yaxis defines the y axis of the viewer
  106961. * @param zaxis defines the z axis of the viewer
  106962. */
  106963. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106964. /**
  106965. * Creates an instance of this axes viewer.
  106966. * @returns a new axes viewer with instanced meshes
  106967. */
  106968. createInstance(): AxesViewer;
  106969. /** Releases resources */
  106970. dispose(): void;
  106971. private static _SetRenderingGroupId;
  106972. }
  106973. }
  106974. declare module BABYLON.Debug {
  106975. /**
  106976. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106977. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106978. */
  106979. export class BoneAxesViewer extends AxesViewer {
  106980. /**
  106981. * Gets or sets the target mesh where to display the axes viewer
  106982. */
  106983. mesh: Nullable<Mesh>;
  106984. /**
  106985. * Gets or sets the target bone where to display the axes viewer
  106986. */
  106987. bone: Nullable<Bone>;
  106988. /** Gets current position */
  106989. pos: Vector3;
  106990. /** Gets direction of X axis */
  106991. xaxis: Vector3;
  106992. /** Gets direction of Y axis */
  106993. yaxis: Vector3;
  106994. /** Gets direction of Z axis */
  106995. zaxis: Vector3;
  106996. /**
  106997. * Creates a new BoneAxesViewer
  106998. * @param scene defines the hosting scene
  106999. * @param bone defines the target bone
  107000. * @param mesh defines the target mesh
  107001. * @param scaleLines defines a scaling factor for line length (1 by default)
  107002. */
  107003. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  107004. /**
  107005. * Force the viewer to update
  107006. */
  107007. update(): void;
  107008. /** Releases resources */
  107009. dispose(): void;
  107010. }
  107011. }
  107012. declare module BABYLON {
  107013. /**
  107014. * Interface used to define scene explorer extensibility option
  107015. */
  107016. export interface IExplorerExtensibilityOption {
  107017. /**
  107018. * Define the option label
  107019. */
  107020. label: string;
  107021. /**
  107022. * Defines the action to execute on click
  107023. */
  107024. action: (entity: any) => void;
  107025. }
  107026. /**
  107027. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  107028. */
  107029. export interface IExplorerExtensibilityGroup {
  107030. /**
  107031. * Defines a predicate to test if a given type mut be extended
  107032. */
  107033. predicate: (entity: any) => boolean;
  107034. /**
  107035. * Gets the list of options added to a type
  107036. */
  107037. entries: IExplorerExtensibilityOption[];
  107038. }
  107039. /**
  107040. * Interface used to define the options to use to create the Inspector
  107041. */
  107042. export interface IInspectorOptions {
  107043. /**
  107044. * Display in overlay mode (default: false)
  107045. */
  107046. overlay?: boolean;
  107047. /**
  107048. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  107049. */
  107050. globalRoot?: HTMLElement;
  107051. /**
  107052. * Display the Scene explorer
  107053. */
  107054. showExplorer?: boolean;
  107055. /**
  107056. * Display the property inspector
  107057. */
  107058. showInspector?: boolean;
  107059. /**
  107060. * Display in embed mode (both panes on the right)
  107061. */
  107062. embedMode?: boolean;
  107063. /**
  107064. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  107065. */
  107066. handleResize?: boolean;
  107067. /**
  107068. * Allow the panes to popup (default: true)
  107069. */
  107070. enablePopup?: boolean;
  107071. /**
  107072. * Allow the panes to be closed by users (default: true)
  107073. */
  107074. enableClose?: boolean;
  107075. /**
  107076. * Optional list of extensibility entries
  107077. */
  107078. explorerExtensibility?: IExplorerExtensibilityGroup[];
  107079. /**
  107080. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  107081. */
  107082. inspectorURL?: string;
  107083. }
  107084. interface Scene {
  107085. /**
  107086. * @hidden
  107087. * Backing field
  107088. */
  107089. _debugLayer: DebugLayer;
  107090. /**
  107091. * Gets the debug layer (aka Inspector) associated with the scene
  107092. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107093. */
  107094. debugLayer: DebugLayer;
  107095. }
  107096. /**
  107097. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107098. * what is happening in your scene
  107099. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107100. */
  107101. export class DebugLayer {
  107102. /**
  107103. * Define the url to get the inspector script from.
  107104. * By default it uses the babylonjs CDN.
  107105. * @ignoreNaming
  107106. */
  107107. static InspectorURL: string;
  107108. private _scene;
  107109. private BJSINSPECTOR;
  107110. private _onPropertyChangedObservable?;
  107111. /**
  107112. * Observable triggered when a property is changed through the inspector.
  107113. */
  107114. readonly onPropertyChangedObservable: any;
  107115. /**
  107116. * Instantiates a new debug layer.
  107117. * The debug layer (aka Inspector) is the go to tool in order to better understand
  107118. * what is happening in your scene
  107119. * @see http://doc.babylonjs.com/features/playground_debuglayer
  107120. * @param scene Defines the scene to inspect
  107121. */
  107122. constructor(scene: Scene);
  107123. /** Creates the inspector window. */
  107124. private _createInspector;
  107125. /**
  107126. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  107127. * @param entity defines the entity to select
  107128. * @param lineContainerTitle defines the specific block to highlight
  107129. */
  107130. select(entity: any, lineContainerTitle?: string): void;
  107131. /** Get the inspector from bundle or global */
  107132. private _getGlobalInspector;
  107133. /**
  107134. * Get if the inspector is visible or not.
  107135. * @returns true if visible otherwise, false
  107136. */
  107137. isVisible(): boolean;
  107138. /**
  107139. * Hide the inspector and close its window.
  107140. */
  107141. hide(): void;
  107142. /**
  107143. * Launch the debugLayer.
  107144. * @param config Define the configuration of the inspector
  107145. * @return a promise fulfilled when the debug layer is visible
  107146. */
  107147. show(config?: IInspectorOptions): Promise<DebugLayer>;
  107148. }
  107149. }
  107150. declare module BABYLON {
  107151. /**
  107152. * Class containing static functions to help procedurally build meshes
  107153. */
  107154. export class BoxBuilder {
  107155. /**
  107156. * Creates a box mesh
  107157. * * The parameter `size` sets the size (float) of each box side (default 1)
  107158. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107159. * * 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)
  107160. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107164. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107165. * @param name defines the name of the mesh
  107166. * @param options defines the options used to create the mesh
  107167. * @param scene defines the hosting scene
  107168. * @returns the box mesh
  107169. */
  107170. static CreateBox(name: string, options: {
  107171. size?: number;
  107172. width?: number;
  107173. height?: number;
  107174. depth?: number;
  107175. faceUV?: Vector4[];
  107176. faceColors?: Color4[];
  107177. sideOrientation?: number;
  107178. frontUVs?: Vector4;
  107179. backUVs?: Vector4;
  107180. wrap?: boolean;
  107181. topBaseAt?: number;
  107182. bottomBaseAt?: number;
  107183. updatable?: boolean;
  107184. }, scene?: Nullable<Scene>): Mesh;
  107185. }
  107186. }
  107187. declare module BABYLON {
  107188. /**
  107189. * Class containing static functions to help procedurally build meshes
  107190. */
  107191. export class SphereBuilder {
  107192. /**
  107193. * Creates a sphere mesh
  107194. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107195. * * 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`)
  107196. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107197. * * 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
  107198. * * 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)
  107199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107202. * @param name defines the name of the mesh
  107203. * @param options defines the options used to create the mesh
  107204. * @param scene defines the hosting scene
  107205. * @returns the sphere mesh
  107206. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107207. */
  107208. static CreateSphere(name: string, options: {
  107209. segments?: number;
  107210. diameter?: number;
  107211. diameterX?: number;
  107212. diameterY?: number;
  107213. diameterZ?: number;
  107214. arc?: number;
  107215. slice?: number;
  107216. sideOrientation?: number;
  107217. frontUVs?: Vector4;
  107218. backUVs?: Vector4;
  107219. updatable?: boolean;
  107220. }, scene: any): Mesh;
  107221. }
  107222. }
  107223. declare module BABYLON.Debug {
  107224. /**
  107225. * Used to show the physics impostor around the specific mesh
  107226. */
  107227. export class PhysicsViewer {
  107228. /** @hidden */
  107229. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  107230. /** @hidden */
  107231. protected _meshes: Array<Nullable<AbstractMesh>>;
  107232. /** @hidden */
  107233. protected _scene: Nullable<Scene>;
  107234. /** @hidden */
  107235. protected _numMeshes: number;
  107236. /** @hidden */
  107237. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  107238. private _renderFunction;
  107239. private _utilityLayer;
  107240. private _debugBoxMesh;
  107241. private _debugSphereMesh;
  107242. private _debugCylinderMesh;
  107243. private _debugMaterial;
  107244. private _debugMeshMeshes;
  107245. /**
  107246. * Creates a new PhysicsViewer
  107247. * @param scene defines the hosting scene
  107248. */
  107249. constructor(scene: Scene);
  107250. /** @hidden */
  107251. protected _updateDebugMeshes(): void;
  107252. /**
  107253. * Renders a specified physic impostor
  107254. * @param impostor defines the impostor to render
  107255. * @param targetMesh defines the mesh represented by the impostor
  107256. * @returns the new debug mesh used to render the impostor
  107257. */
  107258. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  107259. /**
  107260. * Hides a specified physic impostor
  107261. * @param impostor defines the impostor to hide
  107262. */
  107263. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  107264. private _getDebugMaterial;
  107265. private _getDebugBoxMesh;
  107266. private _getDebugSphereMesh;
  107267. private _getDebugCylinderMesh;
  107268. private _getDebugMeshMesh;
  107269. private _getDebugMesh;
  107270. /** Releases all resources */
  107271. dispose(): void;
  107272. }
  107273. }
  107274. declare module BABYLON {
  107275. /**
  107276. * Class containing static functions to help procedurally build meshes
  107277. */
  107278. export class LinesBuilder {
  107279. /**
  107280. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107281. * * 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
  107282. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107283. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107284. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107285. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107286. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107287. * * 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
  107288. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107291. * @param name defines the name of the new line system
  107292. * @param options defines the options used to create the line system
  107293. * @param scene defines the hosting scene
  107294. * @returns a new line system mesh
  107295. */
  107296. static CreateLineSystem(name: string, options: {
  107297. lines: Vector3[][];
  107298. updatable?: boolean;
  107299. instance?: Nullable<LinesMesh>;
  107300. colors?: Nullable<Color4[][]>;
  107301. useVertexAlpha?: boolean;
  107302. }, scene: Nullable<Scene>): LinesMesh;
  107303. /**
  107304. * Creates a line mesh
  107305. * 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
  107306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107307. * * The parameter `points` is an array successive Vector3
  107308. * * 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
  107309. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107310. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107311. * * When updating an instance, remember that only point positions can change, not the number of points
  107312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107314. * @param name defines the name of the new line system
  107315. * @param options defines the options used to create the line system
  107316. * @param scene defines the hosting scene
  107317. * @returns a new line mesh
  107318. */
  107319. static CreateLines(name: string, options: {
  107320. points: Vector3[];
  107321. updatable?: boolean;
  107322. instance?: Nullable<LinesMesh>;
  107323. colors?: Color4[];
  107324. useVertexAlpha?: boolean;
  107325. }, scene?: Nullable<Scene>): LinesMesh;
  107326. /**
  107327. * Creates a dashed line mesh
  107328. * * 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
  107329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107330. * * The parameter `points` is an array successive Vector3
  107331. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107332. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107333. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107334. * * 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
  107335. * * When updating an instance, remember that only point positions can change, not the number of points
  107336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107337. * @param name defines the name of the mesh
  107338. * @param options defines the options used to create the mesh
  107339. * @param scene defines the hosting scene
  107340. * @returns the dashed line mesh
  107341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107342. */
  107343. static CreateDashedLines(name: string, options: {
  107344. points: Vector3[];
  107345. dashSize?: number;
  107346. gapSize?: number;
  107347. dashNb?: number;
  107348. updatable?: boolean;
  107349. instance?: LinesMesh;
  107350. }, scene?: Nullable<Scene>): LinesMesh;
  107351. }
  107352. }
  107353. declare module BABYLON {
  107354. /**
  107355. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107356. * in order to better appreciate the issue one might have.
  107357. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107358. */
  107359. export class RayHelper {
  107360. /**
  107361. * Defines the ray we are currently tryin to visualize.
  107362. */
  107363. ray: Nullable<Ray>;
  107364. private _renderPoints;
  107365. private _renderLine;
  107366. private _renderFunction;
  107367. private _scene;
  107368. private _updateToMeshFunction;
  107369. private _attachedToMesh;
  107370. private _meshSpaceDirection;
  107371. private _meshSpaceOrigin;
  107372. /**
  107373. * Helper function to create a colored helper in a scene in one line.
  107374. * @param ray Defines the ray we are currently tryin to visualize
  107375. * @param scene Defines the scene the ray is used in
  107376. * @param color Defines the color we want to see the ray in
  107377. * @returns The newly created ray helper.
  107378. */
  107379. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  107380. /**
  107381. * Instantiate a new ray helper.
  107382. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  107383. * in order to better appreciate the issue one might have.
  107384. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  107385. * @param ray Defines the ray we are currently tryin to visualize
  107386. */
  107387. constructor(ray: Ray);
  107388. /**
  107389. * Shows the ray we are willing to debug.
  107390. * @param scene Defines the scene the ray needs to be rendered in
  107391. * @param color Defines the color the ray needs to be rendered in
  107392. */
  107393. show(scene: Scene, color?: Color3): void;
  107394. /**
  107395. * Hides the ray we are debugging.
  107396. */
  107397. hide(): void;
  107398. private _render;
  107399. /**
  107400. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  107401. * @param mesh Defines the mesh we want the helper attached to
  107402. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  107403. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  107404. * @param length Defines the length of the ray
  107405. */
  107406. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  107407. /**
  107408. * Detach the ray helper from the mesh it has previously been attached to.
  107409. */
  107410. detachFromMesh(): void;
  107411. private _updateToMesh;
  107412. /**
  107413. * Dispose the helper and release its associated resources.
  107414. */
  107415. dispose(): void;
  107416. }
  107417. }
  107418. declare module BABYLON.Debug {
  107419. /**
  107420. * Class used to render a debug view of a given skeleton
  107421. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  107422. */
  107423. export class SkeletonViewer {
  107424. /** defines the skeleton to render */
  107425. skeleton: Skeleton;
  107426. /** defines the mesh attached to the skeleton */
  107427. mesh: AbstractMesh;
  107428. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107429. autoUpdateBonesMatrices: boolean;
  107430. /** defines the rendering group id to use with the viewer */
  107431. renderingGroupId: number;
  107432. /** Gets or sets the color used to render the skeleton */
  107433. color: Color3;
  107434. private _scene;
  107435. private _debugLines;
  107436. private _debugMesh;
  107437. private _isEnabled;
  107438. private _renderFunction;
  107439. private _utilityLayer;
  107440. /**
  107441. * Returns the mesh used to render the bones
  107442. */
  107443. readonly debugMesh: Nullable<LinesMesh>;
  107444. /**
  107445. * Creates a new SkeletonViewer
  107446. * @param skeleton defines the skeleton to render
  107447. * @param mesh defines the mesh attached to the skeleton
  107448. * @param scene defines the hosting scene
  107449. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  107450. * @param renderingGroupId defines the rendering group id to use with the viewer
  107451. */
  107452. constructor(
  107453. /** defines the skeleton to render */
  107454. skeleton: Skeleton,
  107455. /** defines the mesh attached to the skeleton */
  107456. mesh: AbstractMesh, scene: Scene,
  107457. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  107458. autoUpdateBonesMatrices?: boolean,
  107459. /** defines the rendering group id to use with the viewer */
  107460. renderingGroupId?: number);
  107461. /** Gets or sets a boolean indicating if the viewer is enabled */
  107462. isEnabled: boolean;
  107463. private _getBonePosition;
  107464. private _getLinesForBonesWithLength;
  107465. private _getLinesForBonesNoLength;
  107466. /** Update the viewer to sync with current skeleton state */
  107467. update(): void;
  107468. /** Release associated resources */
  107469. dispose(): void;
  107470. }
  107471. }
  107472. declare module BABYLON {
  107473. /**
  107474. * Options to create the null engine
  107475. */
  107476. export class NullEngineOptions {
  107477. /**
  107478. * Render width (Default: 512)
  107479. */
  107480. renderWidth: number;
  107481. /**
  107482. * Render height (Default: 256)
  107483. */
  107484. renderHeight: number;
  107485. /**
  107486. * Texture size (Default: 512)
  107487. */
  107488. textureSize: number;
  107489. /**
  107490. * If delta time between frames should be constant
  107491. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107492. */
  107493. deterministicLockstep: boolean;
  107494. /**
  107495. * Maximum about of steps between frames (Default: 4)
  107496. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107497. */
  107498. lockstepMaxSteps: number;
  107499. }
  107500. /**
  107501. * The null engine class provides support for headless version of babylon.js.
  107502. * This can be used in server side scenario or for testing purposes
  107503. */
  107504. export class NullEngine extends Engine {
  107505. private _options;
  107506. /**
  107507. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  107508. */
  107509. isDeterministicLockStep(): boolean;
  107510. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  107511. getLockstepMaxSteps(): number;
  107512. /**
  107513. * Sets hardware scaling, used to save performance if needed
  107514. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  107515. */
  107516. getHardwareScalingLevel(): number;
  107517. constructor(options?: NullEngineOptions);
  107518. createVertexBuffer(vertices: FloatArray): DataBuffer;
  107519. createIndexBuffer(indices: IndicesArray): DataBuffer;
  107520. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  107521. getRenderWidth(useScreen?: boolean): number;
  107522. getRenderHeight(useScreen?: boolean): number;
  107523. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  107524. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  107525. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  107526. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  107527. bindSamplers(effect: Effect): void;
  107528. enableEffect(effect: Effect): void;
  107529. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  107530. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  107531. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  107532. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  107533. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  107534. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  107535. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  107536. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  107537. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  107538. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  107539. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  107540. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  107541. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  107542. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  107543. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107544. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  107545. setFloat(uniform: WebGLUniformLocation, value: number): void;
  107546. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  107547. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  107548. setBool(uniform: WebGLUniformLocation, bool: number): void;
  107549. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  107550. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107551. bindBuffers(vertexBuffers: {
  107552. [key: string]: VertexBuffer;
  107553. }, indexBuffer: DataBuffer, effect: Effect): void;
  107554. wipeCaches(bruteForce?: boolean): void;
  107555. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  107556. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  107557. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  107558. /** @hidden */
  107559. _createTexture(): WebGLTexture;
  107560. /** @hidden */
  107561. _releaseTexture(texture: InternalTexture): void;
  107562. 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;
  107563. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  107564. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  107565. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  107566. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  107567. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  107568. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  107569. areAllEffectsReady(): boolean;
  107570. /**
  107571. * @hidden
  107572. * Get the current error code of the webGL context
  107573. * @returns the error code
  107574. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  107575. */
  107576. getError(): number;
  107577. /** @hidden */
  107578. _getUnpackAlignement(): number;
  107579. /** @hidden */
  107580. _unpackFlipY(value: boolean): void;
  107581. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  107582. /**
  107583. * Updates a dynamic vertex buffer.
  107584. * @param vertexBuffer the vertex buffer to update
  107585. * @param data the data used to update the vertex buffer
  107586. * @param byteOffset the byte offset of the data (optional)
  107587. * @param byteLength the byte length of the data (optional)
  107588. */
  107589. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  107590. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  107591. /** @hidden */
  107592. _bindTexture(channel: number, texture: InternalTexture): void;
  107593. /** @hidden */
  107594. _releaseBuffer(buffer: DataBuffer): boolean;
  107595. releaseEffects(): void;
  107596. displayLoadingUI(): void;
  107597. hideLoadingUI(): void;
  107598. /** @hidden */
  107599. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107600. /** @hidden */
  107601. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107602. /** @hidden */
  107603. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107604. /** @hidden */
  107605. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107606. }
  107607. }
  107608. declare module BABYLON {
  107609. /** @hidden */
  107610. export class _OcclusionDataStorage {
  107611. /** @hidden */
  107612. occlusionInternalRetryCounter: number;
  107613. /** @hidden */
  107614. isOcclusionQueryInProgress: boolean;
  107615. /** @hidden */
  107616. isOccluded: boolean;
  107617. /** @hidden */
  107618. occlusionRetryCount: number;
  107619. /** @hidden */
  107620. occlusionType: number;
  107621. /** @hidden */
  107622. occlusionQueryAlgorithmType: number;
  107623. }
  107624. interface Engine {
  107625. /**
  107626. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107627. * @return the new query
  107628. */
  107629. createQuery(): WebGLQuery;
  107630. /**
  107631. * Delete and release a webGL query
  107632. * @param query defines the query to delete
  107633. * @return the current engine
  107634. */
  107635. deleteQuery(query: WebGLQuery): Engine;
  107636. /**
  107637. * Check if a given query has resolved and got its value
  107638. * @param query defines the query to check
  107639. * @returns true if the query got its value
  107640. */
  107641. isQueryResultAvailable(query: WebGLQuery): boolean;
  107642. /**
  107643. * Gets the value of a given query
  107644. * @param query defines the query to check
  107645. * @returns the value of the query
  107646. */
  107647. getQueryResult(query: WebGLQuery): number;
  107648. /**
  107649. * Initiates an occlusion query
  107650. * @param algorithmType defines the algorithm to use
  107651. * @param query defines the query to use
  107652. * @returns the current engine
  107653. * @see http://doc.babylonjs.com/features/occlusionquery
  107654. */
  107655. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107656. /**
  107657. * Ends an occlusion query
  107658. * @see http://doc.babylonjs.com/features/occlusionquery
  107659. * @param algorithmType defines the algorithm to use
  107660. * @returns the current engine
  107661. */
  107662. endOcclusionQuery(algorithmType: number): Engine;
  107663. /**
  107664. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  107665. * Please note that only one query can be issued at a time
  107666. * @returns a time token used to track the time span
  107667. */
  107668. startTimeQuery(): Nullable<_TimeToken>;
  107669. /**
  107670. * Ends a time query
  107671. * @param token defines the token used to measure the time span
  107672. * @returns the time spent (in ns)
  107673. */
  107674. endTimeQuery(token: _TimeToken): int;
  107675. /** @hidden */
  107676. _currentNonTimestampToken: Nullable<_TimeToken>;
  107677. /** @hidden */
  107678. _createTimeQuery(): WebGLQuery;
  107679. /** @hidden */
  107680. _deleteTimeQuery(query: WebGLQuery): void;
  107681. /** @hidden */
  107682. _getGlAlgorithmType(algorithmType: number): number;
  107683. /** @hidden */
  107684. _getTimeQueryResult(query: WebGLQuery): any;
  107685. /** @hidden */
  107686. _getTimeQueryAvailability(query: WebGLQuery): any;
  107687. }
  107688. interface AbstractMesh {
  107689. /**
  107690. * Backing filed
  107691. * @hidden
  107692. */
  107693. __occlusionDataStorage: _OcclusionDataStorage;
  107694. /**
  107695. * Access property
  107696. * @hidden
  107697. */
  107698. _occlusionDataStorage: _OcclusionDataStorage;
  107699. /**
  107700. * 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.
  107701. * The default value is -1 which means don't break the query and wait till the result
  107702. * @see http://doc.babylonjs.com/features/occlusionquery
  107703. */
  107704. occlusionRetryCount: number;
  107705. /**
  107706. * 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:
  107707. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  107708. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  107709. * * 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.
  107710. * @see http://doc.babylonjs.com/features/occlusionquery
  107711. */
  107712. occlusionType: number;
  107713. /**
  107714. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  107715. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  107716. * * 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.
  107717. * @see http://doc.babylonjs.com/features/occlusionquery
  107718. */
  107719. occlusionQueryAlgorithmType: number;
  107720. /**
  107721. * 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
  107722. * @see http://doc.babylonjs.com/features/occlusionquery
  107723. */
  107724. isOccluded: boolean;
  107725. /**
  107726. * Flag to check the progress status of the query
  107727. * @see http://doc.babylonjs.com/features/occlusionquery
  107728. */
  107729. isOcclusionQueryInProgress: boolean;
  107730. }
  107731. }
  107732. declare module BABYLON {
  107733. /** @hidden */
  107734. export var _forceTransformFeedbackToBundle: boolean;
  107735. interface Engine {
  107736. /**
  107737. * Creates a webGL transform feedback object
  107738. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107739. * @returns the webGL transform feedback object
  107740. */
  107741. createTransformFeedback(): WebGLTransformFeedback;
  107742. /**
  107743. * Delete a webGL transform feedback object
  107744. * @param value defines the webGL transform feedback object to delete
  107745. */
  107746. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107747. /**
  107748. * Bind a webGL transform feedback object to the webgl context
  107749. * @param value defines the webGL transform feedback object to bind
  107750. */
  107751. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107752. /**
  107753. * Begins a transform feedback operation
  107754. * @param usePoints defines if points or triangles must be used
  107755. */
  107756. beginTransformFeedback(usePoints: boolean): void;
  107757. /**
  107758. * Ends a transform feedback operation
  107759. */
  107760. endTransformFeedback(): void;
  107761. /**
  107762. * Specify the varyings to use with transform feedback
  107763. * @param program defines the associated webGL program
  107764. * @param value defines the list of strings representing the varying names
  107765. */
  107766. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107767. /**
  107768. * Bind a webGL buffer for a transform feedback operation
  107769. * @param value defines the webGL buffer to bind
  107770. */
  107771. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107772. }
  107773. }
  107774. declare module BABYLON {
  107775. /**
  107776. * Creation options of the multi render target texture.
  107777. */
  107778. export interface IMultiRenderTargetOptions {
  107779. /**
  107780. * Define if the texture needs to create mip maps after render.
  107781. */
  107782. generateMipMaps?: boolean;
  107783. /**
  107784. * Define the types of all the draw buffers we want to create
  107785. */
  107786. types?: number[];
  107787. /**
  107788. * Define the sampling modes of all the draw buffers we want to create
  107789. */
  107790. samplingModes?: number[];
  107791. /**
  107792. * Define if a depth buffer is required
  107793. */
  107794. generateDepthBuffer?: boolean;
  107795. /**
  107796. * Define if a stencil buffer is required
  107797. */
  107798. generateStencilBuffer?: boolean;
  107799. /**
  107800. * Define if a depth texture is required instead of a depth buffer
  107801. */
  107802. generateDepthTexture?: boolean;
  107803. /**
  107804. * Define the number of desired draw buffers
  107805. */
  107806. textureCount?: number;
  107807. /**
  107808. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107809. */
  107810. doNotChangeAspectRatio?: boolean;
  107811. /**
  107812. * Define the default type of the buffers we are creating
  107813. */
  107814. defaultType?: number;
  107815. }
  107816. /**
  107817. * A multi render target, like a render target provides the ability to render to a texture.
  107818. * Unlike the render target, it can render to several draw buffers in one draw.
  107819. * This is specially interesting in deferred rendering or for any effects requiring more than
  107820. * just one color from a single pass.
  107821. */
  107822. export class MultiRenderTarget extends RenderTargetTexture {
  107823. private _internalTextures;
  107824. private _textures;
  107825. private _multiRenderTargetOptions;
  107826. /**
  107827. * Get if draw buffers are currently supported by the used hardware and browser.
  107828. */
  107829. readonly isSupported: boolean;
  107830. /**
  107831. * Get the list of textures generated by the multi render target.
  107832. */
  107833. readonly textures: Texture[];
  107834. /**
  107835. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107836. */
  107837. readonly depthTexture: Texture;
  107838. /**
  107839. * Set the wrapping mode on U of all the textures we are rendering to.
  107840. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107841. */
  107842. wrapU: number;
  107843. /**
  107844. * Set the wrapping mode on V of all the textures we are rendering to.
  107845. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107846. */
  107847. wrapV: number;
  107848. /**
  107849. * Instantiate a new multi render target texture.
  107850. * A multi render target, like a render target provides the ability to render to a texture.
  107851. * Unlike the render target, it can render to several draw buffers in one draw.
  107852. * This is specially interesting in deferred rendering or for any effects requiring more than
  107853. * just one color from a single pass.
  107854. * @param name Define the name of the texture
  107855. * @param size Define the size of the buffers to render to
  107856. * @param count Define the number of target we are rendering into
  107857. * @param scene Define the scene the texture belongs to
  107858. * @param options Define the options used to create the multi render target
  107859. */
  107860. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107861. /** @hidden */
  107862. _rebuild(): void;
  107863. private _createInternalTextures;
  107864. private _createTextures;
  107865. /**
  107866. * Define the number of samples used if MSAA is enabled.
  107867. */
  107868. samples: number;
  107869. /**
  107870. * Resize all the textures in the multi render target.
  107871. * Be carrefull as it will recreate all the data in the new texture.
  107872. * @param size Define the new size
  107873. */
  107874. resize(size: any): void;
  107875. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107876. /**
  107877. * Dispose the render targets and their associated resources
  107878. */
  107879. dispose(): void;
  107880. /**
  107881. * Release all the underlying texture used as draw buffers.
  107882. */
  107883. releaseInternalTextures(): void;
  107884. }
  107885. }
  107886. declare module BABYLON {
  107887. interface Engine {
  107888. /**
  107889. * Unbind a list of render target textures from the webGL context
  107890. * This is used only when drawBuffer extension or webGL2 are active
  107891. * @param textures defines the render target textures to unbind
  107892. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107893. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107894. */
  107895. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107896. /**
  107897. * Create a multi render target texture
  107898. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107899. * @param size defines the size of the texture
  107900. * @param options defines the creation options
  107901. * @returns the cube texture as an InternalTexture
  107902. */
  107903. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107904. /**
  107905. * Update the sample count for a given multiple render target texture
  107906. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107907. * @param textures defines the textures to update
  107908. * @param samples defines the sample count to set
  107909. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107910. */
  107911. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107912. }
  107913. }
  107914. declare module BABYLON {
  107915. /**
  107916. * Gather the list of clipboard event types as constants.
  107917. */
  107918. export class ClipboardEventTypes {
  107919. /**
  107920. * The clipboard event is fired when a copy command is active (pressed).
  107921. */
  107922. static readonly COPY: number;
  107923. /**
  107924. * The clipboard event is fired when a cut command is active (pressed).
  107925. */
  107926. static readonly CUT: number;
  107927. /**
  107928. * The clipboard event is fired when a paste command is active (pressed).
  107929. */
  107930. static readonly PASTE: number;
  107931. }
  107932. /**
  107933. * This class is used to store clipboard related info for the onClipboardObservable event.
  107934. */
  107935. export class ClipboardInfo {
  107936. /**
  107937. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107938. */
  107939. type: number;
  107940. /**
  107941. * Defines the related dom event
  107942. */
  107943. event: ClipboardEvent;
  107944. /**
  107945. *Creates an instance of ClipboardInfo.
  107946. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107947. * @param event Defines the related dom event
  107948. */
  107949. constructor(
  107950. /**
  107951. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107952. */
  107953. type: number,
  107954. /**
  107955. * Defines the related dom event
  107956. */
  107957. event: ClipboardEvent);
  107958. /**
  107959. * Get the clipboard event's type from the keycode.
  107960. * @param keyCode Defines the keyCode for the current keyboard event.
  107961. * @return {number}
  107962. */
  107963. static GetTypeFromCharacter(keyCode: number): number;
  107964. }
  107965. }
  107966. declare module BABYLON {
  107967. /**
  107968. * Google Daydream controller
  107969. */
  107970. export class DaydreamController extends WebVRController {
  107971. /**
  107972. * Base Url for the controller model.
  107973. */
  107974. static MODEL_BASE_URL: string;
  107975. /**
  107976. * File name for the controller model.
  107977. */
  107978. static MODEL_FILENAME: string;
  107979. /**
  107980. * Gamepad Id prefix used to identify Daydream Controller.
  107981. */
  107982. static readonly GAMEPAD_ID_PREFIX: string;
  107983. /**
  107984. * Creates a new DaydreamController from a gamepad
  107985. * @param vrGamepad the gamepad that the controller should be created from
  107986. */
  107987. constructor(vrGamepad: any);
  107988. /**
  107989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107990. * @param scene scene in which to add meshes
  107991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107992. */
  107993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107994. /**
  107995. * Called once for each button that changed state since the last frame
  107996. * @param buttonIdx Which button index changed
  107997. * @param state New state of the button
  107998. * @param changes Which properties on the state changed since last frame
  107999. */
  108000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108001. }
  108002. }
  108003. declare module BABYLON {
  108004. /**
  108005. * Gear VR Controller
  108006. */
  108007. export class GearVRController extends WebVRController {
  108008. /**
  108009. * Base Url for the controller model.
  108010. */
  108011. static MODEL_BASE_URL: string;
  108012. /**
  108013. * File name for the controller model.
  108014. */
  108015. static MODEL_FILENAME: string;
  108016. /**
  108017. * Gamepad Id prefix used to identify this controller.
  108018. */
  108019. static readonly GAMEPAD_ID_PREFIX: string;
  108020. private readonly _buttonIndexToObservableNameMap;
  108021. /**
  108022. * Creates a new GearVRController from a gamepad
  108023. * @param vrGamepad the gamepad that the controller should be created from
  108024. */
  108025. constructor(vrGamepad: any);
  108026. /**
  108027. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108028. * @param scene scene in which to add meshes
  108029. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108030. */
  108031. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108032. /**
  108033. * Called once for each button that changed state since the last frame
  108034. * @param buttonIdx Which button index changed
  108035. * @param state New state of the button
  108036. * @param changes Which properties on the state changed since last frame
  108037. */
  108038. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108039. }
  108040. }
  108041. declare module BABYLON {
  108042. /**
  108043. * Class containing static functions to help procedurally build meshes
  108044. */
  108045. export class PolyhedronBuilder {
  108046. /**
  108047. * Creates a polyhedron mesh
  108048. * * 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
  108049. * * The parameter `size` (positive float, default 1) sets the polygon size
  108050. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108051. * * 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`
  108052. * * 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
  108053. * * 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)`)
  108054. * * 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
  108055. * * 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
  108056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108059. * @param name defines the name of the mesh
  108060. * @param options defines the options used to create the mesh
  108061. * @param scene defines the hosting scene
  108062. * @returns the polyhedron mesh
  108063. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  108064. */
  108065. static CreatePolyhedron(name: string, options: {
  108066. type?: number;
  108067. size?: number;
  108068. sizeX?: number;
  108069. sizeY?: number;
  108070. sizeZ?: number;
  108071. custom?: any;
  108072. faceUV?: Vector4[];
  108073. faceColors?: Color4[];
  108074. flat?: boolean;
  108075. updatable?: boolean;
  108076. sideOrientation?: number;
  108077. frontUVs?: Vector4;
  108078. backUVs?: Vector4;
  108079. }, scene?: Nullable<Scene>): Mesh;
  108080. }
  108081. }
  108082. declare module BABYLON {
  108083. /**
  108084. * Gizmo that enables scaling a mesh along 3 axis
  108085. */
  108086. export class ScaleGizmo extends Gizmo {
  108087. /**
  108088. * Internal gizmo used for interactions on the x axis
  108089. */
  108090. xGizmo: AxisScaleGizmo;
  108091. /**
  108092. * Internal gizmo used for interactions on the y axis
  108093. */
  108094. yGizmo: AxisScaleGizmo;
  108095. /**
  108096. * Internal gizmo used for interactions on the z axis
  108097. */
  108098. zGizmo: AxisScaleGizmo;
  108099. /**
  108100. * Internal gizmo used to scale all axis equally
  108101. */
  108102. uniformScaleGizmo: AxisScaleGizmo;
  108103. private _meshAttached;
  108104. private _updateGizmoRotationToMatchAttachedMesh;
  108105. private _snapDistance;
  108106. private _scaleRatio;
  108107. private _uniformScalingMesh;
  108108. private _octahedron;
  108109. /** Fires an event when any of it's sub gizmos are dragged */
  108110. onDragStartObservable: Observable<unknown>;
  108111. /** Fires an event when any of it's sub gizmos are released from dragging */
  108112. onDragEndObservable: Observable<unknown>;
  108113. attachedMesh: Nullable<AbstractMesh>;
  108114. /**
  108115. * Creates a ScaleGizmo
  108116. * @param gizmoLayer The utility layer the gizmo will be added to
  108117. */
  108118. constructor(gizmoLayer?: UtilityLayerRenderer);
  108119. updateGizmoRotationToMatchAttachedMesh: boolean;
  108120. /**
  108121. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108122. */
  108123. snapDistance: number;
  108124. /**
  108125. * Ratio for the scale of the gizmo (Default: 1)
  108126. */
  108127. scaleRatio: number;
  108128. /**
  108129. * Disposes of the gizmo
  108130. */
  108131. dispose(): void;
  108132. }
  108133. }
  108134. declare module BABYLON {
  108135. /**
  108136. * Single axis scale gizmo
  108137. */
  108138. export class AxisScaleGizmo extends Gizmo {
  108139. /**
  108140. * Drag behavior responsible for the gizmos dragging interactions
  108141. */
  108142. dragBehavior: PointerDragBehavior;
  108143. private _pointerObserver;
  108144. /**
  108145. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108146. */
  108147. snapDistance: number;
  108148. /**
  108149. * Event that fires each time the gizmo snaps to a new location.
  108150. * * snapDistance is the the change in distance
  108151. */
  108152. onSnapObservable: Observable<{
  108153. snapDistance: number;
  108154. }>;
  108155. /**
  108156. * If the scaling operation should be done on all axis (default: false)
  108157. */
  108158. uniformScaling: boolean;
  108159. private _isEnabled;
  108160. private _parent;
  108161. private _arrow;
  108162. private _coloredMaterial;
  108163. private _hoverMaterial;
  108164. /**
  108165. * Creates an AxisScaleGizmo
  108166. * @param gizmoLayer The utility layer the gizmo will be added to
  108167. * @param dragAxis The axis which the gizmo will be able to scale on
  108168. * @param color The color of the gizmo
  108169. */
  108170. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  108171. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108172. /**
  108173. * If the gizmo is enabled
  108174. */
  108175. isEnabled: boolean;
  108176. /**
  108177. * Disposes of the gizmo
  108178. */
  108179. dispose(): void;
  108180. /**
  108181. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108182. * @param mesh The mesh to replace the default mesh of the gizmo
  108183. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  108184. */
  108185. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  108186. }
  108187. }
  108188. declare module BABYLON {
  108189. /**
  108190. * Bounding box gizmo
  108191. */
  108192. export class BoundingBoxGizmo extends Gizmo {
  108193. private _lineBoundingBox;
  108194. private _rotateSpheresParent;
  108195. private _scaleBoxesParent;
  108196. private _boundingDimensions;
  108197. private _renderObserver;
  108198. private _pointerObserver;
  108199. private _scaleDragSpeed;
  108200. private _tmpQuaternion;
  108201. private _tmpVector;
  108202. private _tmpRotationMatrix;
  108203. /**
  108204. * 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)
  108205. */
  108206. ignoreChildren: boolean;
  108207. /**
  108208. * 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)
  108209. */
  108210. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  108211. /**
  108212. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  108213. */
  108214. rotationSphereSize: number;
  108215. /**
  108216. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  108217. */
  108218. scaleBoxSize: number;
  108219. /**
  108220. * 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)
  108221. */
  108222. fixedDragMeshScreenSize: boolean;
  108223. /**
  108224. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  108225. */
  108226. fixedDragMeshScreenSizeDistanceFactor: number;
  108227. /**
  108228. * Fired when a rotation sphere or scale box is dragged
  108229. */
  108230. onDragStartObservable: Observable<{}>;
  108231. /**
  108232. * Fired when a scale box is dragged
  108233. */
  108234. onScaleBoxDragObservable: Observable<{}>;
  108235. /**
  108236. * Fired when a scale box drag is ended
  108237. */
  108238. onScaleBoxDragEndObservable: Observable<{}>;
  108239. /**
  108240. * Fired when a rotation sphere is dragged
  108241. */
  108242. onRotationSphereDragObservable: Observable<{}>;
  108243. /**
  108244. * Fired when a rotation sphere drag is ended
  108245. */
  108246. onRotationSphereDragEndObservable: Observable<{}>;
  108247. /**
  108248. * 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)
  108249. */
  108250. scalePivot: Nullable<Vector3>;
  108251. /**
  108252. * Mesh used as a pivot to rotate the attached mesh
  108253. */
  108254. private _anchorMesh;
  108255. private _existingMeshScale;
  108256. private _dragMesh;
  108257. private pointerDragBehavior;
  108258. private coloredMaterial;
  108259. private hoverColoredMaterial;
  108260. /**
  108261. * Sets the color of the bounding box gizmo
  108262. * @param color the color to set
  108263. */
  108264. setColor(color: Color3): void;
  108265. /**
  108266. * Creates an BoundingBoxGizmo
  108267. * @param gizmoLayer The utility layer the gizmo will be added to
  108268. * @param color The color of the gizmo
  108269. */
  108270. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  108271. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108272. private _selectNode;
  108273. /**
  108274. * Updates the bounding box information for the Gizmo
  108275. */
  108276. updateBoundingBox(): void;
  108277. private _updateRotationSpheres;
  108278. private _updateScaleBoxes;
  108279. /**
  108280. * Enables rotation on the specified axis and disables rotation on the others
  108281. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  108282. */
  108283. setEnabledRotationAxis(axis: string): void;
  108284. /**
  108285. * Enables/disables scaling
  108286. * @param enable if scaling should be enabled
  108287. */
  108288. setEnabledScaling(enable: boolean): void;
  108289. private _updateDummy;
  108290. /**
  108291. * Enables a pointer drag behavior on the bounding box of the gizmo
  108292. */
  108293. enableDragBehavior(): void;
  108294. /**
  108295. * Disposes of the gizmo
  108296. */
  108297. dispose(): void;
  108298. /**
  108299. * 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)
  108300. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  108301. * @returns the bounding box mesh with the passed in mesh as a child
  108302. */
  108303. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  108304. /**
  108305. * CustomMeshes are not supported by this gizmo
  108306. * @param mesh The mesh to replace the default mesh of the gizmo
  108307. */
  108308. setCustomMesh(mesh: Mesh): void;
  108309. }
  108310. }
  108311. declare module BABYLON {
  108312. /**
  108313. * Single plane rotation gizmo
  108314. */
  108315. export class PlaneRotationGizmo extends Gizmo {
  108316. /**
  108317. * Drag behavior responsible for the gizmos dragging interactions
  108318. */
  108319. dragBehavior: PointerDragBehavior;
  108320. private _pointerObserver;
  108321. /**
  108322. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  108323. */
  108324. snapDistance: number;
  108325. /**
  108326. * Event that fires each time the gizmo snaps to a new location.
  108327. * * snapDistance is the the change in distance
  108328. */
  108329. onSnapObservable: Observable<{
  108330. snapDistance: number;
  108331. }>;
  108332. private _isEnabled;
  108333. private _parent;
  108334. /**
  108335. * Creates a PlaneRotationGizmo
  108336. * @param gizmoLayer The utility layer the gizmo will be added to
  108337. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  108338. * @param color The color of the gizmo
  108339. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108340. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108341. */
  108342. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  108343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108344. /**
  108345. * If the gizmo is enabled
  108346. */
  108347. isEnabled: boolean;
  108348. /**
  108349. * Disposes of the gizmo
  108350. */
  108351. dispose(): void;
  108352. }
  108353. }
  108354. declare module BABYLON {
  108355. /**
  108356. * Gizmo that enables rotating a mesh along 3 axis
  108357. */
  108358. export class RotationGizmo extends Gizmo {
  108359. /**
  108360. * Internal gizmo used for interactions on the x axis
  108361. */
  108362. xGizmo: PlaneRotationGizmo;
  108363. /**
  108364. * Internal gizmo used for interactions on the y axis
  108365. */
  108366. yGizmo: PlaneRotationGizmo;
  108367. /**
  108368. * Internal gizmo used for interactions on the z axis
  108369. */
  108370. zGizmo: PlaneRotationGizmo;
  108371. /** Fires an event when any of it's sub gizmos are dragged */
  108372. onDragStartObservable: Observable<unknown>;
  108373. /** Fires an event when any of it's sub gizmos are released from dragging */
  108374. onDragEndObservable: Observable<unknown>;
  108375. private _meshAttached;
  108376. attachedMesh: Nullable<AbstractMesh>;
  108377. /**
  108378. * Creates a RotationGizmo
  108379. * @param gizmoLayer The utility layer the gizmo will be added to
  108380. * @param tessellation Amount of tessellation to be used when creating rotation circles
  108381. * @param useEulerRotation Use and update Euler angle instead of quaternion
  108382. */
  108383. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  108384. updateGizmoRotationToMatchAttachedMesh: boolean;
  108385. /**
  108386. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108387. */
  108388. snapDistance: number;
  108389. /**
  108390. * Ratio for the scale of the gizmo (Default: 1)
  108391. */
  108392. scaleRatio: number;
  108393. /**
  108394. * Disposes of the gizmo
  108395. */
  108396. dispose(): void;
  108397. /**
  108398. * CustomMeshes are not supported by this gizmo
  108399. * @param mesh The mesh to replace the default mesh of the gizmo
  108400. */
  108401. setCustomMesh(mesh: Mesh): void;
  108402. }
  108403. }
  108404. declare module BABYLON {
  108405. /**
  108406. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  108407. */
  108408. export class GizmoManager implements IDisposable {
  108409. private scene;
  108410. /**
  108411. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  108412. */
  108413. gizmos: {
  108414. positionGizmo: Nullable<PositionGizmo>;
  108415. rotationGizmo: Nullable<RotationGizmo>;
  108416. scaleGizmo: Nullable<ScaleGizmo>;
  108417. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  108418. };
  108419. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  108420. clearGizmoOnEmptyPointerEvent: boolean;
  108421. /** Fires an event when the manager is attached to a mesh */
  108422. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  108423. private _gizmosEnabled;
  108424. private _pointerObserver;
  108425. private _attachedMesh;
  108426. private _boundingBoxColor;
  108427. private _defaultUtilityLayer;
  108428. private _defaultKeepDepthUtilityLayer;
  108429. /**
  108430. * When bounding box gizmo is enabled, this can be used to track drag/end events
  108431. */
  108432. boundingBoxDragBehavior: SixDofDragBehavior;
  108433. /**
  108434. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  108435. */
  108436. attachableMeshes: Nullable<Array<AbstractMesh>>;
  108437. /**
  108438. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  108439. */
  108440. usePointerToAttachGizmos: boolean;
  108441. /**
  108442. * Utility layer that the bounding box gizmo belongs to
  108443. */
  108444. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  108445. /**
  108446. * Utility layer that all gizmos besides bounding box belong to
  108447. */
  108448. readonly utilityLayer: UtilityLayerRenderer;
  108449. /**
  108450. * Instatiates a gizmo manager
  108451. * @param scene the scene to overlay the gizmos on top of
  108452. */
  108453. constructor(scene: Scene);
  108454. /**
  108455. * Attaches a set of gizmos to the specified mesh
  108456. * @param mesh The mesh the gizmo's should be attached to
  108457. */
  108458. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108459. /**
  108460. * If the position gizmo is enabled
  108461. */
  108462. positionGizmoEnabled: boolean;
  108463. /**
  108464. * If the rotation gizmo is enabled
  108465. */
  108466. rotationGizmoEnabled: boolean;
  108467. /**
  108468. * If the scale gizmo is enabled
  108469. */
  108470. scaleGizmoEnabled: boolean;
  108471. /**
  108472. * If the boundingBox gizmo is enabled
  108473. */
  108474. boundingBoxGizmoEnabled: boolean;
  108475. /**
  108476. * Disposes of the gizmo manager
  108477. */
  108478. dispose(): void;
  108479. }
  108480. }
  108481. declare module BABYLON {
  108482. /**
  108483. * A directional light is defined by a direction (what a surprise!).
  108484. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  108485. * 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.
  108486. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108487. */
  108488. export class DirectionalLight extends ShadowLight {
  108489. private _shadowFrustumSize;
  108490. /**
  108491. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  108492. */
  108493. /**
  108494. * Specifies a fix frustum size for the shadow generation.
  108495. */
  108496. shadowFrustumSize: number;
  108497. private _shadowOrthoScale;
  108498. /**
  108499. * Gets the shadow projection scale against the optimal computed one.
  108500. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108501. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108502. */
  108503. /**
  108504. * Sets the shadow projection scale against the optimal computed one.
  108505. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  108506. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  108507. */
  108508. shadowOrthoScale: number;
  108509. /**
  108510. * Automatically compute the projection matrix to best fit (including all the casters)
  108511. * on each frame.
  108512. */
  108513. autoUpdateExtends: boolean;
  108514. private _orthoLeft;
  108515. private _orthoRight;
  108516. private _orthoTop;
  108517. private _orthoBottom;
  108518. /**
  108519. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  108520. * The directional light is emitted from everywhere in the given direction.
  108521. * It can cast shadows.
  108522. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108523. * @param name The friendly name of the light
  108524. * @param direction The direction of the light
  108525. * @param scene The scene the light belongs to
  108526. */
  108527. constructor(name: string, direction: Vector3, scene: Scene);
  108528. /**
  108529. * Returns the string "DirectionalLight".
  108530. * @return The class name
  108531. */
  108532. getClassName(): string;
  108533. /**
  108534. * Returns the integer 1.
  108535. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108536. */
  108537. getTypeID(): number;
  108538. /**
  108539. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  108540. * Returns the DirectionalLight Shadow projection matrix.
  108541. */
  108542. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108543. /**
  108544. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  108545. * Returns the DirectionalLight Shadow projection matrix.
  108546. */
  108547. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  108548. /**
  108549. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  108550. * Returns the DirectionalLight Shadow projection matrix.
  108551. */
  108552. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108553. protected _buildUniformLayout(): void;
  108554. /**
  108555. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  108556. * @param effect The effect to update
  108557. * @param lightIndex The index of the light in the effect to update
  108558. * @returns The directional light
  108559. */
  108560. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  108561. /**
  108562. * Gets the minZ used for shadow according to both the scene and the light.
  108563. *
  108564. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108565. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108566. * @param activeCamera The camera we are returning the min for
  108567. * @returns the depth min z
  108568. */
  108569. getDepthMinZ(activeCamera: Camera): number;
  108570. /**
  108571. * Gets the maxZ used for shadow according to both the scene and the light.
  108572. *
  108573. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  108574. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  108575. * @param activeCamera The camera we are returning the max for
  108576. * @returns the depth max z
  108577. */
  108578. getDepthMaxZ(activeCamera: Camera): number;
  108579. /**
  108580. * Prepares the list of defines specific to the light type.
  108581. * @param defines the list of defines
  108582. * @param lightIndex defines the index of the light for the effect
  108583. */
  108584. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108585. }
  108586. }
  108587. declare module BABYLON {
  108588. /**
  108589. * Class containing static functions to help procedurally build meshes
  108590. */
  108591. export class HemisphereBuilder {
  108592. /**
  108593. * Creates a hemisphere mesh
  108594. * @param name defines the name of the mesh
  108595. * @param options defines the options used to create the mesh
  108596. * @param scene defines the hosting scene
  108597. * @returns the hemisphere mesh
  108598. */
  108599. static CreateHemisphere(name: string, options: {
  108600. segments?: number;
  108601. diameter?: number;
  108602. sideOrientation?: number;
  108603. }, scene: any): Mesh;
  108604. }
  108605. }
  108606. declare module BABYLON {
  108607. /**
  108608. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108609. * These values define a cone of light starting from the position, emitting toward the direction.
  108610. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108611. * and the exponent defines the speed of the decay of the light with distance (reach).
  108612. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108613. */
  108614. export class SpotLight extends ShadowLight {
  108615. private _angle;
  108616. private _innerAngle;
  108617. private _cosHalfAngle;
  108618. private _lightAngleScale;
  108619. private _lightAngleOffset;
  108620. /**
  108621. * Gets the cone angle of the spot light in Radians.
  108622. */
  108623. /**
  108624. * Sets the cone angle of the spot light in Radians.
  108625. */
  108626. angle: number;
  108627. /**
  108628. * Only used in gltf falloff mode, this defines the angle where
  108629. * the directional falloff will start before cutting at angle which could be seen
  108630. * as outer angle.
  108631. */
  108632. /**
  108633. * Only used in gltf falloff mode, this defines the angle where
  108634. * the directional falloff will start before cutting at angle which could be seen
  108635. * as outer angle.
  108636. */
  108637. innerAngle: number;
  108638. private _shadowAngleScale;
  108639. /**
  108640. * Allows scaling the angle of the light for shadow generation only.
  108641. */
  108642. /**
  108643. * Allows scaling the angle of the light for shadow generation only.
  108644. */
  108645. shadowAngleScale: number;
  108646. /**
  108647. * The light decay speed with the distance from the emission spot.
  108648. */
  108649. exponent: number;
  108650. private _projectionTextureMatrix;
  108651. /**
  108652. * Allows reading the projecton texture
  108653. */
  108654. readonly projectionTextureMatrix: Matrix;
  108655. protected _projectionTextureLightNear: number;
  108656. /**
  108657. * Gets the near clip of the Spotlight for texture projection.
  108658. */
  108659. /**
  108660. * Sets the near clip of the Spotlight for texture projection.
  108661. */
  108662. projectionTextureLightNear: number;
  108663. protected _projectionTextureLightFar: number;
  108664. /**
  108665. * Gets the far clip of the Spotlight for texture projection.
  108666. */
  108667. /**
  108668. * Sets the far clip of the Spotlight for texture projection.
  108669. */
  108670. projectionTextureLightFar: number;
  108671. protected _projectionTextureUpDirection: Vector3;
  108672. /**
  108673. * Gets the Up vector of the Spotlight for texture projection.
  108674. */
  108675. /**
  108676. * Sets the Up vector of the Spotlight for texture projection.
  108677. */
  108678. projectionTextureUpDirection: Vector3;
  108679. private _projectionTexture;
  108680. /**
  108681. * Gets the projection texture of the light.
  108682. */
  108683. /**
  108684. * Sets the projection texture of the light.
  108685. */
  108686. projectionTexture: Nullable<BaseTexture>;
  108687. private _projectionTextureViewLightDirty;
  108688. private _projectionTextureProjectionLightDirty;
  108689. private _projectionTextureDirty;
  108690. private _projectionTextureViewTargetVector;
  108691. private _projectionTextureViewLightMatrix;
  108692. private _projectionTextureProjectionLightMatrix;
  108693. private _projectionTextureScalingMatrix;
  108694. /**
  108695. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  108696. * It can cast shadows.
  108697. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108698. * @param name The light friendly name
  108699. * @param position The position of the spot light in the scene
  108700. * @param direction The direction of the light in the scene
  108701. * @param angle The cone angle of the light in Radians
  108702. * @param exponent The light decay speed with the distance from the emission spot
  108703. * @param scene The scene the lights belongs to
  108704. */
  108705. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  108706. /**
  108707. * Returns the string "SpotLight".
  108708. * @returns the class name
  108709. */
  108710. getClassName(): string;
  108711. /**
  108712. * Returns the integer 2.
  108713. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108714. */
  108715. getTypeID(): number;
  108716. /**
  108717. * Overrides the direction setter to recompute the projection texture view light Matrix.
  108718. */
  108719. protected _setDirection(value: Vector3): void;
  108720. /**
  108721. * Overrides the position setter to recompute the projection texture view light Matrix.
  108722. */
  108723. protected _setPosition(value: Vector3): void;
  108724. /**
  108725. * 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.
  108726. * Returns the SpotLight.
  108727. */
  108728. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108729. protected _computeProjectionTextureViewLightMatrix(): void;
  108730. protected _computeProjectionTextureProjectionLightMatrix(): void;
  108731. /**
  108732. * Main function for light texture projection matrix computing.
  108733. */
  108734. protected _computeProjectionTextureMatrix(): void;
  108735. protected _buildUniformLayout(): void;
  108736. private _computeAngleValues;
  108737. /**
  108738. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108739. * @param effect The effect to update
  108740. * @param lightIndex The index of the light in the effect to update
  108741. * @returns The spot light
  108742. */
  108743. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108744. /**
  108745. * Disposes the light and the associated resources.
  108746. */
  108747. dispose(): void;
  108748. /**
  108749. * Prepares the list of defines specific to the light type.
  108750. * @param defines the list of defines
  108751. * @param lightIndex defines the index of the light for the effect
  108752. */
  108753. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108754. }
  108755. }
  108756. declare module BABYLON {
  108757. /**
  108758. * Gizmo that enables viewing a light
  108759. */
  108760. export class LightGizmo extends Gizmo {
  108761. private _lightMesh;
  108762. private _material;
  108763. private cachedPosition;
  108764. private cachedForward;
  108765. /**
  108766. * Creates a LightGizmo
  108767. * @param gizmoLayer The utility layer the gizmo will be added to
  108768. */
  108769. constructor(gizmoLayer?: UtilityLayerRenderer);
  108770. private _light;
  108771. /**
  108772. * The light that the gizmo is attached to
  108773. */
  108774. light: Nullable<Light>;
  108775. /**
  108776. * @hidden
  108777. * Updates the gizmo to match the attached mesh's position/rotation
  108778. */
  108779. protected _update(): void;
  108780. private static _Scale;
  108781. /**
  108782. * Creates the lines for a light mesh
  108783. */
  108784. private static _createLightLines;
  108785. /**
  108786. * Disposes of the light gizmo
  108787. */
  108788. dispose(): void;
  108789. private static _CreateHemisphericLightMesh;
  108790. private static _CreatePointLightMesh;
  108791. private static _CreateSpotLightMesh;
  108792. private static _CreateDirectionalLightMesh;
  108793. }
  108794. }
  108795. declare module BABYLON {
  108796. /** @hidden */
  108797. export var backgroundFragmentDeclaration: {
  108798. name: string;
  108799. shader: string;
  108800. };
  108801. }
  108802. declare module BABYLON {
  108803. /** @hidden */
  108804. export var backgroundUboDeclaration: {
  108805. name: string;
  108806. shader: string;
  108807. };
  108808. }
  108809. declare module BABYLON {
  108810. /** @hidden */
  108811. export var backgroundPixelShader: {
  108812. name: string;
  108813. shader: string;
  108814. };
  108815. }
  108816. declare module BABYLON {
  108817. /** @hidden */
  108818. export var backgroundVertexDeclaration: {
  108819. name: string;
  108820. shader: string;
  108821. };
  108822. }
  108823. declare module BABYLON {
  108824. /** @hidden */
  108825. export var backgroundVertexShader: {
  108826. name: string;
  108827. shader: string;
  108828. };
  108829. }
  108830. declare module BABYLON {
  108831. /**
  108832. * Background material used to create an efficient environement around your scene.
  108833. */
  108834. export class BackgroundMaterial extends PushMaterial {
  108835. /**
  108836. * Standard reflectance value at parallel view angle.
  108837. */
  108838. static StandardReflectance0: number;
  108839. /**
  108840. * Standard reflectance value at grazing angle.
  108841. */
  108842. static StandardReflectance90: number;
  108843. protected _primaryColor: Color3;
  108844. /**
  108845. * Key light Color (multiply against the environement texture)
  108846. */
  108847. primaryColor: Color3;
  108848. protected __perceptualColor: Nullable<Color3>;
  108849. /**
  108850. * Experimental Internal Use Only.
  108851. *
  108852. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108853. * This acts as a helper to set the primary color to a more "human friendly" value.
  108854. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108855. * output color as close as possible from the chosen value.
  108856. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108857. * part of lighting setup.)
  108858. */
  108859. _perceptualColor: Nullable<Color3>;
  108860. protected _primaryColorShadowLevel: float;
  108861. /**
  108862. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108863. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108864. */
  108865. primaryColorShadowLevel: float;
  108866. protected _primaryColorHighlightLevel: float;
  108867. /**
  108868. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108869. * The primary color is used at the level chosen to define what the white area would look.
  108870. */
  108871. primaryColorHighlightLevel: float;
  108872. protected _reflectionTexture: Nullable<BaseTexture>;
  108873. /**
  108874. * Reflection Texture used in the material.
  108875. * Should be author in a specific way for the best result (refer to the documentation).
  108876. */
  108877. reflectionTexture: Nullable<BaseTexture>;
  108878. protected _reflectionBlur: float;
  108879. /**
  108880. * Reflection Texture level of blur.
  108881. *
  108882. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108883. * texture twice.
  108884. */
  108885. reflectionBlur: float;
  108886. protected _diffuseTexture: Nullable<BaseTexture>;
  108887. /**
  108888. * Diffuse Texture used in the material.
  108889. * Should be author in a specific way for the best result (refer to the documentation).
  108890. */
  108891. diffuseTexture: Nullable<BaseTexture>;
  108892. protected _shadowLights: Nullable<IShadowLight[]>;
  108893. /**
  108894. * Specify the list of lights casting shadow on the material.
  108895. * All scene shadow lights will be included if null.
  108896. */
  108897. shadowLights: Nullable<IShadowLight[]>;
  108898. protected _shadowLevel: float;
  108899. /**
  108900. * Helps adjusting the shadow to a softer level if required.
  108901. * 0 means black shadows and 1 means no shadows.
  108902. */
  108903. shadowLevel: float;
  108904. protected _sceneCenter: Vector3;
  108905. /**
  108906. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108907. * It is usually zero but might be interesting to modify according to your setup.
  108908. */
  108909. sceneCenter: Vector3;
  108910. protected _opacityFresnel: boolean;
  108911. /**
  108912. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108913. * This helps ensuring a nice transition when the camera goes under the ground.
  108914. */
  108915. opacityFresnel: boolean;
  108916. protected _reflectionFresnel: boolean;
  108917. /**
  108918. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108919. * This helps adding a mirror texture on the ground.
  108920. */
  108921. reflectionFresnel: boolean;
  108922. protected _reflectionFalloffDistance: number;
  108923. /**
  108924. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108925. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108926. */
  108927. reflectionFalloffDistance: number;
  108928. protected _reflectionAmount: number;
  108929. /**
  108930. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108931. */
  108932. reflectionAmount: number;
  108933. protected _reflectionReflectance0: number;
  108934. /**
  108935. * This specifies the weight of the reflection at grazing angle.
  108936. */
  108937. reflectionReflectance0: number;
  108938. protected _reflectionReflectance90: number;
  108939. /**
  108940. * This specifies the weight of the reflection at a perpendicular point of view.
  108941. */
  108942. reflectionReflectance90: number;
  108943. /**
  108944. * Sets the reflection reflectance fresnel values according to the default standard
  108945. * empirically know to work well :-)
  108946. */
  108947. reflectionStandardFresnelWeight: number;
  108948. protected _useRGBColor: boolean;
  108949. /**
  108950. * Helps to directly use the maps channels instead of their level.
  108951. */
  108952. useRGBColor: boolean;
  108953. protected _enableNoise: boolean;
  108954. /**
  108955. * This helps reducing the banding effect that could occur on the background.
  108956. */
  108957. enableNoise: boolean;
  108958. /**
  108959. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108960. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108961. * Recommended to be keep at 1.0 except for special cases.
  108962. */
  108963. fovMultiplier: number;
  108964. private _fovMultiplier;
  108965. /**
  108966. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108967. */
  108968. useEquirectangularFOV: boolean;
  108969. private _maxSimultaneousLights;
  108970. /**
  108971. * Number of Simultaneous lights allowed on the material.
  108972. */
  108973. maxSimultaneousLights: int;
  108974. /**
  108975. * Default configuration related to image processing available in the Background Material.
  108976. */
  108977. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108978. /**
  108979. * Keep track of the image processing observer to allow dispose and replace.
  108980. */
  108981. private _imageProcessingObserver;
  108982. /**
  108983. * Attaches a new image processing configuration to the PBR Material.
  108984. * @param configuration (if null the scene configuration will be use)
  108985. */
  108986. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108987. /**
  108988. * Gets the image processing configuration used either in this material.
  108989. */
  108990. /**
  108991. * Sets the Default image processing configuration used either in the this material.
  108992. *
  108993. * If sets to null, the scene one is in use.
  108994. */
  108995. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108996. /**
  108997. * Gets wether the color curves effect is enabled.
  108998. */
  108999. /**
  109000. * Sets wether the color curves effect is enabled.
  109001. */
  109002. cameraColorCurvesEnabled: boolean;
  109003. /**
  109004. * Gets wether the color grading effect is enabled.
  109005. */
  109006. /**
  109007. * Gets wether the color grading effect is enabled.
  109008. */
  109009. cameraColorGradingEnabled: boolean;
  109010. /**
  109011. * Gets wether tonemapping is enabled or not.
  109012. */
  109013. /**
  109014. * Sets wether tonemapping is enabled or not
  109015. */
  109016. cameraToneMappingEnabled: boolean;
  109017. /**
  109018. * The camera exposure used on this material.
  109019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109020. * This corresponds to a photographic exposure.
  109021. */
  109022. /**
  109023. * The camera exposure used on this material.
  109024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109025. * This corresponds to a photographic exposure.
  109026. */
  109027. cameraExposure: float;
  109028. /**
  109029. * Gets The camera contrast used on this material.
  109030. */
  109031. /**
  109032. * Sets The camera contrast used on this material.
  109033. */
  109034. cameraContrast: float;
  109035. /**
  109036. * Gets the Color Grading 2D Lookup Texture.
  109037. */
  109038. /**
  109039. * Sets the Color Grading 2D Lookup Texture.
  109040. */
  109041. cameraColorGradingTexture: Nullable<BaseTexture>;
  109042. /**
  109043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109045. * 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;
  109046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109047. */
  109048. /**
  109049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109051. * 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;
  109052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109053. */
  109054. cameraColorCurves: Nullable<ColorCurves>;
  109055. /**
  109056. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  109057. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  109058. */
  109059. switchToBGR: boolean;
  109060. private _renderTargets;
  109061. private _reflectionControls;
  109062. private _white;
  109063. private _primaryShadowColor;
  109064. private _primaryHighlightColor;
  109065. /**
  109066. * Instantiates a Background Material in the given scene
  109067. * @param name The friendly name of the material
  109068. * @param scene The scene to add the material to
  109069. */
  109070. constructor(name: string, scene: Scene);
  109071. /**
  109072. * Gets a boolean indicating that current material needs to register RTT
  109073. */
  109074. readonly hasRenderTargetTextures: boolean;
  109075. /**
  109076. * The entire material has been created in order to prevent overdraw.
  109077. * @returns false
  109078. */
  109079. needAlphaTesting(): boolean;
  109080. /**
  109081. * The entire material has been created in order to prevent overdraw.
  109082. * @returns true if blending is enable
  109083. */
  109084. needAlphaBlending(): boolean;
  109085. /**
  109086. * Checks wether the material is ready to be rendered for a given mesh.
  109087. * @param mesh The mesh to render
  109088. * @param subMesh The submesh to check against
  109089. * @param useInstances Specify wether or not the material is used with instances
  109090. * @returns true if all the dependencies are ready (Textures, Effects...)
  109091. */
  109092. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109093. /**
  109094. * Compute the primary color according to the chosen perceptual color.
  109095. */
  109096. private _computePrimaryColorFromPerceptualColor;
  109097. /**
  109098. * Compute the highlights and shadow colors according to their chosen levels.
  109099. */
  109100. private _computePrimaryColors;
  109101. /**
  109102. * Build the uniform buffer used in the material.
  109103. */
  109104. buildUniformLayout(): void;
  109105. /**
  109106. * Unbind the material.
  109107. */
  109108. unbind(): void;
  109109. /**
  109110. * Bind only the world matrix to the material.
  109111. * @param world The world matrix to bind.
  109112. */
  109113. bindOnlyWorldMatrix(world: Matrix): void;
  109114. /**
  109115. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  109116. * @param world The world matrix to bind.
  109117. * @param subMesh The submesh to bind for.
  109118. */
  109119. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109120. /**
  109121. * Dispose the material.
  109122. * @param forceDisposeEffect Force disposal of the associated effect.
  109123. * @param forceDisposeTextures Force disposal of the associated textures.
  109124. */
  109125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109126. /**
  109127. * Clones the material.
  109128. * @param name The cloned name.
  109129. * @returns The cloned material.
  109130. */
  109131. clone(name: string): BackgroundMaterial;
  109132. /**
  109133. * Serializes the current material to its JSON representation.
  109134. * @returns The JSON representation.
  109135. */
  109136. serialize(): any;
  109137. /**
  109138. * Gets the class name of the material
  109139. * @returns "BackgroundMaterial"
  109140. */
  109141. getClassName(): string;
  109142. /**
  109143. * Parse a JSON input to create back a background material.
  109144. * @param source The JSON data to parse
  109145. * @param scene The scene to create the parsed material in
  109146. * @param rootUrl The root url of the assets the material depends upon
  109147. * @returns the instantiated BackgroundMaterial.
  109148. */
  109149. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  109150. }
  109151. }
  109152. declare module BABYLON {
  109153. /**
  109154. * Represents the different options available during the creation of
  109155. * a Environment helper.
  109156. *
  109157. * This can control the default ground, skybox and image processing setup of your scene.
  109158. */
  109159. export interface IEnvironmentHelperOptions {
  109160. /**
  109161. * Specifies wether or not to create a ground.
  109162. * True by default.
  109163. */
  109164. createGround: boolean;
  109165. /**
  109166. * Specifies the ground size.
  109167. * 15 by default.
  109168. */
  109169. groundSize: number;
  109170. /**
  109171. * The texture used on the ground for the main color.
  109172. * Comes from the BabylonJS CDN by default.
  109173. *
  109174. * Remarks: Can be either a texture or a url.
  109175. */
  109176. groundTexture: string | BaseTexture;
  109177. /**
  109178. * The color mixed in the ground texture by default.
  109179. * BabylonJS clearColor by default.
  109180. */
  109181. groundColor: Color3;
  109182. /**
  109183. * Specifies the ground opacity.
  109184. * 1 by default.
  109185. */
  109186. groundOpacity: number;
  109187. /**
  109188. * Enables the ground to receive shadows.
  109189. * True by default.
  109190. */
  109191. enableGroundShadow: boolean;
  109192. /**
  109193. * Helps preventing the shadow to be fully black on the ground.
  109194. * 0.5 by default.
  109195. */
  109196. groundShadowLevel: number;
  109197. /**
  109198. * Creates a mirror texture attach to the ground.
  109199. * false by default.
  109200. */
  109201. enableGroundMirror: boolean;
  109202. /**
  109203. * Specifies the ground mirror size ratio.
  109204. * 0.3 by default as the default kernel is 64.
  109205. */
  109206. groundMirrorSizeRatio: number;
  109207. /**
  109208. * Specifies the ground mirror blur kernel size.
  109209. * 64 by default.
  109210. */
  109211. groundMirrorBlurKernel: number;
  109212. /**
  109213. * Specifies the ground mirror visibility amount.
  109214. * 1 by default
  109215. */
  109216. groundMirrorAmount: number;
  109217. /**
  109218. * Specifies the ground mirror reflectance weight.
  109219. * This uses the standard weight of the background material to setup the fresnel effect
  109220. * of the mirror.
  109221. * 1 by default.
  109222. */
  109223. groundMirrorFresnelWeight: number;
  109224. /**
  109225. * Specifies the ground mirror Falloff distance.
  109226. * This can helps reducing the size of the reflection.
  109227. * 0 by Default.
  109228. */
  109229. groundMirrorFallOffDistance: number;
  109230. /**
  109231. * Specifies the ground mirror texture type.
  109232. * Unsigned Int by Default.
  109233. */
  109234. groundMirrorTextureType: number;
  109235. /**
  109236. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  109237. * the shown objects.
  109238. */
  109239. groundYBias: number;
  109240. /**
  109241. * Specifies wether or not to create a skybox.
  109242. * True by default.
  109243. */
  109244. createSkybox: boolean;
  109245. /**
  109246. * Specifies the skybox size.
  109247. * 20 by default.
  109248. */
  109249. skyboxSize: number;
  109250. /**
  109251. * The texture used on the skybox for the main color.
  109252. * Comes from the BabylonJS CDN by default.
  109253. *
  109254. * Remarks: Can be either a texture or a url.
  109255. */
  109256. skyboxTexture: string | BaseTexture;
  109257. /**
  109258. * The color mixed in the skybox texture by default.
  109259. * BabylonJS clearColor by default.
  109260. */
  109261. skyboxColor: Color3;
  109262. /**
  109263. * The background rotation around the Y axis of the scene.
  109264. * This helps aligning the key lights of your scene with the background.
  109265. * 0 by default.
  109266. */
  109267. backgroundYRotation: number;
  109268. /**
  109269. * Compute automatically the size of the elements to best fit with the scene.
  109270. */
  109271. sizeAuto: boolean;
  109272. /**
  109273. * Default position of the rootMesh if autoSize is not true.
  109274. */
  109275. rootPosition: Vector3;
  109276. /**
  109277. * Sets up the image processing in the scene.
  109278. * true by default.
  109279. */
  109280. setupImageProcessing: boolean;
  109281. /**
  109282. * The texture used as your environment texture in the scene.
  109283. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  109284. *
  109285. * Remarks: Can be either a texture or a url.
  109286. */
  109287. environmentTexture: string | BaseTexture;
  109288. /**
  109289. * The value of the exposure to apply to the scene.
  109290. * 0.6 by default if setupImageProcessing is true.
  109291. */
  109292. cameraExposure: number;
  109293. /**
  109294. * The value of the contrast to apply to the scene.
  109295. * 1.6 by default if setupImageProcessing is true.
  109296. */
  109297. cameraContrast: number;
  109298. /**
  109299. * Specifies wether or not tonemapping should be enabled in the scene.
  109300. * true by default if setupImageProcessing is true.
  109301. */
  109302. toneMappingEnabled: boolean;
  109303. }
  109304. /**
  109305. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  109306. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  109307. * It also helps with the default setup of your imageProcessing configuration.
  109308. */
  109309. export class EnvironmentHelper {
  109310. /**
  109311. * Default ground texture URL.
  109312. */
  109313. private static _groundTextureCDNUrl;
  109314. /**
  109315. * Default skybox texture URL.
  109316. */
  109317. private static _skyboxTextureCDNUrl;
  109318. /**
  109319. * Default environment texture URL.
  109320. */
  109321. private static _environmentTextureCDNUrl;
  109322. /**
  109323. * Creates the default options for the helper.
  109324. */
  109325. private static _getDefaultOptions;
  109326. private _rootMesh;
  109327. /**
  109328. * Gets the root mesh created by the helper.
  109329. */
  109330. readonly rootMesh: Mesh;
  109331. private _skybox;
  109332. /**
  109333. * Gets the skybox created by the helper.
  109334. */
  109335. readonly skybox: Nullable<Mesh>;
  109336. private _skyboxTexture;
  109337. /**
  109338. * Gets the skybox texture created by the helper.
  109339. */
  109340. readonly skyboxTexture: Nullable<BaseTexture>;
  109341. private _skyboxMaterial;
  109342. /**
  109343. * Gets the skybox material created by the helper.
  109344. */
  109345. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  109346. private _ground;
  109347. /**
  109348. * Gets the ground mesh created by the helper.
  109349. */
  109350. readonly ground: Nullable<Mesh>;
  109351. private _groundTexture;
  109352. /**
  109353. * Gets the ground texture created by the helper.
  109354. */
  109355. readonly groundTexture: Nullable<BaseTexture>;
  109356. private _groundMirror;
  109357. /**
  109358. * Gets the ground mirror created by the helper.
  109359. */
  109360. readonly groundMirror: Nullable<MirrorTexture>;
  109361. /**
  109362. * Gets the ground mirror render list to helps pushing the meshes
  109363. * you wish in the ground reflection.
  109364. */
  109365. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  109366. private _groundMaterial;
  109367. /**
  109368. * Gets the ground material created by the helper.
  109369. */
  109370. readonly groundMaterial: Nullable<BackgroundMaterial>;
  109371. /**
  109372. * Stores the creation options.
  109373. */
  109374. private readonly _scene;
  109375. private _options;
  109376. /**
  109377. * This observable will be notified with any error during the creation of the environment,
  109378. * mainly texture creation errors.
  109379. */
  109380. onErrorObservable: Observable<{
  109381. message?: string;
  109382. exception?: any;
  109383. }>;
  109384. /**
  109385. * constructor
  109386. * @param options Defines the options we want to customize the helper
  109387. * @param scene The scene to add the material to
  109388. */
  109389. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  109390. /**
  109391. * Updates the background according to the new options
  109392. * @param options
  109393. */
  109394. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  109395. /**
  109396. * Sets the primary color of all the available elements.
  109397. * @param color the main color to affect to the ground and the background
  109398. */
  109399. setMainColor(color: Color3): void;
  109400. /**
  109401. * Setup the image processing according to the specified options.
  109402. */
  109403. private _setupImageProcessing;
  109404. /**
  109405. * Setup the environment texture according to the specified options.
  109406. */
  109407. private _setupEnvironmentTexture;
  109408. /**
  109409. * Setup the background according to the specified options.
  109410. */
  109411. private _setupBackground;
  109412. /**
  109413. * Get the scene sizes according to the setup.
  109414. */
  109415. private _getSceneSize;
  109416. /**
  109417. * Setup the ground according to the specified options.
  109418. */
  109419. private _setupGround;
  109420. /**
  109421. * Setup the ground material according to the specified options.
  109422. */
  109423. private _setupGroundMaterial;
  109424. /**
  109425. * Setup the ground diffuse texture according to the specified options.
  109426. */
  109427. private _setupGroundDiffuseTexture;
  109428. /**
  109429. * Setup the ground mirror texture according to the specified options.
  109430. */
  109431. private _setupGroundMirrorTexture;
  109432. /**
  109433. * Setup the ground to receive the mirror texture.
  109434. */
  109435. private _setupMirrorInGroundMaterial;
  109436. /**
  109437. * Setup the skybox according to the specified options.
  109438. */
  109439. private _setupSkybox;
  109440. /**
  109441. * Setup the skybox material according to the specified options.
  109442. */
  109443. private _setupSkyboxMaterial;
  109444. /**
  109445. * Setup the skybox reflection texture according to the specified options.
  109446. */
  109447. private _setupSkyboxReflectionTexture;
  109448. private _errorHandler;
  109449. /**
  109450. * Dispose all the elements created by the Helper.
  109451. */
  109452. dispose(): void;
  109453. }
  109454. }
  109455. declare module BABYLON {
  109456. /**
  109457. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  109458. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  109459. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  109460. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109461. */
  109462. export class PhotoDome extends TransformNode {
  109463. /**
  109464. * Define the image as a Monoscopic panoramic 360 image.
  109465. */
  109466. static readonly MODE_MONOSCOPIC: number;
  109467. /**
  109468. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109469. */
  109470. static readonly MODE_TOPBOTTOM: number;
  109471. /**
  109472. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109473. */
  109474. static readonly MODE_SIDEBYSIDE: number;
  109475. private _useDirectMapping;
  109476. /**
  109477. * The texture being displayed on the sphere
  109478. */
  109479. protected _photoTexture: Texture;
  109480. /**
  109481. * Gets or sets the texture being displayed on the sphere
  109482. */
  109483. photoTexture: Texture;
  109484. /**
  109485. * Observable raised when an error occured while loading the 360 image
  109486. */
  109487. onLoadErrorObservable: Observable<string>;
  109488. /**
  109489. * The skybox material
  109490. */
  109491. protected _material: BackgroundMaterial;
  109492. /**
  109493. * The surface used for the skybox
  109494. */
  109495. protected _mesh: Mesh;
  109496. /**
  109497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109498. * Also see the options.resolution property.
  109499. */
  109500. fovMultiplier: number;
  109501. private _imageMode;
  109502. /**
  109503. * Gets or set the current video mode for the video. It can be:
  109504. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  109505. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  109506. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  109507. */
  109508. imageMode: number;
  109509. /**
  109510. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  109511. * @param name Element's name, child elements will append suffixes for their own names.
  109512. * @param urlsOfPhoto defines the url of the photo to display
  109513. * @param options defines an object containing optional or exposed sub element properties
  109514. * @param onError defines a callback called when an error occured while loading the texture
  109515. */
  109516. constructor(name: string, urlOfPhoto: string, options: {
  109517. resolution?: number;
  109518. size?: number;
  109519. useDirectMapping?: boolean;
  109520. faceForward?: boolean;
  109521. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  109522. private _onBeforeCameraRenderObserver;
  109523. private _changeImageMode;
  109524. /**
  109525. * Releases resources associated with this node.
  109526. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109527. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109528. */
  109529. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109530. }
  109531. }
  109532. declare module BABYLON {
  109533. /** @hidden */
  109534. export var rgbdDecodePixelShader: {
  109535. name: string;
  109536. shader: string;
  109537. };
  109538. }
  109539. declare module BABYLON {
  109540. /**
  109541. * Class used to host texture specific utilities
  109542. */
  109543. export class BRDFTextureTools {
  109544. /**
  109545. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  109546. * @param texture the texture to expand.
  109547. */
  109548. private static _ExpandDefaultBRDFTexture;
  109549. /**
  109550. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  109551. * @param scene defines the hosting scene
  109552. * @returns the environment BRDF texture
  109553. */
  109554. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  109555. private static _environmentBRDFBase64Texture;
  109556. }
  109557. }
  109558. declare module BABYLON {
  109559. /**
  109560. * @hidden
  109561. */
  109562. export interface IMaterialClearCoatDefines {
  109563. CLEARCOAT: boolean;
  109564. CLEARCOAT_DEFAULTIOR: boolean;
  109565. CLEARCOAT_TEXTURE: boolean;
  109566. CLEARCOAT_TEXTUREDIRECTUV: number;
  109567. CLEARCOAT_BUMP: boolean;
  109568. CLEARCOAT_BUMPDIRECTUV: number;
  109569. CLEARCOAT_TINT: boolean;
  109570. CLEARCOAT_TINT_TEXTURE: boolean;
  109571. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109572. /** @hidden */
  109573. _areTexturesDirty: boolean;
  109574. }
  109575. /**
  109576. * Define the code related to the clear coat parameters of the pbr material.
  109577. */
  109578. export class PBRClearCoatConfiguration {
  109579. /**
  109580. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109581. * The default fits with a polyurethane material.
  109582. */
  109583. private static readonly _DefaultIndexOfRefraction;
  109584. private _isEnabled;
  109585. /**
  109586. * Defines if the clear coat is enabled in the material.
  109587. */
  109588. isEnabled: boolean;
  109589. /**
  109590. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  109591. */
  109592. intensity: number;
  109593. /**
  109594. * Defines the clear coat layer roughness.
  109595. */
  109596. roughness: number;
  109597. private _indexOfRefraction;
  109598. /**
  109599. * Defines the index of refraction of the clear coat.
  109600. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109601. * The default fits with a polyurethane material.
  109602. * Changing the default value is more performance intensive.
  109603. */
  109604. indexOfRefraction: number;
  109605. private _texture;
  109606. /**
  109607. * Stores the clear coat values in a texture.
  109608. */
  109609. texture: Nullable<BaseTexture>;
  109610. private _bumpTexture;
  109611. /**
  109612. * Define the clear coat specific bump texture.
  109613. */
  109614. bumpTexture: Nullable<BaseTexture>;
  109615. private _isTintEnabled;
  109616. /**
  109617. * Defines if the clear coat tint is enabled in the material.
  109618. */
  109619. isTintEnabled: boolean;
  109620. /**
  109621. * Defines the clear coat tint of the material.
  109622. * This is only use if tint is enabled
  109623. */
  109624. tintColor: Color3;
  109625. /**
  109626. * Defines the distance at which the tint color should be found in the
  109627. * clear coat media.
  109628. * This is only use if tint is enabled
  109629. */
  109630. tintColorAtDistance: number;
  109631. /**
  109632. * Defines the clear coat layer thickness.
  109633. * This is only use if tint is enabled
  109634. */
  109635. tintThickness: number;
  109636. private _tintTexture;
  109637. /**
  109638. * Stores the clear tint values in a texture.
  109639. * rgb is tint
  109640. * a is a thickness factor
  109641. */
  109642. tintTexture: Nullable<BaseTexture>;
  109643. /** @hidden */
  109644. private _internalMarkAllSubMeshesAsTexturesDirty;
  109645. /** @hidden */
  109646. _markAllSubMeshesAsTexturesDirty(): void;
  109647. /**
  109648. * Instantiate a new istance of clear coat configuration.
  109649. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109650. */
  109651. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109652. /**
  109653. * Gets wehter the submesh is ready to be used or not.
  109654. * @param defines the list of "defines" to update.
  109655. * @param scene defines the scene the material belongs to.
  109656. * @param engine defines the engine the material belongs to.
  109657. * @param disableBumpMap defines wether the material disables bump or not.
  109658. * @returns - boolean indicating that the submesh is ready or not.
  109659. */
  109660. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  109661. /**
  109662. * Checks to see if a texture is used in the material.
  109663. * @param defines the list of "defines" to update.
  109664. * @param scene defines the scene to the material belongs to.
  109665. */
  109666. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  109667. /**
  109668. * Binds the material data.
  109669. * @param uniformBuffer defines the Uniform buffer to fill in.
  109670. * @param scene defines the scene the material belongs to.
  109671. * @param engine defines the engine the material belongs to.
  109672. * @param disableBumpMap defines wether the material disables bump or not.
  109673. * @param isFrozen defines wether the material is frozen or not.
  109674. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109675. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109676. */
  109677. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  109678. /**
  109679. * Checks to see if a texture is used in the material.
  109680. * @param texture - Base texture to use.
  109681. * @returns - Boolean specifying if a texture is used in the material.
  109682. */
  109683. hasTexture(texture: BaseTexture): boolean;
  109684. /**
  109685. * Returns an array of the actively used textures.
  109686. * @param activeTextures Array of BaseTextures
  109687. */
  109688. getActiveTextures(activeTextures: BaseTexture[]): void;
  109689. /**
  109690. * Returns the animatable textures.
  109691. * @param animatables Array of animatable textures.
  109692. */
  109693. getAnimatables(animatables: IAnimatable[]): void;
  109694. /**
  109695. * Disposes the resources of the material.
  109696. * @param forceDisposeTextures - Forces the disposal of all textures.
  109697. */
  109698. dispose(forceDisposeTextures?: boolean): void;
  109699. /**
  109700. * Get the current class name of the texture useful for serialization or dynamic coding.
  109701. * @returns "PBRClearCoatConfiguration"
  109702. */
  109703. getClassName(): string;
  109704. /**
  109705. * Add fallbacks to the effect fallbacks list.
  109706. * @param defines defines the Base texture to use.
  109707. * @param fallbacks defines the current fallback list.
  109708. * @param currentRank defines the current fallback rank.
  109709. * @returns the new fallback rank.
  109710. */
  109711. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109712. /**
  109713. * Add the required uniforms to the current list.
  109714. * @param uniforms defines the current uniform list.
  109715. */
  109716. static AddUniforms(uniforms: string[]): void;
  109717. /**
  109718. * Add the required samplers to the current list.
  109719. * @param samplers defines the current sampler list.
  109720. */
  109721. static AddSamplers(samplers: string[]): void;
  109722. /**
  109723. * Add the required uniforms to the current buffer.
  109724. * @param uniformBuffer defines the current uniform buffer.
  109725. */
  109726. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109727. /**
  109728. * Makes a duplicate of the current configuration into another one.
  109729. * @param clearCoatConfiguration define the config where to copy the info
  109730. */
  109731. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  109732. /**
  109733. * Serializes this clear coat configuration.
  109734. * @returns - An object with the serialized config.
  109735. */
  109736. serialize(): any;
  109737. /**
  109738. * Parses a anisotropy Configuration from a serialized object.
  109739. * @param source - Serialized object.
  109740. * @param scene Defines the scene we are parsing for
  109741. * @param rootUrl Defines the rootUrl to load from
  109742. */
  109743. parse(source: any, scene: Scene, rootUrl: string): void;
  109744. }
  109745. }
  109746. declare module BABYLON {
  109747. /**
  109748. * @hidden
  109749. */
  109750. export interface IMaterialAnisotropicDefines {
  109751. ANISOTROPIC: boolean;
  109752. ANISOTROPIC_TEXTURE: boolean;
  109753. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109754. MAINUV1: boolean;
  109755. _areTexturesDirty: boolean;
  109756. _needUVs: boolean;
  109757. }
  109758. /**
  109759. * Define the code related to the anisotropic parameters of the pbr material.
  109760. */
  109761. export class PBRAnisotropicConfiguration {
  109762. private _isEnabled;
  109763. /**
  109764. * Defines if the anisotropy is enabled in the material.
  109765. */
  109766. isEnabled: boolean;
  109767. /**
  109768. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109769. */
  109770. intensity: number;
  109771. /**
  109772. * Defines if the effect is along the tangents, bitangents or in between.
  109773. * By default, the effect is "strectching" the highlights along the tangents.
  109774. */
  109775. direction: Vector2;
  109776. private _texture;
  109777. /**
  109778. * Stores the anisotropy values in a texture.
  109779. * rg is direction (like normal from -1 to 1)
  109780. * b is a intensity
  109781. */
  109782. texture: Nullable<BaseTexture>;
  109783. /** @hidden */
  109784. private _internalMarkAllSubMeshesAsTexturesDirty;
  109785. /** @hidden */
  109786. _markAllSubMeshesAsTexturesDirty(): void;
  109787. /**
  109788. * Instantiate a new istance of anisotropy configuration.
  109789. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109790. */
  109791. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109792. /**
  109793. * Specifies that the submesh is ready to be used.
  109794. * @param defines the list of "defines" to update.
  109795. * @param scene defines the scene the material belongs to.
  109796. * @returns - boolean indicating that the submesh is ready or not.
  109797. */
  109798. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109799. /**
  109800. * Checks to see if a texture is used in the material.
  109801. * @param defines the list of "defines" to update.
  109802. * @param mesh the mesh we are preparing the defines for.
  109803. * @param scene defines the scene the material belongs to.
  109804. */
  109805. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109806. /**
  109807. * Binds the material data.
  109808. * @param uniformBuffer defines the Uniform buffer to fill in.
  109809. * @param scene defines the scene the material belongs to.
  109810. * @param isFrozen defines wether the material is frozen or not.
  109811. */
  109812. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109813. /**
  109814. * Checks to see if a texture is used in the material.
  109815. * @param texture - Base texture to use.
  109816. * @returns - Boolean specifying if a texture is used in the material.
  109817. */
  109818. hasTexture(texture: BaseTexture): boolean;
  109819. /**
  109820. * Returns an array of the actively used textures.
  109821. * @param activeTextures Array of BaseTextures
  109822. */
  109823. getActiveTextures(activeTextures: BaseTexture[]): void;
  109824. /**
  109825. * Returns the animatable textures.
  109826. * @param animatables Array of animatable textures.
  109827. */
  109828. getAnimatables(animatables: IAnimatable[]): void;
  109829. /**
  109830. * Disposes the resources of the material.
  109831. * @param forceDisposeTextures - Forces the disposal of all textures.
  109832. */
  109833. dispose(forceDisposeTextures?: boolean): void;
  109834. /**
  109835. * Get the current class name of the texture useful for serialization or dynamic coding.
  109836. * @returns "PBRAnisotropicConfiguration"
  109837. */
  109838. getClassName(): string;
  109839. /**
  109840. * Add fallbacks to the effect fallbacks list.
  109841. * @param defines defines the Base texture to use.
  109842. * @param fallbacks defines the current fallback list.
  109843. * @param currentRank defines the current fallback rank.
  109844. * @returns the new fallback rank.
  109845. */
  109846. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109847. /**
  109848. * Add the required uniforms to the current list.
  109849. * @param uniforms defines the current uniform list.
  109850. */
  109851. static AddUniforms(uniforms: string[]): void;
  109852. /**
  109853. * Add the required uniforms to the current buffer.
  109854. * @param uniformBuffer defines the current uniform buffer.
  109855. */
  109856. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109857. /**
  109858. * Add the required samplers to the current list.
  109859. * @param samplers defines the current sampler list.
  109860. */
  109861. static AddSamplers(samplers: string[]): void;
  109862. /**
  109863. * Makes a duplicate of the current configuration into another one.
  109864. * @param anisotropicConfiguration define the config where to copy the info
  109865. */
  109866. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109867. /**
  109868. * Serializes this anisotropy configuration.
  109869. * @returns - An object with the serialized config.
  109870. */
  109871. serialize(): any;
  109872. /**
  109873. * Parses a anisotropy Configuration from a serialized object.
  109874. * @param source - Serialized object.
  109875. * @param scene Defines the scene we are parsing for
  109876. * @param rootUrl Defines the rootUrl to load from
  109877. */
  109878. parse(source: any, scene: Scene, rootUrl: string): void;
  109879. }
  109880. }
  109881. declare module BABYLON {
  109882. /**
  109883. * @hidden
  109884. */
  109885. export interface IMaterialBRDFDefines {
  109886. BRDF_V_HEIGHT_CORRELATED: boolean;
  109887. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109888. SPHERICAL_HARMONICS: boolean;
  109889. /** @hidden */
  109890. _areMiscDirty: boolean;
  109891. }
  109892. /**
  109893. * Define the code related to the BRDF parameters of the pbr material.
  109894. */
  109895. export class PBRBRDFConfiguration {
  109896. /**
  109897. * Default value used for the energy conservation.
  109898. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109899. */
  109900. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109901. /**
  109902. * Default value used for the Smith Visibility Height Correlated mode.
  109903. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109904. */
  109905. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109906. /**
  109907. * Default value used for the IBL diffuse part.
  109908. * This can help switching back to the polynomials mode globally which is a tiny bit
  109909. * less GPU intensive at the drawback of a lower quality.
  109910. */
  109911. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109912. private _useEnergyConservation;
  109913. /**
  109914. * Defines if the material uses energy conservation.
  109915. */
  109916. useEnergyConservation: boolean;
  109917. private _useSmithVisibilityHeightCorrelated;
  109918. /**
  109919. * LEGACY Mode set to false
  109920. * Defines if the material uses height smith correlated visibility term.
  109921. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109922. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109923. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109924. * Not relying on height correlated will also disable energy conservation.
  109925. */
  109926. useSmithVisibilityHeightCorrelated: boolean;
  109927. private _useSphericalHarmonics;
  109928. /**
  109929. * LEGACY Mode set to false
  109930. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109931. * diffuse part of the IBL.
  109932. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109933. * to the ground truth.
  109934. */
  109935. useSphericalHarmonics: boolean;
  109936. /** @hidden */
  109937. private _internalMarkAllSubMeshesAsMiscDirty;
  109938. /** @hidden */
  109939. _markAllSubMeshesAsMiscDirty(): void;
  109940. /**
  109941. * Instantiate a new istance of clear coat configuration.
  109942. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109943. */
  109944. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109945. /**
  109946. * Checks to see if a texture is used in the material.
  109947. * @param defines the list of "defines" to update.
  109948. */
  109949. prepareDefines(defines: IMaterialBRDFDefines): void;
  109950. /**
  109951. * Get the current class name of the texture useful for serialization or dynamic coding.
  109952. * @returns "PBRClearCoatConfiguration"
  109953. */
  109954. getClassName(): string;
  109955. /**
  109956. * Makes a duplicate of the current configuration into another one.
  109957. * @param brdfConfiguration define the config where to copy the info
  109958. */
  109959. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109960. /**
  109961. * Serializes this BRDF configuration.
  109962. * @returns - An object with the serialized config.
  109963. */
  109964. serialize(): any;
  109965. /**
  109966. * Parses a anisotropy Configuration from a serialized object.
  109967. * @param source - Serialized object.
  109968. * @param scene Defines the scene we are parsing for
  109969. * @param rootUrl Defines the rootUrl to load from
  109970. */
  109971. parse(source: any, scene: Scene, rootUrl: string): void;
  109972. }
  109973. }
  109974. declare module BABYLON {
  109975. /**
  109976. * @hidden
  109977. */
  109978. export interface IMaterialSheenDefines {
  109979. SHEEN: boolean;
  109980. SHEEN_TEXTURE: boolean;
  109981. SHEEN_TEXTUREDIRECTUV: number;
  109982. SHEEN_LINKWITHALBEDO: boolean;
  109983. /** @hidden */
  109984. _areTexturesDirty: boolean;
  109985. }
  109986. /**
  109987. * Define the code related to the Sheen parameters of the pbr material.
  109988. */
  109989. export class PBRSheenConfiguration {
  109990. private _isEnabled;
  109991. /**
  109992. * Defines if the material uses sheen.
  109993. */
  109994. isEnabled: boolean;
  109995. private _linkSheenWithAlbedo;
  109996. /**
  109997. * Defines if the sheen is linked to the sheen color.
  109998. */
  109999. linkSheenWithAlbedo: boolean;
  110000. /**
  110001. * Defines the sheen intensity.
  110002. */
  110003. intensity: number;
  110004. /**
  110005. * Defines the sheen color.
  110006. */
  110007. color: Color3;
  110008. private _texture;
  110009. /**
  110010. * Stores the sheen tint values in a texture.
  110011. * rgb is tint
  110012. * a is a intensity
  110013. */
  110014. texture: Nullable<BaseTexture>;
  110015. /** @hidden */
  110016. private _internalMarkAllSubMeshesAsTexturesDirty;
  110017. /** @hidden */
  110018. _markAllSubMeshesAsTexturesDirty(): void;
  110019. /**
  110020. * Instantiate a new istance of clear coat configuration.
  110021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110022. */
  110023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110024. /**
  110025. * Specifies that the submesh is ready to be used.
  110026. * @param defines the list of "defines" to update.
  110027. * @param scene defines the scene the material belongs to.
  110028. * @returns - boolean indicating that the submesh is ready or not.
  110029. */
  110030. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  110031. /**
  110032. * Checks to see if a texture is used in the material.
  110033. * @param defines the list of "defines" to update.
  110034. * @param scene defines the scene the material belongs to.
  110035. */
  110036. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  110037. /**
  110038. * Binds the material data.
  110039. * @param uniformBuffer defines the Uniform buffer to fill in.
  110040. * @param scene defines the scene the material belongs to.
  110041. * @param isFrozen defines wether the material is frozen or not.
  110042. */
  110043. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110044. /**
  110045. * Checks to see if a texture is used in the material.
  110046. * @param texture - Base texture to use.
  110047. * @returns - Boolean specifying if a texture is used in the material.
  110048. */
  110049. hasTexture(texture: BaseTexture): boolean;
  110050. /**
  110051. * Returns an array of the actively used textures.
  110052. * @param activeTextures Array of BaseTextures
  110053. */
  110054. getActiveTextures(activeTextures: BaseTexture[]): void;
  110055. /**
  110056. * Returns the animatable textures.
  110057. * @param animatables Array of animatable textures.
  110058. */
  110059. getAnimatables(animatables: IAnimatable[]): void;
  110060. /**
  110061. * Disposes the resources of the material.
  110062. * @param forceDisposeTextures - Forces the disposal of all textures.
  110063. */
  110064. dispose(forceDisposeTextures?: boolean): void;
  110065. /**
  110066. * Get the current class name of the texture useful for serialization or dynamic coding.
  110067. * @returns "PBRSheenConfiguration"
  110068. */
  110069. getClassName(): string;
  110070. /**
  110071. * Add fallbacks to the effect fallbacks list.
  110072. * @param defines defines the Base texture to use.
  110073. * @param fallbacks defines the current fallback list.
  110074. * @param currentRank defines the current fallback rank.
  110075. * @returns the new fallback rank.
  110076. */
  110077. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110078. /**
  110079. * Add the required uniforms to the current list.
  110080. * @param uniforms defines the current uniform list.
  110081. */
  110082. static AddUniforms(uniforms: string[]): void;
  110083. /**
  110084. * Add the required uniforms to the current buffer.
  110085. * @param uniformBuffer defines the current uniform buffer.
  110086. */
  110087. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110088. /**
  110089. * Add the required samplers to the current list.
  110090. * @param samplers defines the current sampler list.
  110091. */
  110092. static AddSamplers(samplers: string[]): void;
  110093. /**
  110094. * Makes a duplicate of the current configuration into another one.
  110095. * @param sheenConfiguration define the config where to copy the info
  110096. */
  110097. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  110098. /**
  110099. * Serializes this BRDF configuration.
  110100. * @returns - An object with the serialized config.
  110101. */
  110102. serialize(): any;
  110103. /**
  110104. * Parses a anisotropy Configuration from a serialized object.
  110105. * @param source - Serialized object.
  110106. * @param scene Defines the scene we are parsing for
  110107. * @param rootUrl Defines the rootUrl to load from
  110108. */
  110109. parse(source: any, scene: Scene, rootUrl: string): void;
  110110. }
  110111. }
  110112. declare module BABYLON {
  110113. /**
  110114. * @hidden
  110115. */
  110116. export interface IMaterialSubSurfaceDefines {
  110117. SUBSURFACE: boolean;
  110118. SS_REFRACTION: boolean;
  110119. SS_TRANSLUCENCY: boolean;
  110120. SS_SCATERRING: boolean;
  110121. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110122. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110123. SS_REFRACTIONMAP_3D: boolean;
  110124. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110125. SS_LODINREFRACTIONALPHA: boolean;
  110126. SS_GAMMAREFRACTION: boolean;
  110127. SS_RGBDREFRACTION: boolean;
  110128. SS_LINEARSPECULARREFRACTION: boolean;
  110129. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110130. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110131. /** @hidden */
  110132. _areTexturesDirty: boolean;
  110133. }
  110134. /**
  110135. * Define the code related to the sub surface parameters of the pbr material.
  110136. */
  110137. export class PBRSubSurfaceConfiguration {
  110138. private _isRefractionEnabled;
  110139. /**
  110140. * Defines if the refraction is enabled in the material.
  110141. */
  110142. isRefractionEnabled: boolean;
  110143. private _isTranslucencyEnabled;
  110144. /**
  110145. * Defines if the translucency is enabled in the material.
  110146. */
  110147. isTranslucencyEnabled: boolean;
  110148. private _isScatteringEnabled;
  110149. /**
  110150. * Defines the refraction intensity of the material.
  110151. * The refraction when enabled replaces the Diffuse part of the material.
  110152. * The intensity helps transitionning between diffuse and refraction.
  110153. */
  110154. refractionIntensity: number;
  110155. /**
  110156. * Defines the translucency intensity of the material.
  110157. * When translucency has been enabled, this defines how much of the "translucency"
  110158. * is addded to the diffuse part of the material.
  110159. */
  110160. translucencyIntensity: number;
  110161. /**
  110162. * Defines the scattering intensity of the material.
  110163. * When scattering has been enabled, this defines how much of the "scattered light"
  110164. * is addded to the diffuse part of the material.
  110165. */
  110166. scatteringIntensity: number;
  110167. private _thicknessTexture;
  110168. /**
  110169. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  110170. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  110171. * 0 would mean minimumThickness
  110172. * 1 would mean maximumThickness
  110173. * The other channels might be use as a mask to vary the different effects intensity.
  110174. */
  110175. thicknessTexture: Nullable<BaseTexture>;
  110176. private _refractionTexture;
  110177. /**
  110178. * Defines the texture to use for refraction.
  110179. */
  110180. refractionTexture: Nullable<BaseTexture>;
  110181. private _indexOfRefraction;
  110182. /**
  110183. * Defines the index of refraction used in the material.
  110184. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  110185. */
  110186. indexOfRefraction: number;
  110187. private _invertRefractionY;
  110188. /**
  110189. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110190. */
  110191. invertRefractionY: boolean;
  110192. private _linkRefractionWithTransparency;
  110193. /**
  110194. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110195. * Materials half opaque for instance using refraction could benefit from this control.
  110196. */
  110197. linkRefractionWithTransparency: boolean;
  110198. /**
  110199. * Defines the minimum thickness stored in the thickness map.
  110200. * If no thickness map is defined, this value will be used to simulate thickness.
  110201. */
  110202. minimumThickness: number;
  110203. /**
  110204. * Defines the maximum thickness stored in the thickness map.
  110205. */
  110206. maximumThickness: number;
  110207. /**
  110208. * Defines the volume tint of the material.
  110209. * This is used for both translucency and scattering.
  110210. */
  110211. tintColor: Color3;
  110212. /**
  110213. * Defines the distance at which the tint color should be found in the media.
  110214. * This is used for refraction only.
  110215. */
  110216. tintColorAtDistance: number;
  110217. /**
  110218. * Defines how far each channel transmit through the media.
  110219. * It is defined as a color to simplify it selection.
  110220. */
  110221. diffusionDistance: Color3;
  110222. private _useMaskFromThicknessTexture;
  110223. /**
  110224. * Stores the intensity of the different subsurface effects in the thickness texture.
  110225. * * the green channel is the translucency intensity.
  110226. * * the blue channel is the scattering intensity.
  110227. * * the alpha channel is the refraction intensity.
  110228. */
  110229. useMaskFromThicknessTexture: boolean;
  110230. /** @hidden */
  110231. private _internalMarkAllSubMeshesAsTexturesDirty;
  110232. /** @hidden */
  110233. _markAllSubMeshesAsTexturesDirty(): void;
  110234. /**
  110235. * Instantiate a new istance of sub surface configuration.
  110236. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110237. */
  110238. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110239. /**
  110240. * Gets wehter the submesh is ready to be used or not.
  110241. * @param defines the list of "defines" to update.
  110242. * @param scene defines the scene the material belongs to.
  110243. * @returns - boolean indicating that the submesh is ready or not.
  110244. */
  110245. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  110246. /**
  110247. * Checks to see if a texture is used in the material.
  110248. * @param defines the list of "defines" to update.
  110249. * @param scene defines the scene to the material belongs to.
  110250. */
  110251. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  110252. /**
  110253. * Binds the material data.
  110254. * @param uniformBuffer defines the Uniform buffer to fill in.
  110255. * @param scene defines the scene the material belongs to.
  110256. * @param engine defines the engine the material belongs to.
  110257. * @param isFrozen defines wether the material is frozen or not.
  110258. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  110259. */
  110260. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  110261. /**
  110262. * Unbinds the material from the mesh.
  110263. * @param activeEffect defines the effect that should be unbound from.
  110264. * @returns true if unbound, otherwise false
  110265. */
  110266. unbind(activeEffect: Effect): boolean;
  110267. /**
  110268. * Returns the texture used for refraction or null if none is used.
  110269. * @param scene defines the scene the material belongs to.
  110270. * @returns - Refraction texture if present. If no refraction texture and refraction
  110271. * is linked with transparency, returns environment texture. Otherwise, returns null.
  110272. */
  110273. private _getRefractionTexture;
  110274. /**
  110275. * Returns true if alpha blending should be disabled.
  110276. */
  110277. readonly disableAlphaBlending: boolean;
  110278. /**
  110279. * Fills the list of render target textures.
  110280. * @param renderTargets the list of render targets to update
  110281. */
  110282. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  110283. /**
  110284. * Checks to see if a texture is used in the material.
  110285. * @param texture - Base texture to use.
  110286. * @returns - Boolean specifying if a texture is used in the material.
  110287. */
  110288. hasTexture(texture: BaseTexture): boolean;
  110289. /**
  110290. * Gets a boolean indicating that current material needs to register RTT
  110291. * @returns true if this uses a render target otherwise false.
  110292. */
  110293. hasRenderTargetTextures(): boolean;
  110294. /**
  110295. * Returns an array of the actively used textures.
  110296. * @param activeTextures Array of BaseTextures
  110297. */
  110298. getActiveTextures(activeTextures: BaseTexture[]): void;
  110299. /**
  110300. * Returns the animatable textures.
  110301. * @param animatables Array of animatable textures.
  110302. */
  110303. getAnimatables(animatables: IAnimatable[]): void;
  110304. /**
  110305. * Disposes the resources of the material.
  110306. * @param forceDisposeTextures - Forces the disposal of all textures.
  110307. */
  110308. dispose(forceDisposeTextures?: boolean): void;
  110309. /**
  110310. * Get the current class name of the texture useful for serialization or dynamic coding.
  110311. * @returns "PBRSubSurfaceConfiguration"
  110312. */
  110313. getClassName(): string;
  110314. /**
  110315. * Add fallbacks to the effect fallbacks list.
  110316. * @param defines defines the Base texture to use.
  110317. * @param fallbacks defines the current fallback list.
  110318. * @param currentRank defines the current fallback rank.
  110319. * @returns the new fallback rank.
  110320. */
  110321. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  110322. /**
  110323. * Add the required uniforms to the current list.
  110324. * @param uniforms defines the current uniform list.
  110325. */
  110326. static AddUniforms(uniforms: string[]): void;
  110327. /**
  110328. * Add the required samplers to the current list.
  110329. * @param samplers defines the current sampler list.
  110330. */
  110331. static AddSamplers(samplers: string[]): void;
  110332. /**
  110333. * Add the required uniforms to the current buffer.
  110334. * @param uniformBuffer defines the current uniform buffer.
  110335. */
  110336. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110337. /**
  110338. * Makes a duplicate of the current configuration into another one.
  110339. * @param configuration define the config where to copy the info
  110340. */
  110341. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  110342. /**
  110343. * Serializes this Sub Surface configuration.
  110344. * @returns - An object with the serialized config.
  110345. */
  110346. serialize(): any;
  110347. /**
  110348. * Parses a anisotropy Configuration from a serialized object.
  110349. * @param source - Serialized object.
  110350. * @param scene Defines the scene we are parsing for
  110351. * @param rootUrl Defines the rootUrl to load from
  110352. */
  110353. parse(source: any, scene: Scene, rootUrl: string): void;
  110354. }
  110355. }
  110356. declare module BABYLON {
  110357. /** @hidden */
  110358. export var pbrFragmentDeclaration: {
  110359. name: string;
  110360. shader: string;
  110361. };
  110362. }
  110363. declare module BABYLON {
  110364. /** @hidden */
  110365. export var pbrUboDeclaration: {
  110366. name: string;
  110367. shader: string;
  110368. };
  110369. }
  110370. declare module BABYLON {
  110371. /** @hidden */
  110372. export var pbrFragmentExtraDeclaration: {
  110373. name: string;
  110374. shader: string;
  110375. };
  110376. }
  110377. declare module BABYLON {
  110378. /** @hidden */
  110379. export var pbrFragmentSamplersDeclaration: {
  110380. name: string;
  110381. shader: string;
  110382. };
  110383. }
  110384. declare module BABYLON {
  110385. /** @hidden */
  110386. export var pbrHelperFunctions: {
  110387. name: string;
  110388. shader: string;
  110389. };
  110390. }
  110391. declare module BABYLON {
  110392. /** @hidden */
  110393. export var harmonicsFunctions: {
  110394. name: string;
  110395. shader: string;
  110396. };
  110397. }
  110398. declare module BABYLON {
  110399. /** @hidden */
  110400. export var pbrDirectLightingSetupFunctions: {
  110401. name: string;
  110402. shader: string;
  110403. };
  110404. }
  110405. declare module BABYLON {
  110406. /** @hidden */
  110407. export var pbrDirectLightingFalloffFunctions: {
  110408. name: string;
  110409. shader: string;
  110410. };
  110411. }
  110412. declare module BABYLON {
  110413. /** @hidden */
  110414. export var pbrBRDFFunctions: {
  110415. name: string;
  110416. shader: string;
  110417. };
  110418. }
  110419. declare module BABYLON {
  110420. /** @hidden */
  110421. export var pbrDirectLightingFunctions: {
  110422. name: string;
  110423. shader: string;
  110424. };
  110425. }
  110426. declare module BABYLON {
  110427. /** @hidden */
  110428. export var pbrIBLFunctions: {
  110429. name: string;
  110430. shader: string;
  110431. };
  110432. }
  110433. declare module BABYLON {
  110434. /** @hidden */
  110435. export var pbrDebug: {
  110436. name: string;
  110437. shader: string;
  110438. };
  110439. }
  110440. declare module BABYLON {
  110441. /** @hidden */
  110442. export var pbrPixelShader: {
  110443. name: string;
  110444. shader: string;
  110445. };
  110446. }
  110447. declare module BABYLON {
  110448. /** @hidden */
  110449. export var pbrVertexDeclaration: {
  110450. name: string;
  110451. shader: string;
  110452. };
  110453. }
  110454. declare module BABYLON {
  110455. /** @hidden */
  110456. export var pbrVertexShader: {
  110457. name: string;
  110458. shader: string;
  110459. };
  110460. }
  110461. declare module BABYLON {
  110462. /**
  110463. * Manages the defines for the PBR Material.
  110464. * @hidden
  110465. */
  110466. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  110467. PBR: boolean;
  110468. MAINUV1: boolean;
  110469. MAINUV2: boolean;
  110470. UV1: boolean;
  110471. UV2: boolean;
  110472. ALBEDO: boolean;
  110473. ALBEDODIRECTUV: number;
  110474. VERTEXCOLOR: boolean;
  110475. AMBIENT: boolean;
  110476. AMBIENTDIRECTUV: number;
  110477. AMBIENTINGRAYSCALE: boolean;
  110478. OPACITY: boolean;
  110479. VERTEXALPHA: boolean;
  110480. OPACITYDIRECTUV: number;
  110481. OPACITYRGB: boolean;
  110482. ALPHATEST: boolean;
  110483. DEPTHPREPASS: boolean;
  110484. ALPHABLEND: boolean;
  110485. ALPHAFROMALBEDO: boolean;
  110486. ALPHATESTVALUE: string;
  110487. SPECULAROVERALPHA: boolean;
  110488. RADIANCEOVERALPHA: boolean;
  110489. ALPHAFRESNEL: boolean;
  110490. LINEARALPHAFRESNEL: boolean;
  110491. PREMULTIPLYALPHA: boolean;
  110492. EMISSIVE: boolean;
  110493. EMISSIVEDIRECTUV: number;
  110494. REFLECTIVITY: boolean;
  110495. REFLECTIVITYDIRECTUV: number;
  110496. SPECULARTERM: boolean;
  110497. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  110498. MICROSURFACEAUTOMATIC: boolean;
  110499. LODBASEDMICROSFURACE: boolean;
  110500. MICROSURFACEMAP: boolean;
  110501. MICROSURFACEMAPDIRECTUV: number;
  110502. METALLICWORKFLOW: boolean;
  110503. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  110504. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  110505. METALLNESSSTOREINMETALMAPBLUE: boolean;
  110506. AOSTOREINMETALMAPRED: boolean;
  110507. ENVIRONMENTBRDF: boolean;
  110508. ENVIRONMENTBRDF_RGBD: boolean;
  110509. NORMAL: boolean;
  110510. TANGENT: boolean;
  110511. BUMP: boolean;
  110512. BUMPDIRECTUV: number;
  110513. OBJECTSPACE_NORMALMAP: boolean;
  110514. PARALLAX: boolean;
  110515. PARALLAXOCCLUSION: boolean;
  110516. NORMALXYSCALE: boolean;
  110517. LIGHTMAP: boolean;
  110518. LIGHTMAPDIRECTUV: number;
  110519. USELIGHTMAPASSHADOWMAP: boolean;
  110520. GAMMALIGHTMAP: boolean;
  110521. REFLECTION: boolean;
  110522. REFLECTIONMAP_3D: boolean;
  110523. REFLECTIONMAP_SPHERICAL: boolean;
  110524. REFLECTIONMAP_PLANAR: boolean;
  110525. REFLECTIONMAP_CUBIC: boolean;
  110526. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110527. REFLECTIONMAP_PROJECTION: boolean;
  110528. REFLECTIONMAP_SKYBOX: boolean;
  110529. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  110530. REFLECTIONMAP_EXPLICIT: boolean;
  110531. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110532. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110533. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110534. INVERTCUBICMAP: boolean;
  110535. USESPHERICALFROMREFLECTIONMAP: boolean;
  110536. USEIRRADIANCEMAP: boolean;
  110537. SPHERICAL_HARMONICS: boolean;
  110538. USESPHERICALINVERTEX: boolean;
  110539. REFLECTIONMAP_OPPOSITEZ: boolean;
  110540. LODINREFLECTIONALPHA: boolean;
  110541. GAMMAREFLECTION: boolean;
  110542. RGBDREFLECTION: boolean;
  110543. LINEARSPECULARREFLECTION: boolean;
  110544. RADIANCEOCCLUSION: boolean;
  110545. HORIZONOCCLUSION: boolean;
  110546. INSTANCES: boolean;
  110547. NUM_BONE_INFLUENCERS: number;
  110548. BonesPerMesh: number;
  110549. BONETEXTURE: boolean;
  110550. NONUNIFORMSCALING: boolean;
  110551. MORPHTARGETS: boolean;
  110552. MORPHTARGETS_NORMAL: boolean;
  110553. MORPHTARGETS_TANGENT: boolean;
  110554. MORPHTARGETS_UV: boolean;
  110555. NUM_MORPH_INFLUENCERS: number;
  110556. IMAGEPROCESSING: boolean;
  110557. VIGNETTE: boolean;
  110558. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110559. VIGNETTEBLENDMODEOPAQUE: boolean;
  110560. TONEMAPPING: boolean;
  110561. TONEMAPPING_ACES: boolean;
  110562. CONTRAST: boolean;
  110563. COLORCURVES: boolean;
  110564. COLORGRADING: boolean;
  110565. COLORGRADING3D: boolean;
  110566. SAMPLER3DGREENDEPTH: boolean;
  110567. SAMPLER3DBGRMAP: boolean;
  110568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110569. EXPOSURE: boolean;
  110570. MULTIVIEW: boolean;
  110571. USEPHYSICALLIGHTFALLOFF: boolean;
  110572. USEGLTFLIGHTFALLOFF: boolean;
  110573. TWOSIDEDLIGHTING: boolean;
  110574. SHADOWFLOAT: boolean;
  110575. CLIPPLANE: boolean;
  110576. CLIPPLANE2: boolean;
  110577. CLIPPLANE3: boolean;
  110578. CLIPPLANE4: boolean;
  110579. POINTSIZE: boolean;
  110580. FOG: boolean;
  110581. LOGARITHMICDEPTH: boolean;
  110582. FORCENORMALFORWARD: boolean;
  110583. SPECULARAA: boolean;
  110584. CLEARCOAT: boolean;
  110585. CLEARCOAT_DEFAULTIOR: boolean;
  110586. CLEARCOAT_TEXTURE: boolean;
  110587. CLEARCOAT_TEXTUREDIRECTUV: number;
  110588. CLEARCOAT_BUMP: boolean;
  110589. CLEARCOAT_BUMPDIRECTUV: number;
  110590. CLEARCOAT_TINT: boolean;
  110591. CLEARCOAT_TINT_TEXTURE: boolean;
  110592. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  110593. ANISOTROPIC: boolean;
  110594. ANISOTROPIC_TEXTURE: boolean;
  110595. ANISOTROPIC_TEXTUREDIRECTUV: number;
  110596. BRDF_V_HEIGHT_CORRELATED: boolean;
  110597. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110598. SHEEN: boolean;
  110599. SHEEN_TEXTURE: boolean;
  110600. SHEEN_TEXTUREDIRECTUV: number;
  110601. SHEEN_LINKWITHALBEDO: boolean;
  110602. SUBSURFACE: boolean;
  110603. SS_REFRACTION: boolean;
  110604. SS_TRANSLUCENCY: boolean;
  110605. SS_SCATERRING: boolean;
  110606. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110607. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110608. SS_REFRACTIONMAP_3D: boolean;
  110609. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110610. SS_LODINREFRACTIONALPHA: boolean;
  110611. SS_GAMMAREFRACTION: boolean;
  110612. SS_RGBDREFRACTION: boolean;
  110613. SS_LINEARSPECULARREFRACTION: boolean;
  110614. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110615. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110616. UNLIT: boolean;
  110617. DEBUGMODE: number;
  110618. /**
  110619. * Initializes the PBR Material defines.
  110620. */
  110621. constructor();
  110622. /**
  110623. * Resets the PBR Material defines.
  110624. */
  110625. reset(): void;
  110626. }
  110627. /**
  110628. * The Physically based material base class of BJS.
  110629. *
  110630. * This offers the main features of a standard PBR material.
  110631. * For more information, please refer to the documentation :
  110632. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110633. */
  110634. export abstract class PBRBaseMaterial extends PushMaterial {
  110635. /**
  110636. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110637. */
  110638. static readonly PBRMATERIAL_OPAQUE: number;
  110639. /**
  110640. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110641. */
  110642. static readonly PBRMATERIAL_ALPHATEST: number;
  110643. /**
  110644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110645. */
  110646. static readonly PBRMATERIAL_ALPHABLEND: number;
  110647. /**
  110648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110649. * They are also discarded below the alpha cutoff threshold to improve performances.
  110650. */
  110651. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110652. /**
  110653. * Defines the default value of how much AO map is occluding the analytical lights
  110654. * (point spot...).
  110655. */
  110656. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110657. /**
  110658. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  110659. */
  110660. static readonly LIGHTFALLOFF_PHYSICAL: number;
  110661. /**
  110662. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  110663. * to enhance interoperability with other engines.
  110664. */
  110665. static readonly LIGHTFALLOFF_GLTF: number;
  110666. /**
  110667. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  110668. * to enhance interoperability with other materials.
  110669. */
  110670. static readonly LIGHTFALLOFF_STANDARD: number;
  110671. /**
  110672. * Intensity of the direct lights e.g. the four lights available in your scene.
  110673. * This impacts both the direct diffuse and specular highlights.
  110674. */
  110675. protected _directIntensity: number;
  110676. /**
  110677. * Intensity of the emissive part of the material.
  110678. * This helps controlling the emissive effect without modifying the emissive color.
  110679. */
  110680. protected _emissiveIntensity: number;
  110681. /**
  110682. * Intensity of the environment e.g. how much the environment will light the object
  110683. * either through harmonics for rough material or through the refelction for shiny ones.
  110684. */
  110685. protected _environmentIntensity: number;
  110686. /**
  110687. * This is a special control allowing the reduction of the specular highlights coming from the
  110688. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110689. */
  110690. protected _specularIntensity: number;
  110691. /**
  110692. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  110693. */
  110694. private _lightingInfos;
  110695. /**
  110696. * Debug Control allowing disabling the bump map on this material.
  110697. */
  110698. protected _disableBumpMap: boolean;
  110699. /**
  110700. * AKA Diffuse Texture in standard nomenclature.
  110701. */
  110702. protected _albedoTexture: Nullable<BaseTexture>;
  110703. /**
  110704. * AKA Occlusion Texture in other nomenclature.
  110705. */
  110706. protected _ambientTexture: Nullable<BaseTexture>;
  110707. /**
  110708. * AKA Occlusion Texture Intensity in other nomenclature.
  110709. */
  110710. protected _ambientTextureStrength: number;
  110711. /**
  110712. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110713. * 1 means it completely occludes it
  110714. * 0 mean it has no impact
  110715. */
  110716. protected _ambientTextureImpactOnAnalyticalLights: number;
  110717. /**
  110718. * Stores the alpha values in a texture.
  110719. */
  110720. protected _opacityTexture: Nullable<BaseTexture>;
  110721. /**
  110722. * Stores the reflection values in a texture.
  110723. */
  110724. protected _reflectionTexture: Nullable<BaseTexture>;
  110725. /**
  110726. * Stores the emissive values in a texture.
  110727. */
  110728. protected _emissiveTexture: Nullable<BaseTexture>;
  110729. /**
  110730. * AKA Specular texture in other nomenclature.
  110731. */
  110732. protected _reflectivityTexture: Nullable<BaseTexture>;
  110733. /**
  110734. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110735. */
  110736. protected _metallicTexture: Nullable<BaseTexture>;
  110737. /**
  110738. * Specifies the metallic scalar of the metallic/roughness workflow.
  110739. * Can also be used to scale the metalness values of the metallic texture.
  110740. */
  110741. protected _metallic: Nullable<number>;
  110742. /**
  110743. * Specifies the roughness scalar of the metallic/roughness workflow.
  110744. * Can also be used to scale the roughness values of the metallic texture.
  110745. */
  110746. protected _roughness: Nullable<number>;
  110747. /**
  110748. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110749. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110750. */
  110751. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110752. /**
  110753. * Stores surface normal data used to displace a mesh in a texture.
  110754. */
  110755. protected _bumpTexture: Nullable<BaseTexture>;
  110756. /**
  110757. * Stores the pre-calculated light information of a mesh in a texture.
  110758. */
  110759. protected _lightmapTexture: Nullable<BaseTexture>;
  110760. /**
  110761. * The color of a material in ambient lighting.
  110762. */
  110763. protected _ambientColor: Color3;
  110764. /**
  110765. * AKA Diffuse Color in other nomenclature.
  110766. */
  110767. protected _albedoColor: Color3;
  110768. /**
  110769. * AKA Specular Color in other nomenclature.
  110770. */
  110771. protected _reflectivityColor: Color3;
  110772. /**
  110773. * The color applied when light is reflected from a material.
  110774. */
  110775. protected _reflectionColor: Color3;
  110776. /**
  110777. * The color applied when light is emitted from a material.
  110778. */
  110779. protected _emissiveColor: Color3;
  110780. /**
  110781. * AKA Glossiness in other nomenclature.
  110782. */
  110783. protected _microSurface: number;
  110784. /**
  110785. * Specifies that the material will use the light map as a show map.
  110786. */
  110787. protected _useLightmapAsShadowmap: boolean;
  110788. /**
  110789. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110790. * makes the reflect vector face the model (under horizon).
  110791. */
  110792. protected _useHorizonOcclusion: boolean;
  110793. /**
  110794. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110795. * too much the area relying on ambient texture to define their ambient occlusion.
  110796. */
  110797. protected _useRadianceOcclusion: boolean;
  110798. /**
  110799. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110800. */
  110801. protected _useAlphaFromAlbedoTexture: boolean;
  110802. /**
  110803. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110805. */
  110806. protected _useSpecularOverAlpha: boolean;
  110807. /**
  110808. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110809. */
  110810. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110811. /**
  110812. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110813. */
  110814. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110815. /**
  110816. * Specifies if the metallic texture contains the roughness information in its green channel.
  110817. */
  110818. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110819. /**
  110820. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110821. */
  110822. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110823. /**
  110824. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110825. */
  110826. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110827. /**
  110828. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110829. */
  110830. protected _useAmbientInGrayScale: boolean;
  110831. /**
  110832. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110833. * The material will try to infer what glossiness each pixel should be.
  110834. */
  110835. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110836. /**
  110837. * Defines the falloff type used in this material.
  110838. * It by default is Physical.
  110839. */
  110840. protected _lightFalloff: number;
  110841. /**
  110842. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110843. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110844. */
  110845. protected _useRadianceOverAlpha: boolean;
  110846. /**
  110847. * Allows using an object space normal map (instead of tangent space).
  110848. */
  110849. protected _useObjectSpaceNormalMap: boolean;
  110850. /**
  110851. * Allows using the bump map in parallax mode.
  110852. */
  110853. protected _useParallax: boolean;
  110854. /**
  110855. * Allows using the bump map in parallax occlusion mode.
  110856. */
  110857. protected _useParallaxOcclusion: boolean;
  110858. /**
  110859. * Controls the scale bias of the parallax mode.
  110860. */
  110861. protected _parallaxScaleBias: number;
  110862. /**
  110863. * If sets to true, disables all the lights affecting the material.
  110864. */
  110865. protected _disableLighting: boolean;
  110866. /**
  110867. * Number of Simultaneous lights allowed on the material.
  110868. */
  110869. protected _maxSimultaneousLights: number;
  110870. /**
  110871. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110872. */
  110873. protected _invertNormalMapX: boolean;
  110874. /**
  110875. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110876. */
  110877. protected _invertNormalMapY: boolean;
  110878. /**
  110879. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110880. */
  110881. protected _twoSidedLighting: boolean;
  110882. /**
  110883. * Defines the alpha limits in alpha test mode.
  110884. */
  110885. protected _alphaCutOff: number;
  110886. /**
  110887. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110888. */
  110889. protected _forceAlphaTest: boolean;
  110890. /**
  110891. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110892. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110893. */
  110894. protected _useAlphaFresnel: boolean;
  110895. /**
  110896. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110897. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110898. */
  110899. protected _useLinearAlphaFresnel: boolean;
  110900. /**
  110901. * The transparency mode of the material.
  110902. */
  110903. protected _transparencyMode: Nullable<number>;
  110904. /**
  110905. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110906. * from cos thetav and roughness:
  110907. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110908. */
  110909. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110910. /**
  110911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110912. */
  110913. protected _forceIrradianceInFragment: boolean;
  110914. /**
  110915. * Force normal to face away from face.
  110916. */
  110917. protected _forceNormalForward: boolean;
  110918. /**
  110919. * Enables specular anti aliasing in the PBR shader.
  110920. * It will both interacts on the Geometry for analytical and IBL lighting.
  110921. * It also prefilter the roughness map based on the bump values.
  110922. */
  110923. protected _enableSpecularAntiAliasing: boolean;
  110924. /**
  110925. * Default configuration related to image processing available in the PBR Material.
  110926. */
  110927. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110928. /**
  110929. * Keep track of the image processing observer to allow dispose and replace.
  110930. */
  110931. private _imageProcessingObserver;
  110932. /**
  110933. * Attaches a new image processing configuration to the PBR Material.
  110934. * @param configuration
  110935. */
  110936. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110937. /**
  110938. * Stores the available render targets.
  110939. */
  110940. private _renderTargets;
  110941. /**
  110942. * Sets the global ambient color for the material used in lighting calculations.
  110943. */
  110944. private _globalAmbientColor;
  110945. /**
  110946. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110947. */
  110948. private _useLogarithmicDepth;
  110949. /**
  110950. * If set to true, no lighting calculations will be applied.
  110951. */
  110952. private _unlit;
  110953. private _debugMode;
  110954. /**
  110955. * @hidden
  110956. * This is reserved for the inspector.
  110957. * Defines the material debug mode.
  110958. * It helps seeing only some components of the material while troubleshooting.
  110959. */
  110960. debugMode: number;
  110961. /**
  110962. * @hidden
  110963. * This is reserved for the inspector.
  110964. * Specify from where on screen the debug mode should start.
  110965. * The value goes from -1 (full screen) to 1 (not visible)
  110966. * It helps with side by side comparison against the final render
  110967. * This defaults to -1
  110968. */
  110969. private debugLimit;
  110970. /**
  110971. * @hidden
  110972. * This is reserved for the inspector.
  110973. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110974. * You can use the factor to better multiply the final value.
  110975. */
  110976. private debugFactor;
  110977. /**
  110978. * Defines the clear coat layer parameters for the material.
  110979. */
  110980. readonly clearCoat: PBRClearCoatConfiguration;
  110981. /**
  110982. * Defines the anisotropic parameters for the material.
  110983. */
  110984. readonly anisotropy: PBRAnisotropicConfiguration;
  110985. /**
  110986. * Defines the BRDF parameters for the material.
  110987. */
  110988. readonly brdf: PBRBRDFConfiguration;
  110989. /**
  110990. * Defines the Sheen parameters for the material.
  110991. */
  110992. readonly sheen: PBRSheenConfiguration;
  110993. /**
  110994. * Defines the SubSurface parameters for the material.
  110995. */
  110996. readonly subSurface: PBRSubSurfaceConfiguration;
  110997. /**
  110998. * Custom callback helping to override the default shader used in the material.
  110999. */
  111000. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  111001. /**
  111002. * Instantiates a new PBRMaterial instance.
  111003. *
  111004. * @param name The material name
  111005. * @param scene The scene the material will be use in.
  111006. */
  111007. constructor(name: string, scene: Scene);
  111008. /**
  111009. * Gets a boolean indicating that current material needs to register RTT
  111010. */
  111011. readonly hasRenderTargetTextures: boolean;
  111012. /**
  111013. * Gets the name of the material class.
  111014. */
  111015. getClassName(): string;
  111016. /**
  111017. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111018. */
  111019. /**
  111020. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  111021. */
  111022. useLogarithmicDepth: boolean;
  111023. /**
  111024. * Gets the current transparency mode.
  111025. */
  111026. /**
  111027. * Sets the transparency mode of the material.
  111028. *
  111029. * | Value | Type | Description |
  111030. * | ----- | ----------------------------------- | ----------- |
  111031. * | 0 | OPAQUE | |
  111032. * | 1 | ALPHATEST | |
  111033. * | 2 | ALPHABLEND | |
  111034. * | 3 | ALPHATESTANDBLEND | |
  111035. *
  111036. */
  111037. transparencyMode: Nullable<number>;
  111038. /**
  111039. * Returns true if alpha blending should be disabled.
  111040. */
  111041. private readonly _disableAlphaBlending;
  111042. /**
  111043. * Specifies whether or not this material should be rendered in alpha blend mode.
  111044. */
  111045. needAlphaBlending(): boolean;
  111046. /**
  111047. * Specifies if the mesh will require alpha blending.
  111048. * @param mesh - BJS mesh.
  111049. */
  111050. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111051. /**
  111052. * Specifies whether or not this material should be rendered in alpha test mode.
  111053. */
  111054. needAlphaTesting(): boolean;
  111055. /**
  111056. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  111057. */
  111058. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  111059. /**
  111060. * Gets the texture used for the alpha test.
  111061. */
  111062. getAlphaTestTexture(): Nullable<BaseTexture>;
  111063. /**
  111064. * Specifies that the submesh is ready to be used.
  111065. * @param mesh - BJS mesh.
  111066. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  111067. * @param useInstances - Specifies that instances should be used.
  111068. * @returns - boolean indicating that the submesh is ready or not.
  111069. */
  111070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111071. /**
  111072. * Specifies if the material uses metallic roughness workflow.
  111073. * @returns boolean specifiying if the material uses metallic roughness workflow.
  111074. */
  111075. isMetallicWorkflow(): boolean;
  111076. private _prepareEffect;
  111077. private _prepareDefines;
  111078. /**
  111079. * Force shader compilation
  111080. */
  111081. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  111082. clipPlane: boolean;
  111083. }>): void;
  111084. /**
  111085. * Initializes the uniform buffer layout for the shader.
  111086. */
  111087. buildUniformLayout(): void;
  111088. /**
  111089. * Unbinds the material from the mesh
  111090. */
  111091. unbind(): void;
  111092. /**
  111093. * Binds the submesh data.
  111094. * @param world - The world matrix.
  111095. * @param mesh - The BJS mesh.
  111096. * @param subMesh - A submesh of the BJS mesh.
  111097. */
  111098. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111099. /**
  111100. * Returns the animatable textures.
  111101. * @returns - Array of animatable textures.
  111102. */
  111103. getAnimatables(): IAnimatable[];
  111104. /**
  111105. * Returns the texture used for reflections.
  111106. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  111107. */
  111108. private _getReflectionTexture;
  111109. /**
  111110. * Returns an array of the actively used textures.
  111111. * @returns - Array of BaseTextures
  111112. */
  111113. getActiveTextures(): BaseTexture[];
  111114. /**
  111115. * Checks to see if a texture is used in the material.
  111116. * @param texture - Base texture to use.
  111117. * @returns - Boolean specifying if a texture is used in the material.
  111118. */
  111119. hasTexture(texture: BaseTexture): boolean;
  111120. /**
  111121. * Disposes the resources of the material.
  111122. * @param forceDisposeEffect - Forces the disposal of effects.
  111123. * @param forceDisposeTextures - Forces the disposal of all textures.
  111124. */
  111125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111126. }
  111127. }
  111128. declare module BABYLON {
  111129. /**
  111130. * The Physically based material of BJS.
  111131. *
  111132. * This offers the main features of a standard PBR material.
  111133. * For more information, please refer to the documentation :
  111134. * https://doc.babylonjs.com/how_to/physically_based_rendering
  111135. */
  111136. export class PBRMaterial extends PBRBaseMaterial {
  111137. /**
  111138. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111139. */
  111140. static readonly PBRMATERIAL_OPAQUE: number;
  111141. /**
  111142. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111143. */
  111144. static readonly PBRMATERIAL_ALPHATEST: number;
  111145. /**
  111146. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111147. */
  111148. static readonly PBRMATERIAL_ALPHABLEND: number;
  111149. /**
  111150. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111151. * They are also discarded below the alpha cutoff threshold to improve performances.
  111152. */
  111153. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  111154. /**
  111155. * Defines the default value of how much AO map is occluding the analytical lights
  111156. * (point spot...).
  111157. */
  111158. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  111159. /**
  111160. * Intensity of the direct lights e.g. the four lights available in your scene.
  111161. * This impacts both the direct diffuse and specular highlights.
  111162. */
  111163. directIntensity: number;
  111164. /**
  111165. * Intensity of the emissive part of the material.
  111166. * This helps controlling the emissive effect without modifying the emissive color.
  111167. */
  111168. emissiveIntensity: number;
  111169. /**
  111170. * Intensity of the environment e.g. how much the environment will light the object
  111171. * either through harmonics for rough material or through the refelction for shiny ones.
  111172. */
  111173. environmentIntensity: number;
  111174. /**
  111175. * This is a special control allowing the reduction of the specular highlights coming from the
  111176. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  111177. */
  111178. specularIntensity: number;
  111179. /**
  111180. * Debug Control allowing disabling the bump map on this material.
  111181. */
  111182. disableBumpMap: boolean;
  111183. /**
  111184. * AKA Diffuse Texture in standard nomenclature.
  111185. */
  111186. albedoTexture: BaseTexture;
  111187. /**
  111188. * AKA Occlusion Texture in other nomenclature.
  111189. */
  111190. ambientTexture: BaseTexture;
  111191. /**
  111192. * AKA Occlusion Texture Intensity in other nomenclature.
  111193. */
  111194. ambientTextureStrength: number;
  111195. /**
  111196. * Defines how much the AO map is occluding the analytical lights (point spot...).
  111197. * 1 means it completely occludes it
  111198. * 0 mean it has no impact
  111199. */
  111200. ambientTextureImpactOnAnalyticalLights: number;
  111201. /**
  111202. * Stores the alpha values in a texture.
  111203. */
  111204. opacityTexture: BaseTexture;
  111205. /**
  111206. * Stores the reflection values in a texture.
  111207. */
  111208. reflectionTexture: Nullable<BaseTexture>;
  111209. /**
  111210. * Stores the emissive values in a texture.
  111211. */
  111212. emissiveTexture: BaseTexture;
  111213. /**
  111214. * AKA Specular texture in other nomenclature.
  111215. */
  111216. reflectivityTexture: BaseTexture;
  111217. /**
  111218. * Used to switch from specular/glossiness to metallic/roughness workflow.
  111219. */
  111220. metallicTexture: BaseTexture;
  111221. /**
  111222. * Specifies the metallic scalar of the metallic/roughness workflow.
  111223. * Can also be used to scale the metalness values of the metallic texture.
  111224. */
  111225. metallic: Nullable<number>;
  111226. /**
  111227. * Specifies the roughness scalar of the metallic/roughness workflow.
  111228. * Can also be used to scale the roughness values of the metallic texture.
  111229. */
  111230. roughness: Nullable<number>;
  111231. /**
  111232. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  111233. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  111234. */
  111235. microSurfaceTexture: BaseTexture;
  111236. /**
  111237. * Stores surface normal data used to displace a mesh in a texture.
  111238. */
  111239. bumpTexture: BaseTexture;
  111240. /**
  111241. * Stores the pre-calculated light information of a mesh in a texture.
  111242. */
  111243. lightmapTexture: BaseTexture;
  111244. /**
  111245. * Stores the refracted light information in a texture.
  111246. */
  111247. refractionTexture: Nullable<BaseTexture>;
  111248. /**
  111249. * The color of a material in ambient lighting.
  111250. */
  111251. ambientColor: Color3;
  111252. /**
  111253. * AKA Diffuse Color in other nomenclature.
  111254. */
  111255. albedoColor: Color3;
  111256. /**
  111257. * AKA Specular Color in other nomenclature.
  111258. */
  111259. reflectivityColor: Color3;
  111260. /**
  111261. * The color reflected from the material.
  111262. */
  111263. reflectionColor: Color3;
  111264. /**
  111265. * The color emitted from the material.
  111266. */
  111267. emissiveColor: Color3;
  111268. /**
  111269. * AKA Glossiness in other nomenclature.
  111270. */
  111271. microSurface: number;
  111272. /**
  111273. * source material index of refraction (IOR)' / 'destination material IOR.
  111274. */
  111275. indexOfRefraction: number;
  111276. /**
  111277. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  111278. */
  111279. invertRefractionY: boolean;
  111280. /**
  111281. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  111282. * Materials half opaque for instance using refraction could benefit from this control.
  111283. */
  111284. linkRefractionWithTransparency: boolean;
  111285. /**
  111286. * If true, the light map contains occlusion information instead of lighting info.
  111287. */
  111288. useLightmapAsShadowmap: boolean;
  111289. /**
  111290. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  111291. */
  111292. useAlphaFromAlbedoTexture: boolean;
  111293. /**
  111294. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111295. */
  111296. forceAlphaTest: boolean;
  111297. /**
  111298. * Defines the alpha limits in alpha test mode.
  111299. */
  111300. alphaCutOff: number;
  111301. /**
  111302. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111303. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111304. */
  111305. useSpecularOverAlpha: boolean;
  111306. /**
  111307. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  111308. */
  111309. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  111310. /**
  111311. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  111312. */
  111313. useRoughnessFromMetallicTextureAlpha: boolean;
  111314. /**
  111315. * Specifies if the metallic texture contains the roughness information in its green channel.
  111316. */
  111317. useRoughnessFromMetallicTextureGreen: boolean;
  111318. /**
  111319. * Specifies if the metallic texture contains the metallness information in its blue channel.
  111320. */
  111321. useMetallnessFromMetallicTextureBlue: boolean;
  111322. /**
  111323. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  111324. */
  111325. useAmbientOcclusionFromMetallicTextureRed: boolean;
  111326. /**
  111327. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  111328. */
  111329. useAmbientInGrayScale: boolean;
  111330. /**
  111331. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  111332. * The material will try to infer what glossiness each pixel should be.
  111333. */
  111334. useAutoMicroSurfaceFromReflectivityMap: boolean;
  111335. /**
  111336. * BJS is using an harcoded light falloff based on a manually sets up range.
  111337. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111338. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111339. */
  111340. /**
  111341. * BJS is using an harcoded light falloff based on a manually sets up range.
  111342. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  111343. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  111344. */
  111345. usePhysicalLightFalloff: boolean;
  111346. /**
  111347. * In order to support the falloff compatibility with gltf, a special mode has been added
  111348. * to reproduce the gltf light falloff.
  111349. */
  111350. /**
  111351. * In order to support the falloff compatibility with gltf, a special mode has been added
  111352. * to reproduce the gltf light falloff.
  111353. */
  111354. useGLTFLightFalloff: boolean;
  111355. /**
  111356. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111357. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111358. */
  111359. useRadianceOverAlpha: boolean;
  111360. /**
  111361. * Allows using an object space normal map (instead of tangent space).
  111362. */
  111363. useObjectSpaceNormalMap: boolean;
  111364. /**
  111365. * Allows using the bump map in parallax mode.
  111366. */
  111367. useParallax: boolean;
  111368. /**
  111369. * Allows using the bump map in parallax occlusion mode.
  111370. */
  111371. useParallaxOcclusion: boolean;
  111372. /**
  111373. * Controls the scale bias of the parallax mode.
  111374. */
  111375. parallaxScaleBias: number;
  111376. /**
  111377. * If sets to true, disables all the lights affecting the material.
  111378. */
  111379. disableLighting: boolean;
  111380. /**
  111381. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  111382. */
  111383. forceIrradianceInFragment: boolean;
  111384. /**
  111385. * Number of Simultaneous lights allowed on the material.
  111386. */
  111387. maxSimultaneousLights: number;
  111388. /**
  111389. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111390. */
  111391. invertNormalMapX: boolean;
  111392. /**
  111393. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111394. */
  111395. invertNormalMapY: boolean;
  111396. /**
  111397. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111398. */
  111399. twoSidedLighting: boolean;
  111400. /**
  111401. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111402. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  111403. */
  111404. useAlphaFresnel: boolean;
  111405. /**
  111406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  111407. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  111408. */
  111409. useLinearAlphaFresnel: boolean;
  111410. /**
  111411. * Let user defines the brdf lookup texture used for IBL.
  111412. * A default 8bit version is embedded but you could point at :
  111413. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  111414. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  111415. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  111416. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  111417. */
  111418. environmentBRDFTexture: Nullable<BaseTexture>;
  111419. /**
  111420. * Force normal to face away from face.
  111421. */
  111422. forceNormalForward: boolean;
  111423. /**
  111424. * Enables specular anti aliasing in the PBR shader.
  111425. * It will both interacts on the Geometry for analytical and IBL lighting.
  111426. * It also prefilter the roughness map based on the bump values.
  111427. */
  111428. enableSpecularAntiAliasing: boolean;
  111429. /**
  111430. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  111431. * makes the reflect vector face the model (under horizon).
  111432. */
  111433. useHorizonOcclusion: boolean;
  111434. /**
  111435. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  111436. * too much the area relying on ambient texture to define their ambient occlusion.
  111437. */
  111438. useRadianceOcclusion: boolean;
  111439. /**
  111440. * If set to true, no lighting calculations will be applied.
  111441. */
  111442. unlit: boolean;
  111443. /**
  111444. * Gets the image processing configuration used either in this material.
  111445. */
  111446. /**
  111447. * Sets the Default image processing configuration used either in the this material.
  111448. *
  111449. * If sets to null, the scene one is in use.
  111450. */
  111451. imageProcessingConfiguration: ImageProcessingConfiguration;
  111452. /**
  111453. * Gets wether the color curves effect is enabled.
  111454. */
  111455. /**
  111456. * Sets wether the color curves effect is enabled.
  111457. */
  111458. cameraColorCurvesEnabled: boolean;
  111459. /**
  111460. * Gets wether the color grading effect is enabled.
  111461. */
  111462. /**
  111463. * Gets wether the color grading effect is enabled.
  111464. */
  111465. cameraColorGradingEnabled: boolean;
  111466. /**
  111467. * Gets wether tonemapping is enabled or not.
  111468. */
  111469. /**
  111470. * Sets wether tonemapping is enabled or not
  111471. */
  111472. cameraToneMappingEnabled: boolean;
  111473. /**
  111474. * The camera exposure used on this material.
  111475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111476. * This corresponds to a photographic exposure.
  111477. */
  111478. /**
  111479. * The camera exposure used on this material.
  111480. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111481. * This corresponds to a photographic exposure.
  111482. */
  111483. cameraExposure: number;
  111484. /**
  111485. * Gets The camera contrast used on this material.
  111486. */
  111487. /**
  111488. * Sets The camera contrast used on this material.
  111489. */
  111490. cameraContrast: number;
  111491. /**
  111492. * Gets the Color Grading 2D Lookup Texture.
  111493. */
  111494. /**
  111495. * Sets the Color Grading 2D Lookup Texture.
  111496. */
  111497. cameraColorGradingTexture: Nullable<BaseTexture>;
  111498. /**
  111499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111501. * 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;
  111502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111503. */
  111504. /**
  111505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111507. * 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;
  111508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111509. */
  111510. cameraColorCurves: Nullable<ColorCurves>;
  111511. /**
  111512. * Instantiates a new PBRMaterial instance.
  111513. *
  111514. * @param name The material name
  111515. * @param scene The scene the material will be use in.
  111516. */
  111517. constructor(name: string, scene: Scene);
  111518. /**
  111519. * Returns the name of this material class.
  111520. */
  111521. getClassName(): string;
  111522. /**
  111523. * Makes a duplicate of the current material.
  111524. * @param name - name to use for the new material.
  111525. */
  111526. clone(name: string): PBRMaterial;
  111527. /**
  111528. * Serializes this PBR Material.
  111529. * @returns - An object with the serialized material.
  111530. */
  111531. serialize(): any;
  111532. /**
  111533. * Parses a PBR Material from a serialized object.
  111534. * @param source - Serialized object.
  111535. * @param scene - BJS scene instance.
  111536. * @param rootUrl - url for the scene object
  111537. * @returns - PBRMaterial
  111538. */
  111539. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  111540. }
  111541. }
  111542. declare module BABYLON {
  111543. /**
  111544. * Direct draw surface info
  111545. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  111546. */
  111547. export interface DDSInfo {
  111548. /**
  111549. * Width of the texture
  111550. */
  111551. width: number;
  111552. /**
  111553. * Width of the texture
  111554. */
  111555. height: number;
  111556. /**
  111557. * Number of Mipmaps for the texture
  111558. * @see https://en.wikipedia.org/wiki/Mipmap
  111559. */
  111560. mipmapCount: number;
  111561. /**
  111562. * If the textures format is a known fourCC format
  111563. * @see https://www.fourcc.org/
  111564. */
  111565. isFourCC: boolean;
  111566. /**
  111567. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  111568. */
  111569. isRGB: boolean;
  111570. /**
  111571. * If the texture is a lumincance format
  111572. */
  111573. isLuminance: boolean;
  111574. /**
  111575. * If this is a cube texture
  111576. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  111577. */
  111578. isCube: boolean;
  111579. /**
  111580. * If the texture is a compressed format eg. FOURCC_DXT1
  111581. */
  111582. isCompressed: boolean;
  111583. /**
  111584. * The dxgiFormat of the texture
  111585. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  111586. */
  111587. dxgiFormat: number;
  111588. /**
  111589. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  111590. */
  111591. textureType: number;
  111592. /**
  111593. * Sphericle polynomial created for the dds texture
  111594. */
  111595. sphericalPolynomial?: SphericalPolynomial;
  111596. }
  111597. /**
  111598. * Class used to provide DDS decompression tools
  111599. */
  111600. export class DDSTools {
  111601. /**
  111602. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111603. */
  111604. static StoreLODInAlphaChannel: boolean;
  111605. /**
  111606. * Gets DDS information from an array buffer
  111607. * @param arrayBuffer defines the array buffer to read data from
  111608. * @returns the DDS information
  111609. */
  111610. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111611. private static _FloatView;
  111612. private static _Int32View;
  111613. private static _ToHalfFloat;
  111614. private static _FromHalfFloat;
  111615. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111616. private static _GetHalfFloatRGBAArrayBuffer;
  111617. private static _GetFloatRGBAArrayBuffer;
  111618. private static _GetFloatAsUIntRGBAArrayBuffer;
  111619. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111620. private static _GetRGBAArrayBuffer;
  111621. private static _ExtractLongWordOrder;
  111622. private static _GetRGBArrayBuffer;
  111623. private static _GetLuminanceArrayBuffer;
  111624. /**
  111625. * Uploads DDS Levels to a Babylon Texture
  111626. * @hidden
  111627. */
  111628. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111629. }
  111630. interface Engine {
  111631. /**
  111632. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111633. * @param rootUrl defines the url where the file to load is located
  111634. * @param scene defines the current scene
  111635. * @param lodScale defines scale to apply to the mip map selection
  111636. * @param lodOffset defines offset to apply to the mip map selection
  111637. * @param onLoad defines an optional callback raised when the texture is loaded
  111638. * @param onError defines an optional callback raised if there is an issue to load the texture
  111639. * @param format defines the format of the data
  111640. * @param forcedExtension defines the extension to use to pick the right loader
  111641. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111642. * @returns the cube texture as an InternalTexture
  111643. */
  111644. 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;
  111645. }
  111646. }
  111647. declare module BABYLON {
  111648. /**
  111649. * Implementation of the DDS Texture Loader.
  111650. * @hidden
  111651. */
  111652. export class _DDSTextureLoader implements IInternalTextureLoader {
  111653. /**
  111654. * Defines wether the loader supports cascade loading the different faces.
  111655. */
  111656. readonly supportCascades: boolean;
  111657. /**
  111658. * This returns if the loader support the current file information.
  111659. * @param extension defines the file extension of the file being loaded
  111660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111661. * @param fallback defines the fallback internal texture if any
  111662. * @param isBase64 defines whether the texture is encoded as a base64
  111663. * @param isBuffer defines whether the texture data are stored as a buffer
  111664. * @returns true if the loader can load the specified file
  111665. */
  111666. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111667. /**
  111668. * Transform the url before loading if required.
  111669. * @param rootUrl the url of the texture
  111670. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111671. * @returns the transformed texture
  111672. */
  111673. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111674. /**
  111675. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111676. * @param rootUrl the url of the texture
  111677. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111678. * @returns the fallback texture
  111679. */
  111680. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111681. /**
  111682. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111683. * @param data contains the texture data
  111684. * @param texture defines the BabylonJS internal texture
  111685. * @param createPolynomials will be true if polynomials have been requested
  111686. * @param onLoad defines the callback to trigger once the texture is ready
  111687. * @param onError defines the callback to trigger in case of error
  111688. */
  111689. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111690. /**
  111691. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111692. * @param data contains the texture data
  111693. * @param texture defines the BabylonJS internal texture
  111694. * @param callback defines the method to call once ready to upload
  111695. */
  111696. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111697. }
  111698. }
  111699. declare module BABYLON {
  111700. /** @hidden */
  111701. export var rgbdEncodePixelShader: {
  111702. name: string;
  111703. shader: string;
  111704. };
  111705. }
  111706. declare module BABYLON {
  111707. /**
  111708. * Raw texture data and descriptor sufficient for WebGL texture upload
  111709. */
  111710. export interface EnvironmentTextureInfo {
  111711. /**
  111712. * Version of the environment map
  111713. */
  111714. version: number;
  111715. /**
  111716. * Width of image
  111717. */
  111718. width: number;
  111719. /**
  111720. * Irradiance information stored in the file.
  111721. */
  111722. irradiance: any;
  111723. /**
  111724. * Specular information stored in the file.
  111725. */
  111726. specular: any;
  111727. }
  111728. /**
  111729. * Sets of helpers addressing the serialization and deserialization of environment texture
  111730. * stored in a BabylonJS env file.
  111731. * Those files are usually stored as .env files.
  111732. */
  111733. export class EnvironmentTextureTools {
  111734. /**
  111735. * Magic number identifying the env file.
  111736. */
  111737. private static _MagicBytes;
  111738. /**
  111739. * Gets the environment info from an env file.
  111740. * @param data The array buffer containing the .env bytes.
  111741. * @returns the environment file info (the json header) if successfully parsed.
  111742. */
  111743. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111744. /**
  111745. * Creates an environment texture from a loaded cube texture.
  111746. * @param texture defines the cube texture to convert in env file
  111747. * @return a promise containing the environment data if succesfull.
  111748. */
  111749. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111750. /**
  111751. * Creates a JSON representation of the spherical data.
  111752. * @param texture defines the texture containing the polynomials
  111753. * @return the JSON representation of the spherical info
  111754. */
  111755. private static _CreateEnvTextureIrradiance;
  111756. /**
  111757. * Uploads the texture info contained in the env file to the GPU.
  111758. * @param texture defines the internal texture to upload to
  111759. * @param arrayBuffer defines the buffer cotaining the data to load
  111760. * @param info defines the texture info retrieved through the GetEnvInfo method
  111761. * @returns a promise
  111762. */
  111763. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111764. /**
  111765. * Uploads the levels of image data to the GPU.
  111766. * @param texture defines the internal texture to upload to
  111767. * @param imageData defines the array buffer views of image data [mipmap][face]
  111768. * @returns a promise
  111769. */
  111770. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111771. /**
  111772. * Uploads spherical polynomials information to the texture.
  111773. * @param texture defines the texture we are trying to upload the information to
  111774. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111775. */
  111776. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111777. /** @hidden */
  111778. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111779. }
  111780. }
  111781. declare module BABYLON {
  111782. /**
  111783. * Implementation of the ENV Texture Loader.
  111784. * @hidden
  111785. */
  111786. export class _ENVTextureLoader implements IInternalTextureLoader {
  111787. /**
  111788. * Defines wether the loader supports cascade loading the different faces.
  111789. */
  111790. readonly supportCascades: boolean;
  111791. /**
  111792. * This returns if the loader support the current file information.
  111793. * @param extension defines the file extension of the file being loaded
  111794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111795. * @param fallback defines the fallback internal texture if any
  111796. * @param isBase64 defines whether the texture is encoded as a base64
  111797. * @param isBuffer defines whether the texture data are stored as a buffer
  111798. * @returns true if the loader can load the specified file
  111799. */
  111800. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111801. /**
  111802. * Transform the url before loading if required.
  111803. * @param rootUrl the url of the texture
  111804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111805. * @returns the transformed texture
  111806. */
  111807. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111808. /**
  111809. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111810. * @param rootUrl the url of the texture
  111811. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111812. * @returns the fallback texture
  111813. */
  111814. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111815. /**
  111816. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111817. * @param data contains the texture data
  111818. * @param texture defines the BabylonJS internal texture
  111819. * @param createPolynomials will be true if polynomials have been requested
  111820. * @param onLoad defines the callback to trigger once the texture is ready
  111821. * @param onError defines the callback to trigger in case of error
  111822. */
  111823. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111824. /**
  111825. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111826. * @param data contains the texture data
  111827. * @param texture defines the BabylonJS internal texture
  111828. * @param callback defines the method to call once ready to upload
  111829. */
  111830. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111831. }
  111832. }
  111833. declare module BABYLON {
  111834. /**
  111835. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111836. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111837. */
  111838. export class KhronosTextureContainer {
  111839. /** contents of the KTX container file */
  111840. arrayBuffer: any;
  111841. private static HEADER_LEN;
  111842. private static COMPRESSED_2D;
  111843. private static COMPRESSED_3D;
  111844. private static TEX_2D;
  111845. private static TEX_3D;
  111846. /**
  111847. * Gets the openGL type
  111848. */
  111849. glType: number;
  111850. /**
  111851. * Gets the openGL type size
  111852. */
  111853. glTypeSize: number;
  111854. /**
  111855. * Gets the openGL format
  111856. */
  111857. glFormat: number;
  111858. /**
  111859. * Gets the openGL internal format
  111860. */
  111861. glInternalFormat: number;
  111862. /**
  111863. * Gets the base internal format
  111864. */
  111865. glBaseInternalFormat: number;
  111866. /**
  111867. * Gets image width in pixel
  111868. */
  111869. pixelWidth: number;
  111870. /**
  111871. * Gets image height in pixel
  111872. */
  111873. pixelHeight: number;
  111874. /**
  111875. * Gets image depth in pixels
  111876. */
  111877. pixelDepth: number;
  111878. /**
  111879. * Gets the number of array elements
  111880. */
  111881. numberOfArrayElements: number;
  111882. /**
  111883. * Gets the number of faces
  111884. */
  111885. numberOfFaces: number;
  111886. /**
  111887. * Gets the number of mipmap levels
  111888. */
  111889. numberOfMipmapLevels: number;
  111890. /**
  111891. * Gets the bytes of key value data
  111892. */
  111893. bytesOfKeyValueData: number;
  111894. /**
  111895. * Gets the load type
  111896. */
  111897. loadType: number;
  111898. /**
  111899. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111900. */
  111901. isInvalid: boolean;
  111902. /**
  111903. * Creates a new KhronosTextureContainer
  111904. * @param arrayBuffer contents of the KTX container file
  111905. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111906. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111907. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111908. */
  111909. constructor(
  111910. /** contents of the KTX container file */
  111911. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111912. /**
  111913. * Uploads KTX content to a Babylon Texture.
  111914. * It is assumed that the texture has already been created & is currently bound
  111915. * @hidden
  111916. */
  111917. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111918. private _upload2DCompressedLevels;
  111919. }
  111920. }
  111921. declare module BABYLON {
  111922. /**
  111923. * Implementation of the KTX Texture Loader.
  111924. * @hidden
  111925. */
  111926. export class _KTXTextureLoader implements IInternalTextureLoader {
  111927. /**
  111928. * Defines wether the loader supports cascade loading the different faces.
  111929. */
  111930. readonly supportCascades: boolean;
  111931. /**
  111932. * This returns if the loader support the current file information.
  111933. * @param extension defines the file extension of the file being loaded
  111934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111935. * @param fallback defines the fallback internal texture if any
  111936. * @param isBase64 defines whether the texture is encoded as a base64
  111937. * @param isBuffer defines whether the texture data are stored as a buffer
  111938. * @returns true if the loader can load the specified file
  111939. */
  111940. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111941. /**
  111942. * Transform the url before loading if required.
  111943. * @param rootUrl the url of the texture
  111944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111945. * @returns the transformed texture
  111946. */
  111947. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111948. /**
  111949. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111950. * @param rootUrl the url of the texture
  111951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111952. * @returns the fallback texture
  111953. */
  111954. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111955. /**
  111956. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111957. * @param data contains the texture data
  111958. * @param texture defines the BabylonJS internal texture
  111959. * @param createPolynomials will be true if polynomials have been requested
  111960. * @param onLoad defines the callback to trigger once the texture is ready
  111961. * @param onError defines the callback to trigger in case of error
  111962. */
  111963. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111964. /**
  111965. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111966. * @param data contains the texture data
  111967. * @param texture defines the BabylonJS internal texture
  111968. * @param callback defines the method to call once ready to upload
  111969. */
  111970. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111971. }
  111972. }
  111973. declare module BABYLON {
  111974. /**
  111975. * Options for the default xr helper
  111976. */
  111977. export class WebXRDefaultExperienceOptions {
  111978. /**
  111979. * Floor meshes that should be used for teleporting
  111980. */
  111981. floorMeshes: Array<AbstractMesh>;
  111982. }
  111983. /**
  111984. * Default experience which provides a similar setup to the previous webVRExperience
  111985. */
  111986. export class WebXRDefaultExperience {
  111987. /**
  111988. * Base experience
  111989. */
  111990. baseExperience: WebXRExperienceHelper;
  111991. /**
  111992. * Input experience extension
  111993. */
  111994. input: WebXRInput;
  111995. /**
  111996. * Loads the controller models
  111997. */
  111998. controllerModelLoader: WebXRControllerModelLoader;
  111999. /**
  112000. * Enables laser pointer and selection
  112001. */
  112002. pointerSelection: WebXRControllerPointerSelection;
  112003. /**
  112004. * Enables teleportation
  112005. */
  112006. teleportation: WebXRControllerTeleportation;
  112007. /**
  112008. * Enables ui for enetering/exiting xr
  112009. */
  112010. enterExitUI: WebXREnterExitUI;
  112011. /**
  112012. * Default output canvas xr should render to
  112013. */
  112014. outputCanvas: WebXRManagedOutputCanvas;
  112015. /**
  112016. * Creates the default xr experience
  112017. * @param scene scene
  112018. * @param options options for basic configuration
  112019. * @returns resulting WebXRDefaultExperience
  112020. */
  112021. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112022. private constructor();
  112023. /**
  112024. * DIsposes of the experience helper
  112025. */
  112026. dispose(): void;
  112027. }
  112028. }
  112029. declare module BABYLON {
  112030. /** @hidden */
  112031. export var _forceSceneHelpersToBundle: boolean;
  112032. interface Scene {
  112033. /**
  112034. * Creates a default light for the scene.
  112035. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  112036. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  112037. */
  112038. createDefaultLight(replace?: boolean): void;
  112039. /**
  112040. * Creates a default camera for the scene.
  112041. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  112042. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112043. * @param replace has default false, when true replaces the active camera in the scene
  112044. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  112045. */
  112046. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112047. /**
  112048. * Creates a default camera and a default light.
  112049. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  112050. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  112051. * @param replace has the default false, when true replaces the active camera/light in the scene
  112052. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  112053. */
  112054. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  112055. /**
  112056. * Creates a new sky box
  112057. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  112058. * @param environmentTexture defines the texture to use as environment texture
  112059. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  112060. * @param scale defines the overall scale of the skybox
  112061. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  112062. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  112063. * @returns a new mesh holding the sky box
  112064. */
  112065. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  112066. /**
  112067. * Creates a new environment
  112068. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  112069. * @param options defines the options you can use to configure the environment
  112070. * @returns the new EnvironmentHelper
  112071. */
  112072. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  112073. /**
  112074. * Creates a new VREXperienceHelper
  112075. * @see http://doc.babylonjs.com/how_to/webvr_helper
  112076. * @param webVROptions defines the options used to create the new VREXperienceHelper
  112077. * @returns a new VREXperienceHelper
  112078. */
  112079. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  112080. /**
  112081. * Creates a new WebXRDefaultExperience
  112082. * @see http://doc.babylonjs.com/how_to/webxr
  112083. * @param options experience options
  112084. * @returns a promise for a new WebXRDefaultExperience
  112085. */
  112086. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  112087. }
  112088. }
  112089. declare module BABYLON {
  112090. /**
  112091. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  112092. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  112093. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  112094. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112095. */
  112096. export class VideoDome extends TransformNode {
  112097. /**
  112098. * Define the video source as a Monoscopic panoramic 360 video.
  112099. */
  112100. static readonly MODE_MONOSCOPIC: number;
  112101. /**
  112102. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112103. */
  112104. static readonly MODE_TOPBOTTOM: number;
  112105. /**
  112106. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112107. */
  112108. static readonly MODE_SIDEBYSIDE: number;
  112109. private _useDirectMapping;
  112110. /**
  112111. * The video texture being displayed on the sphere
  112112. */
  112113. protected _videoTexture: VideoTexture;
  112114. /**
  112115. * Gets the video texture being displayed on the sphere
  112116. */
  112117. readonly videoTexture: VideoTexture;
  112118. /**
  112119. * The skybox material
  112120. */
  112121. protected _material: BackgroundMaterial;
  112122. /**
  112123. * The surface used for the skybox
  112124. */
  112125. protected _mesh: Mesh;
  112126. /**
  112127. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112128. * Also see the options.resolution property.
  112129. */
  112130. fovMultiplier: number;
  112131. private _videoMode;
  112132. /**
  112133. * Gets or set the current video mode for the video. It can be:
  112134. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  112135. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  112136. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  112137. */
  112138. videoMode: number;
  112139. /**
  112140. * Oberserver used in Stereoscopic VR Mode.
  112141. */
  112142. private _onBeforeCameraRenderObserver;
  112143. /**
  112144. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  112145. * @param name Element's name, child elements will append suffixes for their own names.
  112146. * @param urlsOrVideo defines the url(s) or the video element to use
  112147. * @param options An object containing optional or exposed sub element properties
  112148. */
  112149. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  112150. resolution?: number;
  112151. clickToPlay?: boolean;
  112152. autoPlay?: boolean;
  112153. loop?: boolean;
  112154. size?: number;
  112155. poster?: string;
  112156. faceForward?: boolean;
  112157. useDirectMapping?: boolean;
  112158. }, scene: Scene);
  112159. private _changeVideoMode;
  112160. /**
  112161. * Releases resources associated with this node.
  112162. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112163. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112164. */
  112165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112166. }
  112167. }
  112168. declare module BABYLON {
  112169. /**
  112170. * This class can be used to get instrumentation data from a Babylon engine
  112171. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112172. */
  112173. export class EngineInstrumentation implements IDisposable {
  112174. /**
  112175. * Define the instrumented engine.
  112176. */
  112177. engine: Engine;
  112178. private _captureGPUFrameTime;
  112179. private _gpuFrameTimeToken;
  112180. private _gpuFrameTime;
  112181. private _captureShaderCompilationTime;
  112182. private _shaderCompilationTime;
  112183. private _onBeginFrameObserver;
  112184. private _onEndFrameObserver;
  112185. private _onBeforeShaderCompilationObserver;
  112186. private _onAfterShaderCompilationObserver;
  112187. /**
  112188. * Gets the perf counter used for GPU frame time
  112189. */
  112190. readonly gpuFrameTimeCounter: PerfCounter;
  112191. /**
  112192. * Gets the GPU frame time capture status
  112193. */
  112194. /**
  112195. * Enable or disable the GPU frame time capture
  112196. */
  112197. captureGPUFrameTime: boolean;
  112198. /**
  112199. * Gets the perf counter used for shader compilation time
  112200. */
  112201. readonly shaderCompilationTimeCounter: PerfCounter;
  112202. /**
  112203. * Gets the shader compilation time capture status
  112204. */
  112205. /**
  112206. * Enable or disable the shader compilation time capture
  112207. */
  112208. captureShaderCompilationTime: boolean;
  112209. /**
  112210. * Instantiates a new engine instrumentation.
  112211. * This class can be used to get instrumentation data from a Babylon engine
  112212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  112213. * @param engine Defines the engine to instrument
  112214. */
  112215. constructor(
  112216. /**
  112217. * Define the instrumented engine.
  112218. */
  112219. engine: Engine);
  112220. /**
  112221. * Dispose and release associated resources.
  112222. */
  112223. dispose(): void;
  112224. }
  112225. }
  112226. declare module BABYLON {
  112227. /**
  112228. * This class can be used to get instrumentation data from a Babylon engine
  112229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112230. */
  112231. export class SceneInstrumentation implements IDisposable {
  112232. /**
  112233. * Defines the scene to instrument
  112234. */
  112235. scene: Scene;
  112236. private _captureActiveMeshesEvaluationTime;
  112237. private _activeMeshesEvaluationTime;
  112238. private _captureRenderTargetsRenderTime;
  112239. private _renderTargetsRenderTime;
  112240. private _captureFrameTime;
  112241. private _frameTime;
  112242. private _captureRenderTime;
  112243. private _renderTime;
  112244. private _captureInterFrameTime;
  112245. private _interFrameTime;
  112246. private _captureParticlesRenderTime;
  112247. private _particlesRenderTime;
  112248. private _captureSpritesRenderTime;
  112249. private _spritesRenderTime;
  112250. private _capturePhysicsTime;
  112251. private _physicsTime;
  112252. private _captureAnimationsTime;
  112253. private _animationsTime;
  112254. private _captureCameraRenderTime;
  112255. private _cameraRenderTime;
  112256. private _onBeforeActiveMeshesEvaluationObserver;
  112257. private _onAfterActiveMeshesEvaluationObserver;
  112258. private _onBeforeRenderTargetsRenderObserver;
  112259. private _onAfterRenderTargetsRenderObserver;
  112260. private _onAfterRenderObserver;
  112261. private _onBeforeDrawPhaseObserver;
  112262. private _onAfterDrawPhaseObserver;
  112263. private _onBeforeAnimationsObserver;
  112264. private _onBeforeParticlesRenderingObserver;
  112265. private _onAfterParticlesRenderingObserver;
  112266. private _onBeforeSpritesRenderingObserver;
  112267. private _onAfterSpritesRenderingObserver;
  112268. private _onBeforePhysicsObserver;
  112269. private _onAfterPhysicsObserver;
  112270. private _onAfterAnimationsObserver;
  112271. private _onBeforeCameraRenderObserver;
  112272. private _onAfterCameraRenderObserver;
  112273. /**
  112274. * Gets the perf counter used for active meshes evaluation time
  112275. */
  112276. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  112277. /**
  112278. * Gets the active meshes evaluation time capture status
  112279. */
  112280. /**
  112281. * Enable or disable the active meshes evaluation time capture
  112282. */
  112283. captureActiveMeshesEvaluationTime: boolean;
  112284. /**
  112285. * Gets the perf counter used for render targets render time
  112286. */
  112287. readonly renderTargetsRenderTimeCounter: PerfCounter;
  112288. /**
  112289. * Gets the render targets render time capture status
  112290. */
  112291. /**
  112292. * Enable or disable the render targets render time capture
  112293. */
  112294. captureRenderTargetsRenderTime: boolean;
  112295. /**
  112296. * Gets the perf counter used for particles render time
  112297. */
  112298. readonly particlesRenderTimeCounter: PerfCounter;
  112299. /**
  112300. * Gets the particles render time capture status
  112301. */
  112302. /**
  112303. * Enable or disable the particles render time capture
  112304. */
  112305. captureParticlesRenderTime: boolean;
  112306. /**
  112307. * Gets the perf counter used for sprites render time
  112308. */
  112309. readonly spritesRenderTimeCounter: PerfCounter;
  112310. /**
  112311. * Gets the sprites render time capture status
  112312. */
  112313. /**
  112314. * Enable or disable the sprites render time capture
  112315. */
  112316. captureSpritesRenderTime: boolean;
  112317. /**
  112318. * Gets the perf counter used for physics time
  112319. */
  112320. readonly physicsTimeCounter: PerfCounter;
  112321. /**
  112322. * Gets the physics time capture status
  112323. */
  112324. /**
  112325. * Enable or disable the physics time capture
  112326. */
  112327. capturePhysicsTime: boolean;
  112328. /**
  112329. * Gets the perf counter used for animations time
  112330. */
  112331. readonly animationsTimeCounter: PerfCounter;
  112332. /**
  112333. * Gets the animations time capture status
  112334. */
  112335. /**
  112336. * Enable or disable the animations time capture
  112337. */
  112338. captureAnimationsTime: boolean;
  112339. /**
  112340. * Gets the perf counter used for frame time capture
  112341. */
  112342. readonly frameTimeCounter: PerfCounter;
  112343. /**
  112344. * Gets the frame time capture status
  112345. */
  112346. /**
  112347. * Enable or disable the frame time capture
  112348. */
  112349. captureFrameTime: boolean;
  112350. /**
  112351. * Gets the perf counter used for inter-frames time capture
  112352. */
  112353. readonly interFrameTimeCounter: PerfCounter;
  112354. /**
  112355. * Gets the inter-frames time capture status
  112356. */
  112357. /**
  112358. * Enable or disable the inter-frames time capture
  112359. */
  112360. captureInterFrameTime: boolean;
  112361. /**
  112362. * Gets the perf counter used for render time capture
  112363. */
  112364. readonly renderTimeCounter: PerfCounter;
  112365. /**
  112366. * Gets the render time capture status
  112367. */
  112368. /**
  112369. * Enable or disable the render time capture
  112370. */
  112371. captureRenderTime: boolean;
  112372. /**
  112373. * Gets the perf counter used for camera render time capture
  112374. */
  112375. readonly cameraRenderTimeCounter: PerfCounter;
  112376. /**
  112377. * Gets the camera render time capture status
  112378. */
  112379. /**
  112380. * Enable or disable the camera render time capture
  112381. */
  112382. captureCameraRenderTime: boolean;
  112383. /**
  112384. * Gets the perf counter used for draw calls
  112385. */
  112386. readonly drawCallsCounter: PerfCounter;
  112387. /**
  112388. * Instantiates a new scene instrumentation.
  112389. * This class can be used to get instrumentation data from a Babylon engine
  112390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  112391. * @param scene Defines the scene to instrument
  112392. */
  112393. constructor(
  112394. /**
  112395. * Defines the scene to instrument
  112396. */
  112397. scene: Scene);
  112398. /**
  112399. * Dispose and release associated resources.
  112400. */
  112401. dispose(): void;
  112402. }
  112403. }
  112404. declare module BABYLON {
  112405. /** @hidden */
  112406. export var glowMapGenerationPixelShader: {
  112407. name: string;
  112408. shader: string;
  112409. };
  112410. }
  112411. declare module BABYLON {
  112412. /** @hidden */
  112413. export var glowMapGenerationVertexShader: {
  112414. name: string;
  112415. shader: string;
  112416. };
  112417. }
  112418. declare module BABYLON {
  112419. /**
  112420. * Effect layer options. This helps customizing the behaviour
  112421. * of the effect layer.
  112422. */
  112423. export interface IEffectLayerOptions {
  112424. /**
  112425. * Multiplication factor apply to the canvas size to compute the render target size
  112426. * used to generated the objects (the smaller the faster).
  112427. */
  112428. mainTextureRatio: number;
  112429. /**
  112430. * Enforces a fixed size texture to ensure effect stability across devices.
  112431. */
  112432. mainTextureFixedSize?: number;
  112433. /**
  112434. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  112435. */
  112436. alphaBlendingMode: number;
  112437. /**
  112438. * The camera attached to the layer.
  112439. */
  112440. camera: Nullable<Camera>;
  112441. /**
  112442. * The rendering group to draw the layer in.
  112443. */
  112444. renderingGroupId: number;
  112445. }
  112446. /**
  112447. * The effect layer Helps adding post process effect blended with the main pass.
  112448. *
  112449. * This can be for instance use to generate glow or higlight effects on the scene.
  112450. *
  112451. * The effect layer class can not be used directly and is intented to inherited from to be
  112452. * customized per effects.
  112453. */
  112454. export abstract class EffectLayer {
  112455. private _vertexBuffers;
  112456. private _indexBuffer;
  112457. private _cachedDefines;
  112458. private _effectLayerMapGenerationEffect;
  112459. private _effectLayerOptions;
  112460. private _mergeEffect;
  112461. protected _scene: Scene;
  112462. protected _engine: Engine;
  112463. protected _maxSize: number;
  112464. protected _mainTextureDesiredSize: ISize;
  112465. protected _mainTexture: RenderTargetTexture;
  112466. protected _shouldRender: boolean;
  112467. protected _postProcesses: PostProcess[];
  112468. protected _textures: BaseTexture[];
  112469. protected _emissiveTextureAndColor: {
  112470. texture: Nullable<BaseTexture>;
  112471. color: Color4;
  112472. };
  112473. /**
  112474. * The name of the layer
  112475. */
  112476. name: string;
  112477. /**
  112478. * The clear color of the texture used to generate the glow map.
  112479. */
  112480. neutralColor: Color4;
  112481. /**
  112482. * Specifies wether the highlight layer is enabled or not.
  112483. */
  112484. isEnabled: boolean;
  112485. /**
  112486. * Gets the camera attached to the layer.
  112487. */
  112488. readonly camera: Nullable<Camera>;
  112489. /**
  112490. * Gets the rendering group id the layer should render in.
  112491. */
  112492. renderingGroupId: number;
  112493. /**
  112494. * An event triggered when the effect layer has been disposed.
  112495. */
  112496. onDisposeObservable: Observable<EffectLayer>;
  112497. /**
  112498. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  112499. */
  112500. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  112501. /**
  112502. * An event triggered when the generated texture is being merged in the scene.
  112503. */
  112504. onBeforeComposeObservable: Observable<EffectLayer>;
  112505. /**
  112506. * An event triggered when the generated texture has been merged in the scene.
  112507. */
  112508. onAfterComposeObservable: Observable<EffectLayer>;
  112509. /**
  112510. * An event triggered when the efffect layer changes its size.
  112511. */
  112512. onSizeChangedObservable: Observable<EffectLayer>;
  112513. /** @hidden */
  112514. static _SceneComponentInitialization: (scene: Scene) => void;
  112515. /**
  112516. * Instantiates a new effect Layer and references it in the scene.
  112517. * @param name The name of the layer
  112518. * @param scene The scene to use the layer in
  112519. */
  112520. constructor(
  112521. /** The Friendly of the effect in the scene */
  112522. name: string, scene: Scene);
  112523. /**
  112524. * Get the effect name of the layer.
  112525. * @return The effect name
  112526. */
  112527. abstract getEffectName(): string;
  112528. /**
  112529. * Checks for the readiness of the element composing the layer.
  112530. * @param subMesh the mesh to check for
  112531. * @param useInstances specify wether or not to use instances to render the mesh
  112532. * @return true if ready otherwise, false
  112533. */
  112534. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112535. /**
  112536. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112537. * @returns true if the effect requires stencil during the main canvas render pass.
  112538. */
  112539. abstract needStencil(): boolean;
  112540. /**
  112541. * Create the merge effect. This is the shader use to blit the information back
  112542. * to the main canvas at the end of the scene rendering.
  112543. * @returns The effect containing the shader used to merge the effect on the main canvas
  112544. */
  112545. protected abstract _createMergeEffect(): Effect;
  112546. /**
  112547. * Creates the render target textures and post processes used in the effect layer.
  112548. */
  112549. protected abstract _createTextureAndPostProcesses(): void;
  112550. /**
  112551. * Implementation specific of rendering the generating effect on the main canvas.
  112552. * @param effect The effect used to render through
  112553. */
  112554. protected abstract _internalRender(effect: Effect): void;
  112555. /**
  112556. * Sets the required values for both the emissive texture and and the main color.
  112557. */
  112558. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112559. /**
  112560. * Free any resources and references associated to a mesh.
  112561. * Internal use
  112562. * @param mesh The mesh to free.
  112563. */
  112564. abstract _disposeMesh(mesh: Mesh): void;
  112565. /**
  112566. * Serializes this layer (Glow or Highlight for example)
  112567. * @returns a serialized layer object
  112568. */
  112569. abstract serialize?(): any;
  112570. /**
  112571. * Initializes the effect layer with the required options.
  112572. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  112573. */
  112574. protected _init(options: Partial<IEffectLayerOptions>): void;
  112575. /**
  112576. * Generates the index buffer of the full screen quad blending to the main canvas.
  112577. */
  112578. private _generateIndexBuffer;
  112579. /**
  112580. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  112581. */
  112582. private _generateVertexBuffer;
  112583. /**
  112584. * Sets the main texture desired size which is the closest power of two
  112585. * of the engine canvas size.
  112586. */
  112587. private _setMainTextureSize;
  112588. /**
  112589. * Creates the main texture for the effect layer.
  112590. */
  112591. protected _createMainTexture(): void;
  112592. /**
  112593. * Adds specific effects defines.
  112594. * @param defines The defines to add specifics to.
  112595. */
  112596. protected _addCustomEffectDefines(defines: string[]): void;
  112597. /**
  112598. * Checks for the readiness of the element composing the layer.
  112599. * @param subMesh the mesh to check for
  112600. * @param useInstances specify wether or not to use instances to render the mesh
  112601. * @param emissiveTexture the associated emissive texture used to generate the glow
  112602. * @return true if ready otherwise, false
  112603. */
  112604. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  112605. /**
  112606. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  112607. */
  112608. render(): void;
  112609. /**
  112610. * Determine if a given mesh will be used in the current effect.
  112611. * @param mesh mesh to test
  112612. * @returns true if the mesh will be used
  112613. */
  112614. hasMesh(mesh: AbstractMesh): boolean;
  112615. /**
  112616. * Returns true if the layer contains information to display, otherwise false.
  112617. * @returns true if the glow layer should be rendered
  112618. */
  112619. shouldRender(): boolean;
  112620. /**
  112621. * Returns true if the mesh should render, otherwise false.
  112622. * @param mesh The mesh to render
  112623. * @returns true if it should render otherwise false
  112624. */
  112625. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  112626. /**
  112627. * Returns true if the mesh can be rendered, otherwise false.
  112628. * @param mesh The mesh to render
  112629. * @param material The material used on the mesh
  112630. * @returns true if it can be rendered otherwise false
  112631. */
  112632. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112633. /**
  112634. * Returns true if the mesh should render, otherwise false.
  112635. * @param mesh The mesh to render
  112636. * @returns true if it should render otherwise false
  112637. */
  112638. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  112639. /**
  112640. * Renders the submesh passed in parameter to the generation map.
  112641. */
  112642. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  112643. /**
  112644. * Rebuild the required buffers.
  112645. * @hidden Internal use only.
  112646. */
  112647. _rebuild(): void;
  112648. /**
  112649. * Dispose only the render target textures and post process.
  112650. */
  112651. private _disposeTextureAndPostProcesses;
  112652. /**
  112653. * Dispose the highlight layer and free resources.
  112654. */
  112655. dispose(): void;
  112656. /**
  112657. * Gets the class name of the effect layer
  112658. * @returns the string with the class name of the effect layer
  112659. */
  112660. getClassName(): string;
  112661. /**
  112662. * Creates an effect layer from parsed effect layer data
  112663. * @param parsedEffectLayer defines effect layer data
  112664. * @param scene defines the current scene
  112665. * @param rootUrl defines the root URL containing the effect layer information
  112666. * @returns a parsed effect Layer
  112667. */
  112668. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  112669. }
  112670. }
  112671. declare module BABYLON {
  112672. interface AbstractScene {
  112673. /**
  112674. * The list of effect layers (highlights/glow) added to the scene
  112675. * @see http://doc.babylonjs.com/how_to/highlight_layer
  112676. * @see http://doc.babylonjs.com/how_to/glow_layer
  112677. */
  112678. effectLayers: Array<EffectLayer>;
  112679. /**
  112680. * Removes the given effect layer from this scene.
  112681. * @param toRemove defines the effect layer to remove
  112682. * @returns the index of the removed effect layer
  112683. */
  112684. removeEffectLayer(toRemove: EffectLayer): number;
  112685. /**
  112686. * Adds the given effect layer to this scene
  112687. * @param newEffectLayer defines the effect layer to add
  112688. */
  112689. addEffectLayer(newEffectLayer: EffectLayer): void;
  112690. }
  112691. /**
  112692. * Defines the layer scene component responsible to manage any effect layers
  112693. * in a given scene.
  112694. */
  112695. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  112696. /**
  112697. * The component name helpfull to identify the component in the list of scene components.
  112698. */
  112699. readonly name: string;
  112700. /**
  112701. * The scene the component belongs to.
  112702. */
  112703. scene: Scene;
  112704. private _engine;
  112705. private _renderEffects;
  112706. private _needStencil;
  112707. private _previousStencilState;
  112708. /**
  112709. * Creates a new instance of the component for the given scene
  112710. * @param scene Defines the scene to register the component in
  112711. */
  112712. constructor(scene: Scene);
  112713. /**
  112714. * Registers the component in a given scene
  112715. */
  112716. register(): void;
  112717. /**
  112718. * Rebuilds the elements related to this component in case of
  112719. * context lost for instance.
  112720. */
  112721. rebuild(): void;
  112722. /**
  112723. * Serializes the component data to the specified json object
  112724. * @param serializationObject The object to serialize to
  112725. */
  112726. serialize(serializationObject: any): void;
  112727. /**
  112728. * Adds all the elements from the container to the scene
  112729. * @param container the container holding the elements
  112730. */
  112731. addFromContainer(container: AbstractScene): void;
  112732. /**
  112733. * Removes all the elements in the container from the scene
  112734. * @param container contains the elements to remove
  112735. * @param dispose if the removed element should be disposed (default: false)
  112736. */
  112737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112738. /**
  112739. * Disposes the component and the associated ressources.
  112740. */
  112741. dispose(): void;
  112742. private _isReadyForMesh;
  112743. private _renderMainTexture;
  112744. private _setStencil;
  112745. private _setStencilBack;
  112746. private _draw;
  112747. private _drawCamera;
  112748. private _drawRenderingGroup;
  112749. }
  112750. }
  112751. declare module BABYLON {
  112752. /** @hidden */
  112753. export var glowMapMergePixelShader: {
  112754. name: string;
  112755. shader: string;
  112756. };
  112757. }
  112758. declare module BABYLON {
  112759. /** @hidden */
  112760. export var glowMapMergeVertexShader: {
  112761. name: string;
  112762. shader: string;
  112763. };
  112764. }
  112765. declare module BABYLON {
  112766. interface AbstractScene {
  112767. /**
  112768. * Return a the first highlight layer of the scene with a given name.
  112769. * @param name The name of the highlight layer to look for.
  112770. * @return The highlight layer if found otherwise null.
  112771. */
  112772. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112773. }
  112774. /**
  112775. * Glow layer options. This helps customizing the behaviour
  112776. * of the glow layer.
  112777. */
  112778. export interface IGlowLayerOptions {
  112779. /**
  112780. * Multiplication factor apply to the canvas size to compute the render target size
  112781. * used to generated the glowing objects (the smaller the faster).
  112782. */
  112783. mainTextureRatio: number;
  112784. /**
  112785. * Enforces a fixed size texture to ensure resize independant blur.
  112786. */
  112787. mainTextureFixedSize?: number;
  112788. /**
  112789. * How big is the kernel of the blur texture.
  112790. */
  112791. blurKernelSize: number;
  112792. /**
  112793. * The camera attached to the layer.
  112794. */
  112795. camera: Nullable<Camera>;
  112796. /**
  112797. * Enable MSAA by chosing the number of samples.
  112798. */
  112799. mainTextureSamples?: number;
  112800. /**
  112801. * The rendering group to draw the layer in.
  112802. */
  112803. renderingGroupId: number;
  112804. }
  112805. /**
  112806. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112807. *
  112808. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112809. * glowy meshes to your scene.
  112810. *
  112811. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112812. */
  112813. export class GlowLayer extends EffectLayer {
  112814. /**
  112815. * Effect Name of the layer.
  112816. */
  112817. static readonly EffectName: string;
  112818. /**
  112819. * The default blur kernel size used for the glow.
  112820. */
  112821. static DefaultBlurKernelSize: number;
  112822. /**
  112823. * The default texture size ratio used for the glow.
  112824. */
  112825. static DefaultTextureRatio: number;
  112826. /**
  112827. * Sets the kernel size of the blur.
  112828. */
  112829. /**
  112830. * Gets the kernel size of the blur.
  112831. */
  112832. blurKernelSize: number;
  112833. /**
  112834. * Sets the glow intensity.
  112835. */
  112836. /**
  112837. * Gets the glow intensity.
  112838. */
  112839. intensity: number;
  112840. private _options;
  112841. private _intensity;
  112842. private _horizontalBlurPostprocess1;
  112843. private _verticalBlurPostprocess1;
  112844. private _horizontalBlurPostprocess2;
  112845. private _verticalBlurPostprocess2;
  112846. private _blurTexture1;
  112847. private _blurTexture2;
  112848. private _postProcesses1;
  112849. private _postProcesses2;
  112850. private _includedOnlyMeshes;
  112851. private _excludedMeshes;
  112852. /**
  112853. * Callback used to let the user override the color selection on a per mesh basis
  112854. */
  112855. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112856. /**
  112857. * Callback used to let the user override the texture selection on a per mesh basis
  112858. */
  112859. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112860. /**
  112861. * Instantiates a new glow Layer and references it to the scene.
  112862. * @param name The name of the layer
  112863. * @param scene The scene to use the layer in
  112864. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112865. */
  112866. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112867. /**
  112868. * Get the effect name of the layer.
  112869. * @return The effect name
  112870. */
  112871. getEffectName(): string;
  112872. /**
  112873. * Create the merge effect. This is the shader use to blit the information back
  112874. * to the main canvas at the end of the scene rendering.
  112875. */
  112876. protected _createMergeEffect(): Effect;
  112877. /**
  112878. * Creates the render target textures and post processes used in the glow layer.
  112879. */
  112880. protected _createTextureAndPostProcesses(): void;
  112881. /**
  112882. * Checks for the readiness of the element composing the layer.
  112883. * @param subMesh the mesh to check for
  112884. * @param useInstances specify wether or not to use instances to render the mesh
  112885. * @param emissiveTexture the associated emissive texture used to generate the glow
  112886. * @return true if ready otherwise, false
  112887. */
  112888. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112889. /**
  112890. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112891. */
  112892. needStencil(): boolean;
  112893. /**
  112894. * Returns true if the mesh can be rendered, otherwise false.
  112895. * @param mesh The mesh to render
  112896. * @param material The material used on the mesh
  112897. * @returns true if it can be rendered otherwise false
  112898. */
  112899. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112900. /**
  112901. * Implementation specific of rendering the generating effect on the main canvas.
  112902. * @param effect The effect used to render through
  112903. */
  112904. protected _internalRender(effect: Effect): void;
  112905. /**
  112906. * Sets the required values for both the emissive texture and and the main color.
  112907. */
  112908. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112909. /**
  112910. * Returns true if the mesh should render, otherwise false.
  112911. * @param mesh The mesh to render
  112912. * @returns true if it should render otherwise false
  112913. */
  112914. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112915. /**
  112916. * Adds specific effects defines.
  112917. * @param defines The defines to add specifics to.
  112918. */
  112919. protected _addCustomEffectDefines(defines: string[]): void;
  112920. /**
  112921. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112922. * @param mesh The mesh to exclude from the glow layer
  112923. */
  112924. addExcludedMesh(mesh: Mesh): void;
  112925. /**
  112926. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112927. * @param mesh The mesh to remove
  112928. */
  112929. removeExcludedMesh(mesh: Mesh): void;
  112930. /**
  112931. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112932. * @param mesh The mesh to include in the glow layer
  112933. */
  112934. addIncludedOnlyMesh(mesh: Mesh): void;
  112935. /**
  112936. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112937. * @param mesh The mesh to remove
  112938. */
  112939. removeIncludedOnlyMesh(mesh: Mesh): void;
  112940. /**
  112941. * Determine if a given mesh will be used in the glow layer
  112942. * @param mesh The mesh to test
  112943. * @returns true if the mesh will be highlighted by the current glow layer
  112944. */
  112945. hasMesh(mesh: AbstractMesh): boolean;
  112946. /**
  112947. * Free any resources and references associated to a mesh.
  112948. * Internal use
  112949. * @param mesh The mesh to free.
  112950. * @hidden
  112951. */
  112952. _disposeMesh(mesh: Mesh): void;
  112953. /**
  112954. * Gets the class name of the effect layer
  112955. * @returns the string with the class name of the effect layer
  112956. */
  112957. getClassName(): string;
  112958. /**
  112959. * Serializes this glow layer
  112960. * @returns a serialized glow layer object
  112961. */
  112962. serialize(): any;
  112963. /**
  112964. * Creates a Glow Layer from parsed glow layer data
  112965. * @param parsedGlowLayer defines glow layer data
  112966. * @param scene defines the current scene
  112967. * @param rootUrl defines the root URL containing the glow layer information
  112968. * @returns a parsed Glow Layer
  112969. */
  112970. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112971. }
  112972. }
  112973. declare module BABYLON {
  112974. /** @hidden */
  112975. export var glowBlurPostProcessPixelShader: {
  112976. name: string;
  112977. shader: string;
  112978. };
  112979. }
  112980. declare module BABYLON {
  112981. interface AbstractScene {
  112982. /**
  112983. * Return a the first highlight layer of the scene with a given name.
  112984. * @param name The name of the highlight layer to look for.
  112985. * @return The highlight layer if found otherwise null.
  112986. */
  112987. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112988. }
  112989. /**
  112990. * Highlight layer options. This helps customizing the behaviour
  112991. * of the highlight layer.
  112992. */
  112993. export interface IHighlightLayerOptions {
  112994. /**
  112995. * Multiplication factor apply to the canvas size to compute the render target size
  112996. * used to generated the glowing objects (the smaller the faster).
  112997. */
  112998. mainTextureRatio: number;
  112999. /**
  113000. * Enforces a fixed size texture to ensure resize independant blur.
  113001. */
  113002. mainTextureFixedSize?: number;
  113003. /**
  113004. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  113005. * of the picture to blur (the smaller the faster).
  113006. */
  113007. blurTextureSizeRatio: number;
  113008. /**
  113009. * How big in texel of the blur texture is the vertical blur.
  113010. */
  113011. blurVerticalSize: number;
  113012. /**
  113013. * How big in texel of the blur texture is the horizontal blur.
  113014. */
  113015. blurHorizontalSize: number;
  113016. /**
  113017. * Alpha blending mode used to apply the blur. Default is combine.
  113018. */
  113019. alphaBlendingMode: number;
  113020. /**
  113021. * The camera attached to the layer.
  113022. */
  113023. camera: Nullable<Camera>;
  113024. /**
  113025. * Should we display highlight as a solid stroke?
  113026. */
  113027. isStroke?: boolean;
  113028. /**
  113029. * The rendering group to draw the layer in.
  113030. */
  113031. renderingGroupId: number;
  113032. }
  113033. /**
  113034. * The highlight layer Helps adding a glow effect around a mesh.
  113035. *
  113036. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  113037. * glowy meshes to your scene.
  113038. *
  113039. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  113040. */
  113041. export class HighlightLayer extends EffectLayer {
  113042. name: string;
  113043. /**
  113044. * Effect Name of the highlight layer.
  113045. */
  113046. static readonly EffectName: string;
  113047. /**
  113048. * The neutral color used during the preparation of the glow effect.
  113049. * This is black by default as the blend operation is a blend operation.
  113050. */
  113051. static NeutralColor: Color4;
  113052. /**
  113053. * Stencil value used for glowing meshes.
  113054. */
  113055. static GlowingMeshStencilReference: number;
  113056. /**
  113057. * Stencil value used for the other meshes in the scene.
  113058. */
  113059. static NormalMeshStencilReference: number;
  113060. /**
  113061. * Specifies whether or not the inner glow is ACTIVE in the layer.
  113062. */
  113063. innerGlow: boolean;
  113064. /**
  113065. * Specifies whether or not the outer glow is ACTIVE in the layer.
  113066. */
  113067. outerGlow: boolean;
  113068. /**
  113069. * Specifies the horizontal size of the blur.
  113070. */
  113071. /**
  113072. * Gets the horizontal size of the blur.
  113073. */
  113074. blurHorizontalSize: number;
  113075. /**
  113076. * Specifies the vertical size of the blur.
  113077. */
  113078. /**
  113079. * Gets the vertical size of the blur.
  113080. */
  113081. blurVerticalSize: number;
  113082. /**
  113083. * An event triggered when the highlight layer is being blurred.
  113084. */
  113085. onBeforeBlurObservable: Observable<HighlightLayer>;
  113086. /**
  113087. * An event triggered when the highlight layer has been blurred.
  113088. */
  113089. onAfterBlurObservable: Observable<HighlightLayer>;
  113090. private _instanceGlowingMeshStencilReference;
  113091. private _options;
  113092. private _downSamplePostprocess;
  113093. private _horizontalBlurPostprocess;
  113094. private _verticalBlurPostprocess;
  113095. private _blurTexture;
  113096. private _meshes;
  113097. private _excludedMeshes;
  113098. /**
  113099. * Instantiates a new highlight Layer and references it to the scene..
  113100. * @param name The name of the layer
  113101. * @param scene The scene to use the layer in
  113102. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  113103. */
  113104. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  113105. /**
  113106. * Get the effect name of the layer.
  113107. * @return The effect name
  113108. */
  113109. getEffectName(): string;
  113110. /**
  113111. * Create the merge effect. This is the shader use to blit the information back
  113112. * to the main canvas at the end of the scene rendering.
  113113. */
  113114. protected _createMergeEffect(): Effect;
  113115. /**
  113116. * Creates the render target textures and post processes used in the highlight layer.
  113117. */
  113118. protected _createTextureAndPostProcesses(): void;
  113119. /**
  113120. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  113121. */
  113122. needStencil(): boolean;
  113123. /**
  113124. * Checks for the readiness of the element composing the layer.
  113125. * @param subMesh the mesh to check for
  113126. * @param useInstances specify wether or not to use instances to render the mesh
  113127. * @param emissiveTexture the associated emissive texture used to generate the glow
  113128. * @return true if ready otherwise, false
  113129. */
  113130. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113131. /**
  113132. * Implementation specific of rendering the generating effect on the main canvas.
  113133. * @param effect The effect used to render through
  113134. */
  113135. protected _internalRender(effect: Effect): void;
  113136. /**
  113137. * Returns true if the layer contains information to display, otherwise false.
  113138. */
  113139. shouldRender(): boolean;
  113140. /**
  113141. * Returns true if the mesh should render, otherwise false.
  113142. * @param mesh The mesh to render
  113143. * @returns true if it should render otherwise false
  113144. */
  113145. protected _shouldRenderMesh(mesh: Mesh): boolean;
  113146. /**
  113147. * Sets the required values for both the emissive texture and and the main color.
  113148. */
  113149. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  113150. /**
  113151. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  113152. * @param mesh The mesh to exclude from the highlight layer
  113153. */
  113154. addExcludedMesh(mesh: Mesh): void;
  113155. /**
  113156. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  113157. * @param mesh The mesh to highlight
  113158. */
  113159. removeExcludedMesh(mesh: Mesh): void;
  113160. /**
  113161. * Determine if a given mesh will be highlighted by the current HighlightLayer
  113162. * @param mesh mesh to test
  113163. * @returns true if the mesh will be highlighted by the current HighlightLayer
  113164. */
  113165. hasMesh(mesh: AbstractMesh): boolean;
  113166. /**
  113167. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  113168. * @param mesh The mesh to highlight
  113169. * @param color The color of the highlight
  113170. * @param glowEmissiveOnly Extract the glow from the emissive texture
  113171. */
  113172. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  113173. /**
  113174. * Remove a mesh from the highlight layer in order to make it stop glowing.
  113175. * @param mesh The mesh to highlight
  113176. */
  113177. removeMesh(mesh: Mesh): void;
  113178. /**
  113179. * Force the stencil to the normal expected value for none glowing parts
  113180. */
  113181. private _defaultStencilReference;
  113182. /**
  113183. * Free any resources and references associated to a mesh.
  113184. * Internal use
  113185. * @param mesh The mesh to free.
  113186. * @hidden
  113187. */
  113188. _disposeMesh(mesh: Mesh): void;
  113189. /**
  113190. * Dispose the highlight layer and free resources.
  113191. */
  113192. dispose(): void;
  113193. /**
  113194. * Gets the class name of the effect layer
  113195. * @returns the string with the class name of the effect layer
  113196. */
  113197. getClassName(): string;
  113198. /**
  113199. * Serializes this Highlight layer
  113200. * @returns a serialized Highlight layer object
  113201. */
  113202. serialize(): any;
  113203. /**
  113204. * Creates a Highlight layer from parsed Highlight layer data
  113205. * @param parsedHightlightLayer defines the Highlight layer data
  113206. * @param scene defines the current scene
  113207. * @param rootUrl defines the root URL containing the Highlight layer information
  113208. * @returns a parsed Highlight layer
  113209. */
  113210. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  113211. }
  113212. }
  113213. declare module BABYLON {
  113214. interface AbstractScene {
  113215. /**
  113216. * The list of layers (background and foreground) of the scene
  113217. */
  113218. layers: Array<Layer>;
  113219. }
  113220. /**
  113221. * Defines the layer scene component responsible to manage any layers
  113222. * in a given scene.
  113223. */
  113224. export class LayerSceneComponent implements ISceneComponent {
  113225. /**
  113226. * The component name helpfull to identify the component in the list of scene components.
  113227. */
  113228. readonly name: string;
  113229. /**
  113230. * The scene the component belongs to.
  113231. */
  113232. scene: Scene;
  113233. private _engine;
  113234. /**
  113235. * Creates a new instance of the component for the given scene
  113236. * @param scene Defines the scene to register the component in
  113237. */
  113238. constructor(scene: Scene);
  113239. /**
  113240. * Registers the component in a given scene
  113241. */
  113242. register(): void;
  113243. /**
  113244. * Rebuilds the elements related to this component in case of
  113245. * context lost for instance.
  113246. */
  113247. rebuild(): void;
  113248. /**
  113249. * Disposes the component and the associated ressources.
  113250. */
  113251. dispose(): void;
  113252. private _draw;
  113253. private _drawCameraPredicate;
  113254. private _drawCameraBackground;
  113255. private _drawCameraForeground;
  113256. private _drawRenderTargetPredicate;
  113257. private _drawRenderTargetBackground;
  113258. private _drawRenderTargetForeground;
  113259. /**
  113260. * Adds all the elements from the container to the scene
  113261. * @param container the container holding the elements
  113262. */
  113263. addFromContainer(container: AbstractScene): void;
  113264. /**
  113265. * Removes all the elements in the container from the scene
  113266. * @param container contains the elements to remove
  113267. * @param dispose if the removed element should be disposed (default: false)
  113268. */
  113269. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113270. }
  113271. }
  113272. declare module BABYLON {
  113273. /** @hidden */
  113274. export var layerPixelShader: {
  113275. name: string;
  113276. shader: string;
  113277. };
  113278. }
  113279. declare module BABYLON {
  113280. /** @hidden */
  113281. export var layerVertexShader: {
  113282. name: string;
  113283. shader: string;
  113284. };
  113285. }
  113286. declare module BABYLON {
  113287. /**
  113288. * This represents a full screen 2d layer.
  113289. * This can be useful to display a picture in the background of your scene for instance.
  113290. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113291. */
  113292. export class Layer {
  113293. /**
  113294. * Define the name of the layer.
  113295. */
  113296. name: string;
  113297. /**
  113298. * Define the texture the layer should display.
  113299. */
  113300. texture: Nullable<Texture>;
  113301. /**
  113302. * Is the layer in background or foreground.
  113303. */
  113304. isBackground: boolean;
  113305. /**
  113306. * Define the color of the layer (instead of texture).
  113307. */
  113308. color: Color4;
  113309. /**
  113310. * Define the scale of the layer in order to zoom in out of the texture.
  113311. */
  113312. scale: Vector2;
  113313. /**
  113314. * Define an offset for the layer in order to shift the texture.
  113315. */
  113316. offset: Vector2;
  113317. /**
  113318. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  113319. */
  113320. alphaBlendingMode: number;
  113321. /**
  113322. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  113323. * Alpha test will not mix with the background color in case of transparency.
  113324. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  113325. */
  113326. alphaTest: boolean;
  113327. /**
  113328. * Define a mask to restrict the layer to only some of the scene cameras.
  113329. */
  113330. layerMask: number;
  113331. /**
  113332. * Define the list of render target the layer is visible into.
  113333. */
  113334. renderTargetTextures: RenderTargetTexture[];
  113335. /**
  113336. * Define if the layer is only used in renderTarget or if it also
  113337. * renders in the main frame buffer of the canvas.
  113338. */
  113339. renderOnlyInRenderTargetTextures: boolean;
  113340. private _scene;
  113341. private _vertexBuffers;
  113342. private _indexBuffer;
  113343. private _effect;
  113344. private _alphaTestEffect;
  113345. /**
  113346. * An event triggered when the layer is disposed.
  113347. */
  113348. onDisposeObservable: Observable<Layer>;
  113349. private _onDisposeObserver;
  113350. /**
  113351. * Back compatibility with callback before the onDisposeObservable existed.
  113352. * The set callback will be triggered when the layer has been disposed.
  113353. */
  113354. onDispose: () => void;
  113355. /**
  113356. * An event triggered before rendering the scene
  113357. */
  113358. onBeforeRenderObservable: Observable<Layer>;
  113359. private _onBeforeRenderObserver;
  113360. /**
  113361. * Back compatibility with callback before the onBeforeRenderObservable existed.
  113362. * The set callback will be triggered just before rendering the layer.
  113363. */
  113364. onBeforeRender: () => void;
  113365. /**
  113366. * An event triggered after rendering the scene
  113367. */
  113368. onAfterRenderObservable: Observable<Layer>;
  113369. private _onAfterRenderObserver;
  113370. /**
  113371. * Back compatibility with callback before the onAfterRenderObservable existed.
  113372. * The set callback will be triggered just after rendering the layer.
  113373. */
  113374. onAfterRender: () => void;
  113375. /**
  113376. * Instantiates a new layer.
  113377. * This represents a full screen 2d layer.
  113378. * This can be useful to display a picture in the background of your scene for instance.
  113379. * @see https://www.babylonjs-playground.com/#08A2BS#1
  113380. * @param name Define the name of the layer in the scene
  113381. * @param imgUrl Define the url of the texture to display in the layer
  113382. * @param scene Define the scene the layer belongs to
  113383. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  113384. * @param color Defines a color for the layer
  113385. */
  113386. constructor(
  113387. /**
  113388. * Define the name of the layer.
  113389. */
  113390. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  113391. private _createIndexBuffer;
  113392. /** @hidden */
  113393. _rebuild(): void;
  113394. /**
  113395. * Renders the layer in the scene.
  113396. */
  113397. render(): void;
  113398. /**
  113399. * Disposes and releases the associated ressources.
  113400. */
  113401. dispose(): void;
  113402. }
  113403. }
  113404. declare module BABYLON {
  113405. /** @hidden */
  113406. export var lensFlarePixelShader: {
  113407. name: string;
  113408. shader: string;
  113409. };
  113410. }
  113411. declare module BABYLON {
  113412. /** @hidden */
  113413. export var lensFlareVertexShader: {
  113414. name: string;
  113415. shader: string;
  113416. };
  113417. }
  113418. declare module BABYLON {
  113419. /**
  113420. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113421. * It is usually composed of several `lensFlare`.
  113422. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113423. */
  113424. export class LensFlareSystem {
  113425. /**
  113426. * Define the name of the lens flare system
  113427. */
  113428. name: string;
  113429. /**
  113430. * List of lens flares used in this system.
  113431. */
  113432. lensFlares: LensFlare[];
  113433. /**
  113434. * Define a limit from the border the lens flare can be visible.
  113435. */
  113436. borderLimit: number;
  113437. /**
  113438. * Define a viewport border we do not want to see the lens flare in.
  113439. */
  113440. viewportBorder: number;
  113441. /**
  113442. * Define a predicate which could limit the list of meshes able to occlude the effect.
  113443. */
  113444. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  113445. /**
  113446. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  113447. */
  113448. layerMask: number;
  113449. /**
  113450. * Define the id of the lens flare system in the scene.
  113451. * (equal to name by default)
  113452. */
  113453. id: string;
  113454. private _scene;
  113455. private _emitter;
  113456. private _vertexBuffers;
  113457. private _indexBuffer;
  113458. private _effect;
  113459. private _positionX;
  113460. private _positionY;
  113461. private _isEnabled;
  113462. /** @hidden */
  113463. static _SceneComponentInitialization: (scene: Scene) => void;
  113464. /**
  113465. * Instantiates a lens flare system.
  113466. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  113467. * It is usually composed of several `lensFlare`.
  113468. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113469. * @param name Define the name of the lens flare system in the scene
  113470. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  113471. * @param scene Define the scene the lens flare system belongs to
  113472. */
  113473. constructor(
  113474. /**
  113475. * Define the name of the lens flare system
  113476. */
  113477. name: string, emitter: any, scene: Scene);
  113478. /**
  113479. * Define if the lens flare system is enabled.
  113480. */
  113481. isEnabled: boolean;
  113482. /**
  113483. * Get the scene the effects belongs to.
  113484. * @returns the scene holding the lens flare system
  113485. */
  113486. getScene(): Scene;
  113487. /**
  113488. * Get the emitter of the lens flare system.
  113489. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113490. * @returns the emitter of the lens flare system
  113491. */
  113492. getEmitter(): any;
  113493. /**
  113494. * Set the emitter of the lens flare system.
  113495. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  113496. * @param newEmitter Define the new emitter of the system
  113497. */
  113498. setEmitter(newEmitter: any): void;
  113499. /**
  113500. * Get the lens flare system emitter position.
  113501. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  113502. * @returns the position
  113503. */
  113504. getEmitterPosition(): Vector3;
  113505. /**
  113506. * @hidden
  113507. */
  113508. computeEffectivePosition(globalViewport: Viewport): boolean;
  113509. /** @hidden */
  113510. _isVisible(): boolean;
  113511. /**
  113512. * @hidden
  113513. */
  113514. render(): boolean;
  113515. /**
  113516. * Dispose and release the lens flare with its associated resources.
  113517. */
  113518. dispose(): void;
  113519. /**
  113520. * Parse a lens flare system from a JSON repressentation
  113521. * @param parsedLensFlareSystem Define the JSON to parse
  113522. * @param scene Define the scene the parsed system should be instantiated in
  113523. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  113524. * @returns the parsed system
  113525. */
  113526. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  113527. /**
  113528. * Serialize the current Lens Flare System into a JSON representation.
  113529. * @returns the serialized JSON
  113530. */
  113531. serialize(): any;
  113532. }
  113533. }
  113534. declare module BABYLON {
  113535. /**
  113536. * This represents one of the lens effect in a `lensFlareSystem`.
  113537. * It controls one of the indiviual texture used in the effect.
  113538. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113539. */
  113540. export class LensFlare {
  113541. /**
  113542. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113543. */
  113544. size: number;
  113545. /**
  113546. * 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.
  113547. */
  113548. position: number;
  113549. /**
  113550. * Define the lens color.
  113551. */
  113552. color: Color3;
  113553. /**
  113554. * Define the lens texture.
  113555. */
  113556. texture: Nullable<Texture>;
  113557. /**
  113558. * Define the alpha mode to render this particular lens.
  113559. */
  113560. alphaMode: number;
  113561. private _system;
  113562. /**
  113563. * Creates a new Lens Flare.
  113564. * This represents one of the lens effect in a `lensFlareSystem`.
  113565. * It controls one of the indiviual texture used in the effect.
  113566. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113567. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  113568. * @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.
  113569. * @param color Define the lens color
  113570. * @param imgUrl Define the lens texture url
  113571. * @param system Define the `lensFlareSystem` this flare is part of
  113572. * @returns The newly created Lens Flare
  113573. */
  113574. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  113575. /**
  113576. * Instantiates a new Lens Flare.
  113577. * This represents one of the lens effect in a `lensFlareSystem`.
  113578. * It controls one of the indiviual texture used in the effect.
  113579. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113580. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  113581. * @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.
  113582. * @param color Define the lens color
  113583. * @param imgUrl Define the lens texture url
  113584. * @param system Define the `lensFlareSystem` this flare is part of
  113585. */
  113586. constructor(
  113587. /**
  113588. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  113589. */
  113590. size: number,
  113591. /**
  113592. * 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.
  113593. */
  113594. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  113595. /**
  113596. * Dispose and release the lens flare with its associated resources.
  113597. */
  113598. dispose(): void;
  113599. }
  113600. }
  113601. declare module BABYLON {
  113602. interface AbstractScene {
  113603. /**
  113604. * The list of lens flare system added to the scene
  113605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113606. */
  113607. lensFlareSystems: Array<LensFlareSystem>;
  113608. /**
  113609. * Removes the given lens flare system from this scene.
  113610. * @param toRemove The lens flare system to remove
  113611. * @returns The index of the removed lens flare system
  113612. */
  113613. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  113614. /**
  113615. * Adds the given lens flare system to this scene
  113616. * @param newLensFlareSystem The lens flare system to add
  113617. */
  113618. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  113619. /**
  113620. * Gets a lens flare system using its name
  113621. * @param name defines the name to look for
  113622. * @returns the lens flare system or null if not found
  113623. */
  113624. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  113625. /**
  113626. * Gets a lens flare system using its id
  113627. * @param id defines the id to look for
  113628. * @returns the lens flare system or null if not found
  113629. */
  113630. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  113631. }
  113632. /**
  113633. * Defines the lens flare scene component responsible to manage any lens flares
  113634. * in a given scene.
  113635. */
  113636. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  113637. /**
  113638. * The component name helpfull to identify the component in the list of scene components.
  113639. */
  113640. readonly name: string;
  113641. /**
  113642. * The scene the component belongs to.
  113643. */
  113644. scene: Scene;
  113645. /**
  113646. * Creates a new instance of the component for the given scene
  113647. * @param scene Defines the scene to register the component in
  113648. */
  113649. constructor(scene: Scene);
  113650. /**
  113651. * Registers the component in a given scene
  113652. */
  113653. register(): void;
  113654. /**
  113655. * Rebuilds the elements related to this component in case of
  113656. * context lost for instance.
  113657. */
  113658. rebuild(): void;
  113659. /**
  113660. * Adds all the elements from the container to the scene
  113661. * @param container the container holding the elements
  113662. */
  113663. addFromContainer(container: AbstractScene): void;
  113664. /**
  113665. * Removes all the elements in the container from the scene
  113666. * @param container contains the elements to remove
  113667. * @param dispose if the removed element should be disposed (default: false)
  113668. */
  113669. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113670. /**
  113671. * Serializes the component data to the specified json object
  113672. * @param serializationObject The object to serialize to
  113673. */
  113674. serialize(serializationObject: any): void;
  113675. /**
  113676. * Disposes the component and the associated ressources.
  113677. */
  113678. dispose(): void;
  113679. private _draw;
  113680. }
  113681. }
  113682. declare module BABYLON {
  113683. /**
  113684. * Defines the shadow generator component responsible to manage any shadow generators
  113685. * in a given scene.
  113686. */
  113687. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  113688. /**
  113689. * The component name helpfull to identify the component in the list of scene components.
  113690. */
  113691. readonly name: string;
  113692. /**
  113693. * The scene the component belongs to.
  113694. */
  113695. scene: Scene;
  113696. /**
  113697. * Creates a new instance of the component for the given scene
  113698. * @param scene Defines the scene to register the component in
  113699. */
  113700. constructor(scene: Scene);
  113701. /**
  113702. * Registers the component in a given scene
  113703. */
  113704. register(): void;
  113705. /**
  113706. * Rebuilds the elements related to this component in case of
  113707. * context lost for instance.
  113708. */
  113709. rebuild(): void;
  113710. /**
  113711. * Serializes the component data to the specified json object
  113712. * @param serializationObject The object to serialize to
  113713. */
  113714. serialize(serializationObject: any): void;
  113715. /**
  113716. * Adds all the elements from the container to the scene
  113717. * @param container the container holding the elements
  113718. */
  113719. addFromContainer(container: AbstractScene): void;
  113720. /**
  113721. * Removes all the elements in the container from the scene
  113722. * @param container contains the elements to remove
  113723. * @param dispose if the removed element should be disposed (default: false)
  113724. */
  113725. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113726. /**
  113727. * Rebuilds the elements related to this component in case of
  113728. * context lost for instance.
  113729. */
  113730. dispose(): void;
  113731. private _gatherRenderTargets;
  113732. }
  113733. }
  113734. declare module BABYLON {
  113735. /**
  113736. * A point light is a light defined by an unique point in world space.
  113737. * The light is emitted in every direction from this point.
  113738. * A good example of a point light is a standard light bulb.
  113739. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113740. */
  113741. export class PointLight extends ShadowLight {
  113742. private _shadowAngle;
  113743. /**
  113744. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113745. * This specifies what angle the shadow will use to be created.
  113746. *
  113747. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113748. */
  113749. /**
  113750. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113751. * This specifies what angle the shadow will use to be created.
  113752. *
  113753. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113754. */
  113755. shadowAngle: number;
  113756. /**
  113757. * Gets the direction if it has been set.
  113758. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113759. */
  113760. /**
  113761. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113762. */
  113763. direction: Vector3;
  113764. /**
  113765. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113766. * A PointLight emits the light in every direction.
  113767. * It can cast shadows.
  113768. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113769. * ```javascript
  113770. * var pointLight = new PointLight("pl", camera.position, scene);
  113771. * ```
  113772. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113773. * @param name The light friendly name
  113774. * @param position The position of the point light in the scene
  113775. * @param scene The scene the lights belongs to
  113776. */
  113777. constructor(name: string, position: Vector3, scene: Scene);
  113778. /**
  113779. * Returns the string "PointLight"
  113780. * @returns the class name
  113781. */
  113782. getClassName(): string;
  113783. /**
  113784. * Returns the integer 0.
  113785. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113786. */
  113787. getTypeID(): number;
  113788. /**
  113789. * Specifies wether or not the shadowmap should be a cube texture.
  113790. * @returns true if the shadowmap needs to be a cube texture.
  113791. */
  113792. needCube(): boolean;
  113793. /**
  113794. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113795. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113796. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113797. */
  113798. getShadowDirection(faceIndex?: number): Vector3;
  113799. /**
  113800. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113801. * - fov = PI / 2
  113802. * - aspect ratio : 1.0
  113803. * - z-near and far equal to the active camera minZ and maxZ.
  113804. * Returns the PointLight.
  113805. */
  113806. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113807. protected _buildUniformLayout(): void;
  113808. /**
  113809. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113810. * @param effect The effect to update
  113811. * @param lightIndex The index of the light in the effect to update
  113812. * @returns The point light
  113813. */
  113814. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113815. /**
  113816. * Prepares the list of defines specific to the light type.
  113817. * @param defines the list of defines
  113818. * @param lightIndex defines the index of the light for the effect
  113819. */
  113820. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113821. }
  113822. }
  113823. declare module BABYLON {
  113824. /**
  113825. * Header information of HDR texture files.
  113826. */
  113827. export interface HDRInfo {
  113828. /**
  113829. * The height of the texture in pixels.
  113830. */
  113831. height: number;
  113832. /**
  113833. * The width of the texture in pixels.
  113834. */
  113835. width: number;
  113836. /**
  113837. * The index of the beginning of the data in the binary file.
  113838. */
  113839. dataPosition: number;
  113840. }
  113841. /**
  113842. * This groups tools to convert HDR texture to native colors array.
  113843. */
  113844. export class HDRTools {
  113845. private static Ldexp;
  113846. private static Rgbe2float;
  113847. private static readStringLine;
  113848. /**
  113849. * Reads header information from an RGBE texture stored in a native array.
  113850. * More information on this format are available here:
  113851. * https://en.wikipedia.org/wiki/RGBE_image_format
  113852. *
  113853. * @param uint8array The binary file stored in native array.
  113854. * @return The header information.
  113855. */
  113856. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113857. /**
  113858. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113859. * This RGBE texture needs to store the information as a panorama.
  113860. *
  113861. * More information on this format are available here:
  113862. * https://en.wikipedia.org/wiki/RGBE_image_format
  113863. *
  113864. * @param buffer The binary file stored in an array buffer.
  113865. * @param size The expected size of the extracted cubemap.
  113866. * @return The Cube Map information.
  113867. */
  113868. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113869. /**
  113870. * Returns the pixels data extracted from an RGBE texture.
  113871. * This pixels will be stored left to right up to down in the R G B order in one array.
  113872. *
  113873. * More information on this format are available here:
  113874. * https://en.wikipedia.org/wiki/RGBE_image_format
  113875. *
  113876. * @param uint8array The binary file stored in an array buffer.
  113877. * @param hdrInfo The header information of the file.
  113878. * @return The pixels data in RGB right to left up to down order.
  113879. */
  113880. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113881. private static RGBE_ReadPixels_RLE;
  113882. }
  113883. }
  113884. declare module BABYLON {
  113885. /**
  113886. * This represents a texture coming from an HDR input.
  113887. *
  113888. * The only supported format is currently panorama picture stored in RGBE format.
  113889. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113890. */
  113891. export class HDRCubeTexture extends BaseTexture {
  113892. private static _facesMapping;
  113893. private _generateHarmonics;
  113894. private _noMipmap;
  113895. private _textureMatrix;
  113896. private _size;
  113897. private _onLoad;
  113898. private _onError;
  113899. /**
  113900. * The texture URL.
  113901. */
  113902. url: string;
  113903. /**
  113904. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113905. */
  113906. coordinatesMode: number;
  113907. protected _isBlocking: boolean;
  113908. /**
  113909. * Sets wether or not the texture is blocking during loading.
  113910. */
  113911. /**
  113912. * Gets wether or not the texture is blocking during loading.
  113913. */
  113914. isBlocking: boolean;
  113915. protected _rotationY: number;
  113916. /**
  113917. * Sets texture matrix rotation angle around Y axis in radians.
  113918. */
  113919. /**
  113920. * Gets texture matrix rotation angle around Y axis radians.
  113921. */
  113922. rotationY: number;
  113923. /**
  113924. * Gets or sets the center of the bounding box associated with the cube texture
  113925. * It must define where the camera used to render the texture was set
  113926. */
  113927. boundingBoxPosition: Vector3;
  113928. private _boundingBoxSize;
  113929. /**
  113930. * Gets or sets the size of the bounding box associated with the cube texture
  113931. * When defined, the cubemap will switch to local mode
  113932. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113933. * @example https://www.babylonjs-playground.com/#RNASML
  113934. */
  113935. boundingBoxSize: Vector3;
  113936. /**
  113937. * Instantiates an HDRTexture from the following parameters.
  113938. *
  113939. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113940. * @param scene The scene the texture will be used in
  113941. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113942. * @param noMipmap Forces to not generate the mipmap if true
  113943. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113944. * @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)
  113945. * @param reserved Reserved flag for internal use.
  113946. */
  113947. 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>);
  113948. /**
  113949. * Get the current class name of the texture useful for serialization or dynamic coding.
  113950. * @returns "HDRCubeTexture"
  113951. */
  113952. getClassName(): string;
  113953. /**
  113954. * Occurs when the file is raw .hdr file.
  113955. */
  113956. private loadTexture;
  113957. clone(): HDRCubeTexture;
  113958. delayLoad(): void;
  113959. /**
  113960. * Get the texture reflection matrix used to rotate/transform the reflection.
  113961. * @returns the reflection matrix
  113962. */
  113963. getReflectionTextureMatrix(): Matrix;
  113964. /**
  113965. * Set the texture reflection matrix used to rotate/transform the reflection.
  113966. * @param value Define the reflection matrix to set
  113967. */
  113968. setReflectionTextureMatrix(value: Matrix): void;
  113969. /**
  113970. * Parses a JSON representation of an HDR Texture in order to create the texture
  113971. * @param parsedTexture Define the JSON representation
  113972. * @param scene Define the scene the texture should be created in
  113973. * @param rootUrl Define the root url in case we need to load relative dependencies
  113974. * @returns the newly created texture after parsing
  113975. */
  113976. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113977. serialize(): any;
  113978. }
  113979. }
  113980. declare module BABYLON {
  113981. /**
  113982. * Class used to control physics engine
  113983. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113984. */
  113985. export class PhysicsEngine implements IPhysicsEngine {
  113986. private _physicsPlugin;
  113987. /**
  113988. * Global value used to control the smallest number supported by the simulation
  113989. */
  113990. static Epsilon: number;
  113991. private _impostors;
  113992. private _joints;
  113993. /**
  113994. * Gets the gravity vector used by the simulation
  113995. */
  113996. gravity: Vector3;
  113997. /**
  113998. * Factory used to create the default physics plugin.
  113999. * @returns The default physics plugin
  114000. */
  114001. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  114002. /**
  114003. * Creates a new Physics Engine
  114004. * @param gravity defines the gravity vector used by the simulation
  114005. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  114006. */
  114007. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  114008. /**
  114009. * Sets the gravity vector used by the simulation
  114010. * @param gravity defines the gravity vector to use
  114011. */
  114012. setGravity(gravity: Vector3): void;
  114013. /**
  114014. * Set the time step of the physics engine.
  114015. * Default is 1/60.
  114016. * To slow it down, enter 1/600 for example.
  114017. * To speed it up, 1/30
  114018. * @param newTimeStep defines the new timestep to apply to this world.
  114019. */
  114020. setTimeStep(newTimeStep?: number): void;
  114021. /**
  114022. * Get the time step of the physics engine.
  114023. * @returns the current time step
  114024. */
  114025. getTimeStep(): number;
  114026. /**
  114027. * Release all resources
  114028. */
  114029. dispose(): void;
  114030. /**
  114031. * Gets the name of the current physics plugin
  114032. * @returns the name of the plugin
  114033. */
  114034. getPhysicsPluginName(): string;
  114035. /**
  114036. * Adding a new impostor for the impostor tracking.
  114037. * This will be done by the impostor itself.
  114038. * @param impostor the impostor to add
  114039. */
  114040. addImpostor(impostor: PhysicsImpostor): void;
  114041. /**
  114042. * Remove an impostor from the engine.
  114043. * This impostor and its mesh will not longer be updated by the physics engine.
  114044. * @param impostor the impostor to remove
  114045. */
  114046. removeImpostor(impostor: PhysicsImpostor): void;
  114047. /**
  114048. * Add a joint to the physics engine
  114049. * @param mainImpostor defines the main impostor to which the joint is added.
  114050. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  114051. * @param joint defines the joint that will connect both impostors.
  114052. */
  114053. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114054. /**
  114055. * Removes a joint from the simulation
  114056. * @param mainImpostor defines the impostor used with the joint
  114057. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  114058. * @param joint defines the joint to remove
  114059. */
  114060. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  114061. /**
  114062. * Called by the scene. No need to call it.
  114063. * @param delta defines the timespam between frames
  114064. */
  114065. _step(delta: number): void;
  114066. /**
  114067. * Gets the current plugin used to run the simulation
  114068. * @returns current plugin
  114069. */
  114070. getPhysicsPlugin(): IPhysicsEnginePlugin;
  114071. /**
  114072. * Gets the list of physic impostors
  114073. * @returns an array of PhysicsImpostor
  114074. */
  114075. getImpostors(): Array<PhysicsImpostor>;
  114076. /**
  114077. * Gets the impostor for a physics enabled object
  114078. * @param object defines the object impersonated by the impostor
  114079. * @returns the PhysicsImpostor or null if not found
  114080. */
  114081. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  114082. /**
  114083. * Gets the impostor for a physics body object
  114084. * @param body defines physics body used by the impostor
  114085. * @returns the PhysicsImpostor or null if not found
  114086. */
  114087. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  114088. /**
  114089. * Does a raycast in the physics world
  114090. * @param from when should the ray start?
  114091. * @param to when should the ray end?
  114092. * @returns PhysicsRaycastResult
  114093. */
  114094. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114095. }
  114096. }
  114097. declare module BABYLON {
  114098. /** @hidden */
  114099. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  114100. private _useDeltaForWorldStep;
  114101. world: any;
  114102. name: string;
  114103. private _physicsMaterials;
  114104. private _fixedTimeStep;
  114105. private _cannonRaycastResult;
  114106. private _raycastResult;
  114107. private _physicsBodysToRemoveAfterStep;
  114108. BJSCANNON: any;
  114109. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  114110. setGravity(gravity: Vector3): void;
  114111. setTimeStep(timeStep: number): void;
  114112. getTimeStep(): number;
  114113. executeStep(delta: number): void;
  114114. private _removeMarkedPhysicsBodiesFromWorld;
  114115. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114116. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114117. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114118. private _processChildMeshes;
  114119. removePhysicsBody(impostor: PhysicsImpostor): void;
  114120. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114121. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114122. private _addMaterial;
  114123. private _checkWithEpsilon;
  114124. private _createShape;
  114125. private _createHeightmap;
  114126. private _minus90X;
  114127. private _plus90X;
  114128. private _tmpPosition;
  114129. private _tmpDeltaPosition;
  114130. private _tmpUnityRotation;
  114131. private _updatePhysicsBodyTransformation;
  114132. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114133. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114134. isSupported(): boolean;
  114135. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114136. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114138. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114139. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114140. getBodyMass(impostor: PhysicsImpostor): number;
  114141. getBodyFriction(impostor: PhysicsImpostor): number;
  114142. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114143. getBodyRestitution(impostor: PhysicsImpostor): number;
  114144. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114145. sleepBody(impostor: PhysicsImpostor): void;
  114146. wakeUpBody(impostor: PhysicsImpostor): void;
  114147. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  114148. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114149. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114150. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114151. getRadius(impostor: PhysicsImpostor): number;
  114152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114153. dispose(): void;
  114154. private _extendNamespace;
  114155. /**
  114156. * Does a raycast in the physics world
  114157. * @param from when should the ray start?
  114158. * @param to when should the ray end?
  114159. * @returns PhysicsRaycastResult
  114160. */
  114161. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114162. }
  114163. }
  114164. declare module BABYLON {
  114165. /** @hidden */
  114166. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  114167. world: any;
  114168. name: string;
  114169. BJSOIMO: any;
  114170. private _raycastResult;
  114171. constructor(iterations?: number, oimoInjection?: any);
  114172. setGravity(gravity: Vector3): void;
  114173. setTimeStep(timeStep: number): void;
  114174. getTimeStep(): number;
  114175. private _tmpImpostorsArray;
  114176. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114177. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114178. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114179. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114180. private _tmpPositionVector;
  114181. removePhysicsBody(impostor: PhysicsImpostor): void;
  114182. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114183. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114184. isSupported(): boolean;
  114185. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114186. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114187. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114188. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114189. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114190. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114191. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114192. getBodyMass(impostor: PhysicsImpostor): number;
  114193. getBodyFriction(impostor: PhysicsImpostor): number;
  114194. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114195. getBodyRestitution(impostor: PhysicsImpostor): number;
  114196. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114197. sleepBody(impostor: PhysicsImpostor): void;
  114198. wakeUpBody(impostor: PhysicsImpostor): void;
  114199. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114200. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  114201. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  114202. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114203. getRadius(impostor: PhysicsImpostor): number;
  114204. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114205. dispose(): void;
  114206. /**
  114207. * Does a raycast in the physics world
  114208. * @param from when should the ray start?
  114209. * @param to when should the ray end?
  114210. * @returns PhysicsRaycastResult
  114211. */
  114212. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114213. }
  114214. }
  114215. declare module BABYLON {
  114216. /**
  114217. * Class containing static functions to help procedurally build meshes
  114218. */
  114219. export class RibbonBuilder {
  114220. /**
  114221. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114222. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114223. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114224. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114225. * * 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
  114226. * * 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
  114227. * * 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
  114228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114230. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114231. * * 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
  114232. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114233. * * 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
  114234. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114236. * @param name defines the name of the mesh
  114237. * @param options defines the options used to create the mesh
  114238. * @param scene defines the hosting scene
  114239. * @returns the ribbon mesh
  114240. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114242. */
  114243. static CreateRibbon(name: string, options: {
  114244. pathArray: Vector3[][];
  114245. closeArray?: boolean;
  114246. closePath?: boolean;
  114247. offset?: number;
  114248. updatable?: boolean;
  114249. sideOrientation?: number;
  114250. frontUVs?: Vector4;
  114251. backUVs?: Vector4;
  114252. instance?: Mesh;
  114253. invertUV?: boolean;
  114254. uvs?: Vector2[];
  114255. colors?: Color4[];
  114256. }, scene?: Nullable<Scene>): Mesh;
  114257. }
  114258. }
  114259. declare module BABYLON {
  114260. /**
  114261. * Class containing static functions to help procedurally build meshes
  114262. */
  114263. export class ShapeBuilder {
  114264. /**
  114265. * 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.
  114266. * * 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.
  114267. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114268. * * 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.
  114269. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114270. * * 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
  114271. * * 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
  114272. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114275. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114277. * @param name defines the name of the mesh
  114278. * @param options defines the options used to create the mesh
  114279. * @param scene defines the hosting scene
  114280. * @returns the extruded shape mesh
  114281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114283. */
  114284. static ExtrudeShape(name: string, options: {
  114285. shape: Vector3[];
  114286. path: Vector3[];
  114287. scale?: number;
  114288. rotation?: number;
  114289. cap?: number;
  114290. updatable?: boolean;
  114291. sideOrientation?: number;
  114292. frontUVs?: Vector4;
  114293. backUVs?: Vector4;
  114294. instance?: Mesh;
  114295. invertUV?: boolean;
  114296. }, scene?: Nullable<Scene>): Mesh;
  114297. /**
  114298. * Creates an custom extruded shape mesh.
  114299. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114300. * * 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.
  114301. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114302. * * 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
  114303. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114304. * * 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
  114305. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114306. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114307. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114308. * * 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
  114309. * * 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
  114310. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114315. * @param name defines the name of the mesh
  114316. * @param options defines the options used to create the mesh
  114317. * @param scene defines the hosting scene
  114318. * @returns the custom extruded shape mesh
  114319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114322. */
  114323. static ExtrudeShapeCustom(name: string, options: {
  114324. shape: Vector3[];
  114325. path: Vector3[];
  114326. scaleFunction?: any;
  114327. rotationFunction?: any;
  114328. ribbonCloseArray?: boolean;
  114329. ribbonClosePath?: boolean;
  114330. cap?: number;
  114331. updatable?: boolean;
  114332. sideOrientation?: number;
  114333. frontUVs?: Vector4;
  114334. backUVs?: Vector4;
  114335. instance?: Mesh;
  114336. invertUV?: boolean;
  114337. }, scene?: Nullable<Scene>): Mesh;
  114338. private static _ExtrudeShapeGeneric;
  114339. }
  114340. }
  114341. declare module BABYLON {
  114342. /**
  114343. * AmmoJS Physics plugin
  114344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  114345. * @see https://github.com/kripken/ammo.js/
  114346. */
  114347. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  114348. private _useDeltaForWorldStep;
  114349. /**
  114350. * Reference to the Ammo library
  114351. */
  114352. bjsAMMO: any;
  114353. /**
  114354. * Created ammoJS world which physics bodies are added to
  114355. */
  114356. world: any;
  114357. /**
  114358. * Name of the plugin
  114359. */
  114360. name: string;
  114361. private _timeStep;
  114362. private _fixedTimeStep;
  114363. private _maxSteps;
  114364. private _tmpQuaternion;
  114365. private _tmpAmmoTransform;
  114366. private _tmpAmmoQuaternion;
  114367. private _tmpAmmoConcreteContactResultCallback;
  114368. private _collisionConfiguration;
  114369. private _dispatcher;
  114370. private _overlappingPairCache;
  114371. private _solver;
  114372. private _softBodySolver;
  114373. private _tmpAmmoVectorA;
  114374. private _tmpAmmoVectorB;
  114375. private _tmpAmmoVectorC;
  114376. private _tmpAmmoVectorD;
  114377. private _tmpContactCallbackResult;
  114378. private _tmpAmmoVectorRCA;
  114379. private _tmpAmmoVectorRCB;
  114380. private _raycastResult;
  114381. private static readonly DISABLE_COLLISION_FLAG;
  114382. private static readonly KINEMATIC_FLAG;
  114383. private static readonly DISABLE_DEACTIVATION_FLAG;
  114384. /**
  114385. * Initializes the ammoJS plugin
  114386. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  114387. * @param ammoInjection can be used to inject your own ammo reference
  114388. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  114389. */
  114390. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  114391. /**
  114392. * Sets the gravity of the physics world (m/(s^2))
  114393. * @param gravity Gravity to set
  114394. */
  114395. setGravity(gravity: Vector3): void;
  114396. /**
  114397. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  114398. * @param timeStep timestep to use in seconds
  114399. */
  114400. setTimeStep(timeStep: number): void;
  114401. /**
  114402. * 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)
  114403. * @param fixedTimeStep fixedTimeStep to use in seconds
  114404. */
  114405. setFixedTimeStep(fixedTimeStep: number): void;
  114406. /**
  114407. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  114408. * @param maxSteps the maximum number of steps by the physics engine per frame
  114409. */
  114410. setMaxSteps(maxSteps: number): void;
  114411. /**
  114412. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  114413. * @returns the current timestep in seconds
  114414. */
  114415. getTimeStep(): number;
  114416. private _isImpostorInContact;
  114417. private _isImpostorPairInContact;
  114418. private _stepSimulation;
  114419. /**
  114420. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  114421. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  114422. * After the step the babylon meshes are set to the position of the physics imposters
  114423. * @param delta amount of time to step forward
  114424. * @param impostors array of imposters to update before/after the step
  114425. */
  114426. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  114427. /**
  114428. * Update babylon mesh to match physics world object
  114429. * @param impostor imposter to match
  114430. */
  114431. private _afterSoftStep;
  114432. /**
  114433. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114434. * @param impostor imposter to match
  114435. */
  114436. private _ropeStep;
  114437. /**
  114438. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  114439. * @param impostor imposter to match
  114440. */
  114441. private _softbodyOrClothStep;
  114442. private _tmpVector;
  114443. private _tmpMatrix;
  114444. /**
  114445. * Applies an impulse on the imposter
  114446. * @param impostor imposter to apply impulse to
  114447. * @param force amount of force to be applied to the imposter
  114448. * @param contactPoint the location to apply the impulse on the imposter
  114449. */
  114450. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114451. /**
  114452. * Applies a force on the imposter
  114453. * @param impostor imposter to apply force
  114454. * @param force amount of force to be applied to the imposter
  114455. * @param contactPoint the location to apply the force on the imposter
  114456. */
  114457. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  114458. /**
  114459. * Creates a physics body using the plugin
  114460. * @param impostor the imposter to create the physics body on
  114461. */
  114462. generatePhysicsBody(impostor: PhysicsImpostor): void;
  114463. /**
  114464. * Removes the physics body from the imposter and disposes of the body's memory
  114465. * @param impostor imposter to remove the physics body from
  114466. */
  114467. removePhysicsBody(impostor: PhysicsImpostor): void;
  114468. /**
  114469. * Generates a joint
  114470. * @param impostorJoint the imposter joint to create the joint with
  114471. */
  114472. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  114473. /**
  114474. * Removes a joint
  114475. * @param impostorJoint the imposter joint to remove the joint from
  114476. */
  114477. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  114478. private _addMeshVerts;
  114479. /**
  114480. * Initialise the soft body vertices to match its object's (mesh) vertices
  114481. * Softbody vertices (nodes) are in world space and to match this
  114482. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114483. * @param impostor to create the softbody for
  114484. */
  114485. private _softVertexData;
  114486. /**
  114487. * Create an impostor's soft body
  114488. * @param impostor to create the softbody for
  114489. */
  114490. private _createSoftbody;
  114491. /**
  114492. * Create cloth for an impostor
  114493. * @param impostor to create the softbody for
  114494. */
  114495. private _createCloth;
  114496. /**
  114497. * Create rope for an impostor
  114498. * @param impostor to create the softbody for
  114499. */
  114500. private _createRope;
  114501. private _addHullVerts;
  114502. private _createShape;
  114503. /**
  114504. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114505. * @param impostor imposter containing the physics body and babylon object
  114506. */
  114507. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  114508. /**
  114509. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114510. * @param impostor imposter containing the physics body and babylon object
  114511. * @param newPosition new position
  114512. * @param newRotation new rotation
  114513. */
  114514. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  114515. /**
  114516. * If this plugin is supported
  114517. * @returns true if its supported
  114518. */
  114519. isSupported(): boolean;
  114520. /**
  114521. * Sets the linear velocity of the physics body
  114522. * @param impostor imposter to set the velocity on
  114523. * @param velocity velocity to set
  114524. */
  114525. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114526. /**
  114527. * Sets the angular velocity of the physics body
  114528. * @param impostor imposter to set the velocity on
  114529. * @param velocity velocity to set
  114530. */
  114531. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  114532. /**
  114533. * gets the linear velocity
  114534. * @param impostor imposter to get linear velocity from
  114535. * @returns linear velocity
  114536. */
  114537. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114538. /**
  114539. * gets the angular velocity
  114540. * @param impostor imposter to get angular velocity from
  114541. * @returns angular velocity
  114542. */
  114543. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  114544. /**
  114545. * Sets the mass of physics body
  114546. * @param impostor imposter to set the mass on
  114547. * @param mass mass to set
  114548. */
  114549. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  114550. /**
  114551. * Gets the mass of the physics body
  114552. * @param impostor imposter to get the mass from
  114553. * @returns mass
  114554. */
  114555. getBodyMass(impostor: PhysicsImpostor): number;
  114556. /**
  114557. * Gets friction of the impostor
  114558. * @param impostor impostor to get friction from
  114559. * @returns friction value
  114560. */
  114561. getBodyFriction(impostor: PhysicsImpostor): number;
  114562. /**
  114563. * Sets friction of the impostor
  114564. * @param impostor impostor to set friction on
  114565. * @param friction friction value
  114566. */
  114567. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  114568. /**
  114569. * Gets restitution of the impostor
  114570. * @param impostor impostor to get restitution from
  114571. * @returns restitution value
  114572. */
  114573. getBodyRestitution(impostor: PhysicsImpostor): number;
  114574. /**
  114575. * Sets resitution of the impostor
  114576. * @param impostor impostor to set resitution on
  114577. * @param restitution resitution value
  114578. */
  114579. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  114580. /**
  114581. * Gets pressure inside the impostor
  114582. * @param impostor impostor to get pressure from
  114583. * @returns pressure value
  114584. */
  114585. getBodyPressure(impostor: PhysicsImpostor): number;
  114586. /**
  114587. * Sets pressure inside a soft body impostor
  114588. * Cloth and rope must remain 0 pressure
  114589. * @param impostor impostor to set pressure on
  114590. * @param pressure pressure value
  114591. */
  114592. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  114593. /**
  114594. * Gets stiffness of the impostor
  114595. * @param impostor impostor to get stiffness from
  114596. * @returns pressure value
  114597. */
  114598. getBodyStiffness(impostor: PhysicsImpostor): number;
  114599. /**
  114600. * Sets stiffness of the impostor
  114601. * @param impostor impostor to set stiffness on
  114602. * @param stiffness stiffness value from 0 to 1
  114603. */
  114604. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  114605. /**
  114606. * Gets velocityIterations of the impostor
  114607. * @param impostor impostor to get velocity iterations from
  114608. * @returns velocityIterations value
  114609. */
  114610. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  114611. /**
  114612. * Sets velocityIterations of the impostor
  114613. * @param impostor impostor to set velocity iterations on
  114614. * @param velocityIterations velocityIterations value
  114615. */
  114616. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  114617. /**
  114618. * Gets positionIterations of the impostor
  114619. * @param impostor impostor to get position iterations from
  114620. * @returns positionIterations value
  114621. */
  114622. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  114623. /**
  114624. * Sets positionIterations of the impostor
  114625. * @param impostor impostor to set position on
  114626. * @param positionIterations positionIterations value
  114627. */
  114628. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  114629. /**
  114630. * Append an anchor to a cloth object
  114631. * @param impostor is the cloth impostor to add anchor to
  114632. * @param otherImpostor is the rigid impostor to anchor to
  114633. * @param width ratio across width from 0 to 1
  114634. * @param height ratio up height from 0 to 1
  114635. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114636. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114637. */
  114638. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114639. /**
  114640. * Append an hook to a rope object
  114641. * @param impostor is the rope impostor to add hook to
  114642. * @param otherImpostor is the rigid impostor to hook to
  114643. * @param length ratio along the rope from 0 to 1
  114644. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114645. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114646. */
  114647. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114648. /**
  114649. * Sleeps the physics body and stops it from being active
  114650. * @param impostor impostor to sleep
  114651. */
  114652. sleepBody(impostor: PhysicsImpostor): void;
  114653. /**
  114654. * Activates the physics body
  114655. * @param impostor impostor to activate
  114656. */
  114657. wakeUpBody(impostor: PhysicsImpostor): void;
  114658. /**
  114659. * Updates the distance parameters of the joint
  114660. * @param joint joint to update
  114661. * @param maxDistance maximum distance of the joint
  114662. * @param minDistance minimum distance of the joint
  114663. */
  114664. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114665. /**
  114666. * Sets a motor on the joint
  114667. * @param joint joint to set motor on
  114668. * @param speed speed of the motor
  114669. * @param maxForce maximum force of the motor
  114670. * @param motorIndex index of the motor
  114671. */
  114672. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114673. /**
  114674. * Sets the motors limit
  114675. * @param joint joint to set limit on
  114676. * @param upperLimit upper limit
  114677. * @param lowerLimit lower limit
  114678. */
  114679. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114680. /**
  114681. * Syncs the position and rotation of a mesh with the impostor
  114682. * @param mesh mesh to sync
  114683. * @param impostor impostor to update the mesh with
  114684. */
  114685. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114686. /**
  114687. * Gets the radius of the impostor
  114688. * @param impostor impostor to get radius from
  114689. * @returns the radius
  114690. */
  114691. getRadius(impostor: PhysicsImpostor): number;
  114692. /**
  114693. * Gets the box size of the impostor
  114694. * @param impostor impostor to get box size from
  114695. * @param result the resulting box size
  114696. */
  114697. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114698. /**
  114699. * Disposes of the impostor
  114700. */
  114701. dispose(): void;
  114702. /**
  114703. * Does a raycast in the physics world
  114704. * @param from when should the ray start?
  114705. * @param to when should the ray end?
  114706. * @returns PhysicsRaycastResult
  114707. */
  114708. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114709. }
  114710. }
  114711. declare module BABYLON {
  114712. interface AbstractScene {
  114713. /**
  114714. * The list of reflection probes added to the scene
  114715. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114716. */
  114717. reflectionProbes: Array<ReflectionProbe>;
  114718. /**
  114719. * Removes the given reflection probe from this scene.
  114720. * @param toRemove The reflection probe to remove
  114721. * @returns The index of the removed reflection probe
  114722. */
  114723. removeReflectionProbe(toRemove: ReflectionProbe): number;
  114724. /**
  114725. * Adds the given reflection probe to this scene.
  114726. * @param newReflectionProbe The reflection probe to add
  114727. */
  114728. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  114729. }
  114730. /**
  114731. * Class used to generate realtime reflection / refraction cube textures
  114732. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114733. */
  114734. export class ReflectionProbe {
  114735. /** defines the name of the probe */
  114736. name: string;
  114737. private _scene;
  114738. private _renderTargetTexture;
  114739. private _projectionMatrix;
  114740. private _viewMatrix;
  114741. private _target;
  114742. private _add;
  114743. private _attachedMesh;
  114744. private _invertYAxis;
  114745. /** Gets or sets probe position (center of the cube map) */
  114746. position: Vector3;
  114747. /**
  114748. * Creates a new reflection probe
  114749. * @param name defines the name of the probe
  114750. * @param size defines the texture resolution (for each face)
  114751. * @param scene defines the hosting scene
  114752. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  114753. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  114754. */
  114755. constructor(
  114756. /** defines the name of the probe */
  114757. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  114758. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  114759. samples: number;
  114760. /** Gets or sets the refresh rate to use (on every frame by default) */
  114761. refreshRate: number;
  114762. /**
  114763. * Gets the hosting scene
  114764. * @returns a Scene
  114765. */
  114766. getScene(): Scene;
  114767. /** Gets the internal CubeTexture used to render to */
  114768. readonly cubeTexture: RenderTargetTexture;
  114769. /** Gets the list of meshes to render */
  114770. readonly renderList: Nullable<AbstractMesh[]>;
  114771. /**
  114772. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114773. * @param mesh defines the mesh to attach to
  114774. */
  114775. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114776. /**
  114777. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114778. * @param renderingGroupId The rendering group id corresponding to its index
  114779. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114780. */
  114781. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114782. /**
  114783. * Clean all associated resources
  114784. */
  114785. dispose(): void;
  114786. /**
  114787. * Converts the reflection probe information to a readable string for debug purpose.
  114788. * @param fullDetails Supports for multiple levels of logging within scene loading
  114789. * @returns the human readable reflection probe info
  114790. */
  114791. toString(fullDetails?: boolean): string;
  114792. /**
  114793. * Get the class name of the relfection probe.
  114794. * @returns "ReflectionProbe"
  114795. */
  114796. getClassName(): string;
  114797. /**
  114798. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114799. * @returns The JSON representation of the texture
  114800. */
  114801. serialize(): any;
  114802. /**
  114803. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114804. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114805. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114806. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114807. * @returns The parsed reflection probe if successful
  114808. */
  114809. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114810. }
  114811. }
  114812. declare module BABYLON {
  114813. /** @hidden */
  114814. export var _BabylonLoaderRegistered: boolean;
  114815. }
  114816. declare module BABYLON {
  114817. /**
  114818. * The Physically based simple base material of BJS.
  114819. *
  114820. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114821. * It is used as the base class for both the specGloss and metalRough conventions.
  114822. */
  114823. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114824. /**
  114825. * Number of Simultaneous lights allowed on the material.
  114826. */
  114827. maxSimultaneousLights: number;
  114828. /**
  114829. * If sets to true, disables all the lights affecting the material.
  114830. */
  114831. disableLighting: boolean;
  114832. /**
  114833. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114834. */
  114835. environmentTexture: BaseTexture;
  114836. /**
  114837. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114838. */
  114839. invertNormalMapX: boolean;
  114840. /**
  114841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114842. */
  114843. invertNormalMapY: boolean;
  114844. /**
  114845. * Normal map used in the model.
  114846. */
  114847. normalTexture: BaseTexture;
  114848. /**
  114849. * Emissivie color used to self-illuminate the model.
  114850. */
  114851. emissiveColor: Color3;
  114852. /**
  114853. * Emissivie texture used to self-illuminate the model.
  114854. */
  114855. emissiveTexture: BaseTexture;
  114856. /**
  114857. * Occlusion Channel Strenght.
  114858. */
  114859. occlusionStrength: number;
  114860. /**
  114861. * Occlusion Texture of the material (adding extra occlusion effects).
  114862. */
  114863. occlusionTexture: BaseTexture;
  114864. /**
  114865. * Defines the alpha limits in alpha test mode.
  114866. */
  114867. alphaCutOff: number;
  114868. /**
  114869. * Gets the current double sided mode.
  114870. */
  114871. /**
  114872. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114873. */
  114874. doubleSided: boolean;
  114875. /**
  114876. * Stores the pre-calculated light information of a mesh in a texture.
  114877. */
  114878. lightmapTexture: BaseTexture;
  114879. /**
  114880. * If true, the light map contains occlusion information instead of lighting info.
  114881. */
  114882. useLightmapAsShadowmap: boolean;
  114883. /**
  114884. * Instantiates a new PBRMaterial instance.
  114885. *
  114886. * @param name The material name
  114887. * @param scene The scene the material will be use in.
  114888. */
  114889. constructor(name: string, scene: Scene);
  114890. getClassName(): string;
  114891. }
  114892. }
  114893. declare module BABYLON {
  114894. /**
  114895. * The PBR material of BJS following the metal roughness convention.
  114896. *
  114897. * This fits to the PBR convention in the GLTF definition:
  114898. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114899. */
  114900. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114901. /**
  114902. * The base color has two different interpretations depending on the value of metalness.
  114903. * When the material is a metal, the base color is the specific measured reflectance value
  114904. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114905. * of the material.
  114906. */
  114907. baseColor: Color3;
  114908. /**
  114909. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114910. * well as opacity information in the alpha channel.
  114911. */
  114912. baseTexture: BaseTexture;
  114913. /**
  114914. * Specifies the metallic scalar value of the material.
  114915. * Can also be used to scale the metalness values of the metallic texture.
  114916. */
  114917. metallic: number;
  114918. /**
  114919. * Specifies the roughness scalar value of the material.
  114920. * Can also be used to scale the roughness values of the metallic texture.
  114921. */
  114922. roughness: number;
  114923. /**
  114924. * Texture containing both the metallic value in the B channel and the
  114925. * roughness value in the G channel to keep better precision.
  114926. */
  114927. metallicRoughnessTexture: BaseTexture;
  114928. /**
  114929. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114930. *
  114931. * @param name The material name
  114932. * @param scene The scene the material will be use in.
  114933. */
  114934. constructor(name: string, scene: Scene);
  114935. /**
  114936. * Return the currrent class name of the material.
  114937. */
  114938. getClassName(): string;
  114939. /**
  114940. * Makes a duplicate of the current material.
  114941. * @param name - name to use for the new material.
  114942. */
  114943. clone(name: string): PBRMetallicRoughnessMaterial;
  114944. /**
  114945. * Serialize the material to a parsable JSON object.
  114946. */
  114947. serialize(): any;
  114948. /**
  114949. * Parses a JSON object correponding to the serialize function.
  114950. */
  114951. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114952. }
  114953. }
  114954. declare module BABYLON {
  114955. /**
  114956. * The PBR material of BJS following the specular glossiness convention.
  114957. *
  114958. * This fits to the PBR convention in the GLTF definition:
  114959. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114960. */
  114961. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114962. /**
  114963. * Specifies the diffuse color of the material.
  114964. */
  114965. diffuseColor: Color3;
  114966. /**
  114967. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114968. * channel.
  114969. */
  114970. diffuseTexture: BaseTexture;
  114971. /**
  114972. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114973. */
  114974. specularColor: Color3;
  114975. /**
  114976. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114977. */
  114978. glossiness: number;
  114979. /**
  114980. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114981. */
  114982. specularGlossinessTexture: BaseTexture;
  114983. /**
  114984. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114985. *
  114986. * @param name The material name
  114987. * @param scene The scene the material will be use in.
  114988. */
  114989. constructor(name: string, scene: Scene);
  114990. /**
  114991. * Return the currrent class name of the material.
  114992. */
  114993. getClassName(): string;
  114994. /**
  114995. * Makes a duplicate of the current material.
  114996. * @param name - name to use for the new material.
  114997. */
  114998. clone(name: string): PBRSpecularGlossinessMaterial;
  114999. /**
  115000. * Serialize the material to a parsable JSON object.
  115001. */
  115002. serialize(): any;
  115003. /**
  115004. * Parses a JSON object correponding to the serialize function.
  115005. */
  115006. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  115007. }
  115008. }
  115009. declare module BABYLON {
  115010. /**
  115011. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  115012. * It can help converting any input color in a desired output one. This can then be used to create effects
  115013. * from sepia, black and white to sixties or futuristic rendering...
  115014. *
  115015. * The only supported format is currently 3dl.
  115016. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  115017. */
  115018. export class ColorGradingTexture extends BaseTexture {
  115019. /**
  115020. * The current texture matrix. (will always be identity in color grading texture)
  115021. */
  115022. private _textureMatrix;
  115023. /**
  115024. * The texture URL.
  115025. */
  115026. url: string;
  115027. /**
  115028. * Empty line regex stored for GC.
  115029. */
  115030. private static _noneEmptyLineRegex;
  115031. private _engine;
  115032. /**
  115033. * Instantiates a ColorGradingTexture from the following parameters.
  115034. *
  115035. * @param url The location of the color gradind data (currently only supporting 3dl)
  115036. * @param scene The scene the texture will be used in
  115037. */
  115038. constructor(url: string, scene: Scene);
  115039. /**
  115040. * Returns the texture matrix used in most of the material.
  115041. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  115042. */
  115043. getTextureMatrix(): Matrix;
  115044. /**
  115045. * Occurs when the file being loaded is a .3dl LUT file.
  115046. */
  115047. private load3dlTexture;
  115048. /**
  115049. * Starts the loading process of the texture.
  115050. */
  115051. private loadTexture;
  115052. /**
  115053. * Clones the color gradind texture.
  115054. */
  115055. clone(): ColorGradingTexture;
  115056. /**
  115057. * Called during delayed load for textures.
  115058. */
  115059. delayLoad(): void;
  115060. /**
  115061. * Parses a color grading texture serialized by Babylon.
  115062. * @param parsedTexture The texture information being parsedTexture
  115063. * @param scene The scene to load the texture in
  115064. * @param rootUrl The root url of the data assets to load
  115065. * @return A color gradind texture
  115066. */
  115067. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  115068. /**
  115069. * Serializes the LUT texture to json format.
  115070. */
  115071. serialize(): any;
  115072. }
  115073. }
  115074. declare module BABYLON {
  115075. /**
  115076. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  115077. */
  115078. export class EquiRectangularCubeTexture extends BaseTexture {
  115079. /** The six faces of the cube. */
  115080. private static _FacesMapping;
  115081. private _noMipmap;
  115082. private _onLoad;
  115083. private _onError;
  115084. /** The size of the cubemap. */
  115085. private _size;
  115086. /** The buffer of the image. */
  115087. private _buffer;
  115088. /** The width of the input image. */
  115089. private _width;
  115090. /** The height of the input image. */
  115091. private _height;
  115092. /** The URL to the image. */
  115093. url: string;
  115094. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  115095. coordinatesMode: number;
  115096. /**
  115097. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  115098. * @param url The location of the image
  115099. * @param scene The scene the texture will be used in
  115100. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  115101. * @param noMipmap Forces to not generate the mipmap if true
  115102. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115103. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115104. * @param onLoad — defines a callback called when texture is loaded
  115105. * @param onError — defines a callback called if there is an error
  115106. */
  115107. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  115108. /**
  115109. * Load the image data, by putting the image on a canvas and extracting its buffer.
  115110. */
  115111. private loadImage;
  115112. /**
  115113. * Convert the image buffer into a cubemap and create a CubeTexture.
  115114. */
  115115. private loadTexture;
  115116. /**
  115117. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  115118. * @param buffer The ArrayBuffer that should be converted.
  115119. * @returns The buffer as Float32Array.
  115120. */
  115121. private getFloat32ArrayFromArrayBuffer;
  115122. /**
  115123. * Get the current class name of the texture useful for serialization or dynamic coding.
  115124. * @returns "EquiRectangularCubeTexture"
  115125. */
  115126. getClassName(): string;
  115127. /**
  115128. * Create a clone of the current EquiRectangularCubeTexture and return it.
  115129. * @returns A clone of the current EquiRectangularCubeTexture.
  115130. */
  115131. clone(): EquiRectangularCubeTexture;
  115132. }
  115133. }
  115134. declare module BABYLON {
  115135. /**
  115136. * Based on jsTGALoader - Javascript loader for TGA file
  115137. * By Vincent Thibault
  115138. * @see http://blog.robrowser.com/javascript-tga-loader.html
  115139. */
  115140. export class TGATools {
  115141. private static _TYPE_INDEXED;
  115142. private static _TYPE_RGB;
  115143. private static _TYPE_GREY;
  115144. private static _TYPE_RLE_INDEXED;
  115145. private static _TYPE_RLE_RGB;
  115146. private static _TYPE_RLE_GREY;
  115147. private static _ORIGIN_MASK;
  115148. private static _ORIGIN_SHIFT;
  115149. private static _ORIGIN_BL;
  115150. private static _ORIGIN_BR;
  115151. private static _ORIGIN_UL;
  115152. private static _ORIGIN_UR;
  115153. /**
  115154. * Gets the header of a TGA file
  115155. * @param data defines the TGA data
  115156. * @returns the header
  115157. */
  115158. static GetTGAHeader(data: Uint8Array): any;
  115159. /**
  115160. * Uploads TGA content to a Babylon Texture
  115161. * @hidden
  115162. */
  115163. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  115164. /** @hidden */
  115165. 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;
  115166. /** @hidden */
  115167. 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;
  115168. /** @hidden */
  115169. 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;
  115170. /** @hidden */
  115171. 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;
  115172. /** @hidden */
  115173. 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;
  115174. /** @hidden */
  115175. 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;
  115176. }
  115177. }
  115178. declare module BABYLON {
  115179. /**
  115180. * Implementation of the TGA Texture Loader.
  115181. * @hidden
  115182. */
  115183. export class _TGATextureLoader implements IInternalTextureLoader {
  115184. /**
  115185. * Defines wether the loader supports cascade loading the different faces.
  115186. */
  115187. readonly supportCascades: boolean;
  115188. /**
  115189. * This returns if the loader support the current file information.
  115190. * @param extension defines the file extension of the file being loaded
  115191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115192. * @param fallback defines the fallback internal texture if any
  115193. * @param isBase64 defines whether the texture is encoded as a base64
  115194. * @param isBuffer defines whether the texture data are stored as a buffer
  115195. * @returns true if the loader can load the specified file
  115196. */
  115197. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115198. /**
  115199. * Transform the url before loading if required.
  115200. * @param rootUrl the url of the texture
  115201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115202. * @returns the transformed texture
  115203. */
  115204. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115205. /**
  115206. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115207. * @param rootUrl the url of the texture
  115208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115209. * @returns the fallback texture
  115210. */
  115211. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115212. /**
  115213. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115214. * @param data contains the texture data
  115215. * @param texture defines the BabylonJS internal texture
  115216. * @param createPolynomials will be true if polynomials have been requested
  115217. * @param onLoad defines the callback to trigger once the texture is ready
  115218. * @param onError defines the callback to trigger in case of error
  115219. */
  115220. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115221. /**
  115222. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115223. * @param data contains the texture data
  115224. * @param texture defines the BabylonJS internal texture
  115225. * @param callback defines the method to call once ready to upload
  115226. */
  115227. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115228. }
  115229. }
  115230. declare module BABYLON {
  115231. /**
  115232. * Info about the .basis files
  115233. */
  115234. class BasisFileInfo {
  115235. /**
  115236. * If the file has alpha
  115237. */
  115238. hasAlpha: boolean;
  115239. /**
  115240. * Info about each image of the basis file
  115241. */
  115242. images: Array<{
  115243. levels: Array<{
  115244. width: number;
  115245. height: number;
  115246. transcodedPixels: ArrayBufferView;
  115247. }>;
  115248. }>;
  115249. }
  115250. /**
  115251. * Result of transcoding a basis file
  115252. */
  115253. class TranscodeResult {
  115254. /**
  115255. * Info about the .basis file
  115256. */
  115257. fileInfo: BasisFileInfo;
  115258. /**
  115259. * Format to use when loading the file
  115260. */
  115261. format: number;
  115262. }
  115263. /**
  115264. * Configuration options for the Basis transcoder
  115265. */
  115266. export class BasisTranscodeConfiguration {
  115267. /**
  115268. * Supported compression formats used to determine the supported output format of the transcoder
  115269. */
  115270. supportedCompressionFormats?: {
  115271. /**
  115272. * etc1 compression format
  115273. */
  115274. etc1?: boolean;
  115275. /**
  115276. * s3tc compression format
  115277. */
  115278. s3tc?: boolean;
  115279. /**
  115280. * pvrtc compression format
  115281. */
  115282. pvrtc?: boolean;
  115283. /**
  115284. * etc2 compression format
  115285. */
  115286. etc2?: boolean;
  115287. };
  115288. /**
  115289. * If mipmap levels should be loaded for transcoded images (Default: true)
  115290. */
  115291. loadMipmapLevels?: boolean;
  115292. /**
  115293. * Index of a single image to load (Default: all images)
  115294. */
  115295. loadSingleImage?: number;
  115296. }
  115297. /**
  115298. * Used to load .Basis files
  115299. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  115300. */
  115301. export class BasisTools {
  115302. private static _IgnoreSupportedFormats;
  115303. /**
  115304. * URL to use when loading the basis transcoder
  115305. */
  115306. static JSModuleURL: string;
  115307. /**
  115308. * URL to use when loading the wasm module for the transcoder
  115309. */
  115310. static WasmModuleURL: string;
  115311. /**
  115312. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  115313. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  115314. * @returns internal format corresponding to the Basis format
  115315. */
  115316. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  115317. private static _WorkerPromise;
  115318. private static _Worker;
  115319. private static _actionId;
  115320. private static _CreateWorkerAsync;
  115321. /**
  115322. * Transcodes a loaded image file to compressed pixel data
  115323. * @param imageData image data to transcode
  115324. * @param config configuration options for the transcoding
  115325. * @returns a promise resulting in the transcoded image
  115326. */
  115327. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  115328. /**
  115329. * Loads a texture from the transcode result
  115330. * @param texture texture load to
  115331. * @param transcodeResult the result of transcoding the basis file to load from
  115332. */
  115333. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  115334. }
  115335. }
  115336. declare module BABYLON {
  115337. /**
  115338. * Loader for .basis file format
  115339. */
  115340. export class _BasisTextureLoader implements IInternalTextureLoader {
  115341. /**
  115342. * Defines whether the loader supports cascade loading the different faces.
  115343. */
  115344. readonly supportCascades: boolean;
  115345. /**
  115346. * This returns if the loader support the current file information.
  115347. * @param extension defines the file extension of the file being loaded
  115348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115349. * @param fallback defines the fallback internal texture if any
  115350. * @param isBase64 defines whether the texture is encoded as a base64
  115351. * @param isBuffer defines whether the texture data are stored as a buffer
  115352. * @returns true if the loader can load the specified file
  115353. */
  115354. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115355. /**
  115356. * Transform the url before loading if required.
  115357. * @param rootUrl the url of the texture
  115358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115359. * @returns the transformed texture
  115360. */
  115361. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115362. /**
  115363. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115364. * @param rootUrl the url of the texture
  115365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115366. * @returns the fallback texture
  115367. */
  115368. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115369. /**
  115370. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  115371. * @param data contains the texture data
  115372. * @param texture defines the BabylonJS internal texture
  115373. * @param createPolynomials will be true if polynomials have been requested
  115374. * @param onLoad defines the callback to trigger once the texture is ready
  115375. * @param onError defines the callback to trigger in case of error
  115376. */
  115377. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115378. /**
  115379. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115380. * @param data contains the texture data
  115381. * @param texture defines the BabylonJS internal texture
  115382. * @param callback defines the method to call once ready to upload
  115383. */
  115384. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115385. }
  115386. }
  115387. declare module BABYLON {
  115388. /**
  115389. * 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.
  115390. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115391. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115392. */
  115393. export class CustomProceduralTexture extends ProceduralTexture {
  115394. private _animate;
  115395. private _time;
  115396. private _config;
  115397. private _texturePath;
  115398. /**
  115399. * Instantiates a new Custom Procedural Texture.
  115400. * 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.
  115401. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  115402. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  115403. * @param name Define the name of the texture
  115404. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  115405. * @param size Define the size of the texture to create
  115406. * @param scene Define the scene the texture belongs to
  115407. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  115408. * @param generateMipMaps Define if the texture should creates mip maps or not
  115409. */
  115410. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115411. private _loadJson;
  115412. /**
  115413. * Is the texture ready to be used ? (rendered at least once)
  115414. * @returns true if ready, otherwise, false.
  115415. */
  115416. isReady(): boolean;
  115417. /**
  115418. * Render the texture to its associated render target.
  115419. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  115420. */
  115421. render(useCameraPostProcess?: boolean): void;
  115422. /**
  115423. * Update the list of dependant textures samplers in the shader.
  115424. */
  115425. updateTextures(): void;
  115426. /**
  115427. * Update the uniform values of the procedural texture in the shader.
  115428. */
  115429. updateShaderUniforms(): void;
  115430. /**
  115431. * Define if the texture animates or not.
  115432. */
  115433. animate: boolean;
  115434. }
  115435. }
  115436. declare module BABYLON {
  115437. /** @hidden */
  115438. export var noisePixelShader: {
  115439. name: string;
  115440. shader: string;
  115441. };
  115442. }
  115443. declare module BABYLON {
  115444. /**
  115445. * Class used to generate noise procedural textures
  115446. */
  115447. export class NoiseProceduralTexture extends ProceduralTexture {
  115448. private _time;
  115449. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  115450. brightness: number;
  115451. /** Defines the number of octaves to process */
  115452. octaves: number;
  115453. /** Defines the level of persistence (0.8 by default) */
  115454. persistence: number;
  115455. /** Gets or sets animation speed factor (default is 1) */
  115456. animationSpeedFactor: number;
  115457. /**
  115458. * Creates a new NoiseProceduralTexture
  115459. * @param name defines the name fo the texture
  115460. * @param size defines the size of the texture (default is 256)
  115461. * @param scene defines the hosting scene
  115462. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  115463. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  115464. */
  115465. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  115466. private _updateShaderUniforms;
  115467. protected _getDefines(): string;
  115468. /** Generate the current state of the procedural texture */
  115469. render(useCameraPostProcess?: boolean): void;
  115470. /**
  115471. * Serializes this noise procedural texture
  115472. * @returns a serialized noise procedural texture object
  115473. */
  115474. serialize(): any;
  115475. /**
  115476. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  115477. * @param parsedTexture defines parsed texture data
  115478. * @param scene defines the current scene
  115479. * @param rootUrl defines the root URL containing noise procedural texture information
  115480. * @returns a parsed NoiseProceduralTexture
  115481. */
  115482. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  115483. }
  115484. }
  115485. declare module BABYLON {
  115486. /**
  115487. * Raw cube texture where the raw buffers are passed in
  115488. */
  115489. export class RawCubeTexture extends CubeTexture {
  115490. /**
  115491. * Creates a cube texture where the raw buffers are passed in.
  115492. * @param scene defines the scene the texture is attached to
  115493. * @param data defines the array of data to use to create each face
  115494. * @param size defines the size of the textures
  115495. * @param format defines the format of the data
  115496. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  115497. * @param generateMipMaps defines if the engine should generate the mip levels
  115498. * @param invertY defines if data must be stored with Y axis inverted
  115499. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  115500. * @param compression defines the compression used (null by default)
  115501. */
  115502. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  115503. /**
  115504. * Updates the raw cube texture.
  115505. * @param data defines the data to store
  115506. * @param format defines the data format
  115507. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  115508. * @param invertY defines if data must be stored with Y axis inverted
  115509. * @param compression defines the compression used (null by default)
  115510. * @param level defines which level of the texture to update
  115511. */
  115512. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  115513. /**
  115514. * Updates a raw cube texture with RGBD encoded data.
  115515. * @param data defines the array of data [mipmap][face] to use to create each face
  115516. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  115517. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  115518. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  115519. * @returns a promsie that resolves when the operation is complete
  115520. */
  115521. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  115522. /**
  115523. * Clones the raw cube texture.
  115524. * @return a new cube texture
  115525. */
  115526. clone(): CubeTexture;
  115527. /** @hidden */
  115528. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  115529. }
  115530. }
  115531. declare module BABYLON {
  115532. /**
  115533. * Class used to store 3D textures containing user data
  115534. */
  115535. export class RawTexture3D extends Texture {
  115536. /** Gets or sets the texture format to use */
  115537. format: number;
  115538. private _engine;
  115539. /**
  115540. * Create a new RawTexture3D
  115541. * @param data defines the data of the texture
  115542. * @param width defines the width of the texture
  115543. * @param height defines the height of the texture
  115544. * @param depth defines the depth of the texture
  115545. * @param format defines the texture format to use
  115546. * @param scene defines the hosting scene
  115547. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  115548. * @param invertY defines if texture must be stored with Y axis inverted
  115549. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  115550. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  115551. */
  115552. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  115553. /** Gets or sets the texture format to use */
  115554. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  115555. /**
  115556. * Update the texture with new data
  115557. * @param data defines the data to store in the texture
  115558. */
  115559. update(data: ArrayBufferView): void;
  115560. }
  115561. }
  115562. declare module BABYLON {
  115563. /**
  115564. * Creates a refraction texture used by refraction channel of the standard material.
  115565. * It is like a mirror but to see through a material.
  115566. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115567. */
  115568. export class RefractionTexture extends RenderTargetTexture {
  115569. /**
  115570. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  115571. * 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.
  115572. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115573. */
  115574. refractionPlane: Plane;
  115575. /**
  115576. * Define how deep under the surface we should see.
  115577. */
  115578. depth: number;
  115579. /**
  115580. * Creates a refraction texture used by refraction channel of the standard material.
  115581. * It is like a mirror but to see through a material.
  115582. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  115583. * @param name Define the texture name
  115584. * @param size Define the size of the underlying texture
  115585. * @param scene Define the scene the refraction belongs to
  115586. * @param generateMipMaps Define if we need to generate mips level for the refraction
  115587. */
  115588. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  115589. /**
  115590. * Clone the refraction texture.
  115591. * @returns the cloned texture
  115592. */
  115593. clone(): RefractionTexture;
  115594. /**
  115595. * Serialize the texture to a JSON representation you could use in Parse later on
  115596. * @returns the serialized JSON representation
  115597. */
  115598. serialize(): any;
  115599. }
  115600. }
  115601. declare module BABYLON {
  115602. /**
  115603. * Defines the options related to the creation of an HtmlElementTexture
  115604. */
  115605. export interface IHtmlElementTextureOptions {
  115606. /**
  115607. * Defines wether mip maps should be created or not.
  115608. */
  115609. generateMipMaps?: boolean;
  115610. /**
  115611. * Defines the sampling mode of the texture.
  115612. */
  115613. samplingMode?: number;
  115614. /**
  115615. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  115616. */
  115617. engine: Nullable<Engine>;
  115618. /**
  115619. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  115620. */
  115621. scene: Nullable<Scene>;
  115622. }
  115623. /**
  115624. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  115625. * To be as efficient as possible depending on your constraints nothing aside the first upload
  115626. * is automatically managed.
  115627. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  115628. * in your application.
  115629. *
  115630. * As the update is not automatic, you need to call them manually.
  115631. */
  115632. export class HtmlElementTexture extends BaseTexture {
  115633. /**
  115634. * The texture URL.
  115635. */
  115636. element: HTMLVideoElement | HTMLCanvasElement;
  115637. private static readonly DefaultOptions;
  115638. private _textureMatrix;
  115639. private _engine;
  115640. private _isVideo;
  115641. private _generateMipMaps;
  115642. private _samplingMode;
  115643. /**
  115644. * Instantiates a HtmlElementTexture from the following parameters.
  115645. *
  115646. * @param name Defines the name of the texture
  115647. * @param element Defines the video or canvas the texture is filled with
  115648. * @param options Defines the other none mandatory texture creation options
  115649. */
  115650. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  115651. private _createInternalTexture;
  115652. /**
  115653. * Returns the texture matrix used in most of the material.
  115654. */
  115655. getTextureMatrix(): Matrix;
  115656. /**
  115657. * Updates the content of the texture.
  115658. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  115659. */
  115660. update(invertY?: Nullable<boolean>): void;
  115661. }
  115662. }
  115663. declare module BABYLON {
  115664. /**
  115665. * Enum used to define the target of a block
  115666. */
  115667. export enum NodeMaterialBlockTargets {
  115668. /** Vertex shader */
  115669. Vertex = 1,
  115670. /** Fragment shader */
  115671. Fragment = 2,
  115672. /** Neutral */
  115673. Neutral = 4,
  115674. /** Vertex and Fragment */
  115675. VertexAndFragment = 3
  115676. }
  115677. }
  115678. declare module BABYLON {
  115679. /**
  115680. * Defines the kind of connection point for node based material
  115681. */
  115682. export enum NodeMaterialBlockConnectionPointTypes {
  115683. /** Float */
  115684. Float = 1,
  115685. /** Int */
  115686. Int = 2,
  115687. /** Vector2 */
  115688. Vector2 = 4,
  115689. /** Vector3 */
  115690. Vector3 = 8,
  115691. /** Vector4 */
  115692. Vector4 = 16,
  115693. /** Color3 */
  115694. Color3 = 32,
  115695. /** Color4 */
  115696. Color4 = 64,
  115697. /** Matrix */
  115698. Matrix = 128,
  115699. /** Detect type based on connection */
  115700. AutoDetect = 1024,
  115701. /** Output type that will be defined by input type */
  115702. BasedOnInput = 2048
  115703. }
  115704. }
  115705. declare module BABYLON {
  115706. /**
  115707. * Root class for all node material optimizers
  115708. */
  115709. export class NodeMaterialOptimizer {
  115710. /**
  115711. * Function used to optimize a NodeMaterial graph
  115712. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  115713. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  115714. */
  115715. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  115716. }
  115717. }
  115718. declare module BABYLON {
  115719. /**
  115720. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115721. */
  115722. export class TransformBlock extends NodeMaterialBlock {
  115723. /**
  115724. * Defines the value to use to complement W value to transform it to a Vector4
  115725. */
  115726. complementW: number;
  115727. /**
  115728. * Defines the value to use to complement z value to transform it to a Vector4
  115729. */
  115730. complementZ: number;
  115731. /**
  115732. * Creates a new TransformBlock
  115733. * @param name defines the block name
  115734. */
  115735. constructor(name: string);
  115736. /**
  115737. * Gets the current class name
  115738. * @returns the class name
  115739. */
  115740. getClassName(): string;
  115741. /**
  115742. * Gets the vector input
  115743. */
  115744. readonly vector: NodeMaterialConnectionPoint;
  115745. /**
  115746. * Gets the output component
  115747. */
  115748. readonly output: NodeMaterialConnectionPoint;
  115749. /**
  115750. * Gets the matrix transform input
  115751. */
  115752. readonly transform: NodeMaterialConnectionPoint;
  115753. protected _buildBlock(state: NodeMaterialBuildState): this;
  115754. serialize(): any;
  115755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115756. }
  115757. }
  115758. declare module BABYLON {
  115759. /**
  115760. * Block used to output the vertex position
  115761. */
  115762. export class VertexOutputBlock extends NodeMaterialBlock {
  115763. /**
  115764. * Creates a new VertexOutputBlock
  115765. * @param name defines the block name
  115766. */
  115767. constructor(name: string);
  115768. /**
  115769. * Gets the current class name
  115770. * @returns the class name
  115771. */
  115772. getClassName(): string;
  115773. /**
  115774. * Gets the vector input component
  115775. */
  115776. readonly vector: NodeMaterialConnectionPoint;
  115777. protected _buildBlock(state: NodeMaterialBuildState): this;
  115778. }
  115779. }
  115780. declare module BABYLON {
  115781. /**
  115782. * Block used to output the final color
  115783. */
  115784. export class FragmentOutputBlock extends NodeMaterialBlock {
  115785. /**
  115786. * Create a new FragmentOutputBlock
  115787. * @param name defines the block name
  115788. */
  115789. constructor(name: string);
  115790. /**
  115791. * Gets the current class name
  115792. * @returns the class name
  115793. */
  115794. getClassName(): string;
  115795. /**
  115796. * Gets the rgba input component
  115797. */
  115798. readonly rgba: NodeMaterialConnectionPoint;
  115799. /**
  115800. * Gets the rgb input component
  115801. */
  115802. readonly rgb: NodeMaterialConnectionPoint;
  115803. /**
  115804. * Gets the a input component
  115805. */
  115806. readonly a: NodeMaterialConnectionPoint;
  115807. protected _buildBlock(state: NodeMaterialBuildState): this;
  115808. }
  115809. }
  115810. declare module BABYLON {
  115811. /**
  115812. * Interface used to configure the node material editor
  115813. */
  115814. export interface INodeMaterialEditorOptions {
  115815. /** Define the URl to load node editor script */
  115816. editorURL?: string;
  115817. }
  115818. /** @hidden */
  115819. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115820. /** BONES */
  115821. NUM_BONE_INFLUENCERS: number;
  115822. BonesPerMesh: number;
  115823. BONETEXTURE: boolean;
  115824. /** MORPH TARGETS */
  115825. MORPHTARGETS: boolean;
  115826. MORPHTARGETS_NORMAL: boolean;
  115827. MORPHTARGETS_TANGENT: boolean;
  115828. MORPHTARGETS_UV: boolean;
  115829. NUM_MORPH_INFLUENCERS: number;
  115830. /** IMAGE PROCESSING */
  115831. IMAGEPROCESSING: boolean;
  115832. VIGNETTE: boolean;
  115833. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115834. VIGNETTEBLENDMODEOPAQUE: boolean;
  115835. TONEMAPPING: boolean;
  115836. TONEMAPPING_ACES: boolean;
  115837. CONTRAST: boolean;
  115838. EXPOSURE: boolean;
  115839. COLORCURVES: boolean;
  115840. COLORGRADING: boolean;
  115841. COLORGRADING3D: boolean;
  115842. SAMPLER3DGREENDEPTH: boolean;
  115843. SAMPLER3DBGRMAP: boolean;
  115844. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115845. constructor();
  115846. setValue(name: string, value: boolean): void;
  115847. }
  115848. /**
  115849. * Class used to configure NodeMaterial
  115850. */
  115851. export interface INodeMaterialOptions {
  115852. /**
  115853. * Defines if blocks should emit comments
  115854. */
  115855. emitComments: boolean;
  115856. }
  115857. /**
  115858. * Class used to create a node based material built by assembling shader blocks
  115859. */
  115860. export class NodeMaterial extends PushMaterial {
  115861. private static _BuildIdGenerator;
  115862. private _options;
  115863. private _vertexCompilationState;
  115864. private _fragmentCompilationState;
  115865. private _sharedData;
  115866. private _buildId;
  115867. private _buildWasSuccessful;
  115868. private _cachedWorldViewMatrix;
  115869. private _cachedWorldViewProjectionMatrix;
  115870. private _optimizers;
  115871. /** Define the URl to load node editor script */
  115872. static EditorURL: string;
  115873. private BJSNODEMATERIALEDITOR;
  115874. /** Get the inspector from bundle or global */
  115875. private _getGlobalNodeMaterialEditor;
  115876. /**
  115877. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  115878. */
  115879. ignoreAlpha: boolean;
  115880. /**
  115881. * Defines the maximum number of lights that can be used in the material
  115882. */
  115883. maxSimultaneousLights: number;
  115884. /**
  115885. * Observable raised when the material is built
  115886. */
  115887. onBuildObservable: Observable<NodeMaterial>;
  115888. /**
  115889. * Gets or sets the root nodes of the material vertex shader
  115890. */
  115891. _vertexOutputNodes: NodeMaterialBlock[];
  115892. /**
  115893. * Gets or sets the root nodes of the material fragment (pixel) shader
  115894. */
  115895. _fragmentOutputNodes: NodeMaterialBlock[];
  115896. /** Gets or sets options to control the node material overall behavior */
  115897. options: INodeMaterialOptions;
  115898. /**
  115899. * Default configuration related to image processing available in the standard Material.
  115900. */
  115901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115902. /**
  115903. * Gets the image processing configuration used either in this material.
  115904. */
  115905. /**
  115906. * Sets the Default image processing configuration used either in the this material.
  115907. *
  115908. * If sets to null, the scene one is in use.
  115909. */
  115910. imageProcessingConfiguration: ImageProcessingConfiguration;
  115911. /**
  115912. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  115913. */
  115914. attachedBlocks: NodeMaterialBlock[];
  115915. /**
  115916. * Create a new node based material
  115917. * @param name defines the material name
  115918. * @param scene defines the hosting scene
  115919. * @param options defines creation option
  115920. */
  115921. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115922. /**
  115923. * Gets the current class name of the material e.g. "NodeMaterial"
  115924. * @returns the class name
  115925. */
  115926. getClassName(): string;
  115927. /**
  115928. * Keep track of the image processing observer to allow dispose and replace.
  115929. */
  115930. private _imageProcessingObserver;
  115931. /**
  115932. * Attaches a new image processing configuration to the Standard Material.
  115933. * @param configuration
  115934. */
  115935. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115936. /**
  115937. * Adds a new optimizer to the list of optimizers
  115938. * @param optimizer defines the optimizers to add
  115939. * @returns the current material
  115940. */
  115941. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115942. /**
  115943. * Remove an optimizer from the list of optimizers
  115944. * @param optimizer defines the optimizers to remove
  115945. * @returns the current material
  115946. */
  115947. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115948. /**
  115949. * Add a new block to the list of output nodes
  115950. * @param node defines the node to add
  115951. * @returns the current material
  115952. */
  115953. addOutputNode(node: NodeMaterialBlock): this;
  115954. /**
  115955. * Remove a block from the list of root nodes
  115956. * @param node defines the node to remove
  115957. * @returns the current material
  115958. */
  115959. removeOutputNode(node: NodeMaterialBlock): this;
  115960. private _addVertexOutputNode;
  115961. private _removeVertexOutputNode;
  115962. private _addFragmentOutputNode;
  115963. private _removeFragmentOutputNode;
  115964. /**
  115965. * Specifies if the material will require alpha blending
  115966. * @returns a boolean specifying if alpha blending is needed
  115967. */
  115968. needAlphaBlending(): boolean;
  115969. /**
  115970. * Specifies if this material should be rendered in alpha test mode
  115971. * @returns a boolean specifying if an alpha test is needed.
  115972. */
  115973. needAlphaTesting(): boolean;
  115974. private _initializeBlock;
  115975. private _resetDualBlocks;
  115976. /**
  115977. * Build the material and generates the inner effect
  115978. * @param verbose defines if the build should log activity
  115979. */
  115980. build(verbose?: boolean): void;
  115981. /**
  115982. * Runs an otpimization phase to try to improve the shader code
  115983. */
  115984. optimize(): void;
  115985. private _prepareDefinesForAttributes;
  115986. /**
  115987. * Get if the submesh is ready to be used and all its information available.
  115988. * Child classes can use it to update shaders
  115989. * @param mesh defines the mesh to check
  115990. * @param subMesh defines which submesh to check
  115991. * @param useInstances specifies that instances should be used
  115992. * @returns a boolean indicating that the submesh is ready or not
  115993. */
  115994. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115995. /**
  115996. * Get a string representing the shaders built by the current node graph
  115997. */
  115998. readonly compiledShaders: string;
  115999. /**
  116000. * Binds the world matrix to the material
  116001. * @param world defines the world transformation matrix
  116002. */
  116003. bindOnlyWorldMatrix(world: Matrix): void;
  116004. /**
  116005. * Binds the submesh to this material by preparing the effect and shader to draw
  116006. * @param world defines the world transformation matrix
  116007. * @param mesh defines the mesh containing the submesh
  116008. * @param subMesh defines the submesh to bind the material to
  116009. */
  116010. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  116011. /**
  116012. * Gets the active textures from the material
  116013. * @returns an array of textures
  116014. */
  116015. getActiveTextures(): BaseTexture[];
  116016. /**
  116017. * Specifies if the material uses a texture
  116018. * @param texture defines the texture to check against the material
  116019. * @returns a boolean specifying if the material uses the texture
  116020. */
  116021. hasTexture(texture: BaseTexture): boolean;
  116022. /**
  116023. * Disposes the material
  116024. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  116025. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  116026. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  116027. */
  116028. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  116029. /** Creates the node editor window. */
  116030. private _createNodeEditor;
  116031. /**
  116032. * Launch the node material editor
  116033. * @param config Define the configuration of the editor
  116034. * @return a promise fulfilled when the node editor is visible
  116035. */
  116036. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  116037. /**
  116038. * Clear the current material
  116039. */
  116040. clear(): void;
  116041. /**
  116042. * Clear the current material and set it to a default state
  116043. */
  116044. setToDefault(): void;
  116045. private _gatherBlocks;
  116046. /**
  116047. * Serializes this material in a JSON representation
  116048. * @returns the serialized material object
  116049. */
  116050. serialize(): any;
  116051. /**
  116052. * Clear the current graph and load a new one from a serialization object
  116053. * @param source defines the JSON representation of the material
  116054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116055. */
  116056. loadFromSerialization(source: any, rootUrl?: string): void;
  116057. /**
  116058. * Creates a node material from parsed material data
  116059. * @param source defines the JSON representation of the material
  116060. * @param scene defines the hosting scene
  116061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  116062. * @returns a new node material
  116063. */
  116064. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  116065. }
  116066. }
  116067. declare module BABYLON {
  116068. /**
  116069. * Block used to read a texture from a sampler
  116070. */
  116071. export class TextureBlock extends NodeMaterialBlock {
  116072. private _defineName;
  116073. private _samplerName;
  116074. private _transformedUVName;
  116075. private _textureTransformName;
  116076. private _textureInfoName;
  116077. private _mainUVName;
  116078. private _mainUVDefineName;
  116079. /**
  116080. * Gets or sets the texture associated with the node
  116081. */
  116082. texture: Nullable<BaseTexture>;
  116083. /**
  116084. * Create a new TextureBlock
  116085. * @param name defines the block name
  116086. */
  116087. constructor(name: string);
  116088. /**
  116089. * Gets the current class name
  116090. * @returns the class name
  116091. */
  116092. getClassName(): string;
  116093. /**
  116094. * Gets the uv input component
  116095. */
  116096. readonly uv: NodeMaterialConnectionPoint;
  116097. /**
  116098. * Gets the output component
  116099. */
  116100. readonly output: NodeMaterialConnectionPoint;
  116101. autoConfigure(): void;
  116102. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116104. isReady(): boolean;
  116105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116106. private _injectVertexCode;
  116107. private _writeOutput;
  116108. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116109. serialize(): any;
  116110. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116111. }
  116112. }
  116113. declare module BABYLON {
  116114. /**
  116115. * Class used to store shared data between 2 NodeMaterialBuildState
  116116. */
  116117. export class NodeMaterialBuildStateSharedData {
  116118. /**
  116119. * Gets the list of emitted varyings
  116120. */
  116121. varyings: string[];
  116122. /**
  116123. * Gets the varying declaration string
  116124. */
  116125. varyingDeclaration: string;
  116126. /**
  116127. * Input blocks
  116128. */
  116129. inputBlocks: InputBlock[];
  116130. /**
  116131. * Input blocks
  116132. */
  116133. textureBlocks: TextureBlock[];
  116134. /**
  116135. * Bindable blocks (Blocks that need to set data to the effect)
  116136. */
  116137. bindableBlocks: NodeMaterialBlock[];
  116138. /**
  116139. * List of blocks that can provide a compilation fallback
  116140. */
  116141. blocksWithFallbacks: NodeMaterialBlock[];
  116142. /**
  116143. * List of blocks that can provide a define update
  116144. */
  116145. blocksWithDefines: NodeMaterialBlock[];
  116146. /**
  116147. * List of blocks that can provide a repeatable content
  116148. */
  116149. repeatableContentBlocks: NodeMaterialBlock[];
  116150. /**
  116151. * List of blocks that can provide a dynamic list of uniforms
  116152. */
  116153. dynamicUniformBlocks: NodeMaterialBlock[];
  116154. /**
  116155. * List of blocks that can block the isReady function for the material
  116156. */
  116157. blockingBlocks: NodeMaterialBlock[];
  116158. /**
  116159. * Build Id used to avoid multiple recompilations
  116160. */
  116161. buildId: number;
  116162. /** List of emitted variables */
  116163. variableNames: {
  116164. [key: string]: number;
  116165. };
  116166. /** List of emitted defines */
  116167. defineNames: {
  116168. [key: string]: number;
  116169. };
  116170. /** Should emit comments? */
  116171. emitComments: boolean;
  116172. /** Emit build activity */
  116173. verbose: boolean;
  116174. /**
  116175. * Gets the compilation hints emitted at compilation time
  116176. */
  116177. hints: {
  116178. needWorldViewMatrix: boolean;
  116179. needWorldViewProjectionMatrix: boolean;
  116180. needAlphaBlending: boolean;
  116181. needAlphaTesting: boolean;
  116182. };
  116183. /**
  116184. * List of compilation checks
  116185. */
  116186. checks: {
  116187. emitVertex: boolean;
  116188. emitFragment: boolean;
  116189. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  116190. };
  116191. /** Creates a new shared data */
  116192. constructor();
  116193. /**
  116194. * Emits console errors and exceptions if there is a failing check
  116195. */
  116196. emitErrors(): void;
  116197. }
  116198. }
  116199. declare module BABYLON {
  116200. /**
  116201. * Class used to store node based material build state
  116202. */
  116203. export class NodeMaterialBuildState {
  116204. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  116205. supportUniformBuffers: boolean;
  116206. /**
  116207. * Gets the list of emitted attributes
  116208. */
  116209. attributes: string[];
  116210. /**
  116211. * Gets the list of emitted uniforms
  116212. */
  116213. uniforms: string[];
  116214. /**
  116215. * Gets the list of emitted uniform buffers
  116216. */
  116217. uniformBuffers: string[];
  116218. /**
  116219. * Gets the list of emitted samplers
  116220. */
  116221. samplers: string[];
  116222. /**
  116223. * Gets the list of emitted functions
  116224. */
  116225. functions: {
  116226. [key: string]: string;
  116227. };
  116228. /**
  116229. * Gets the target of the compilation state
  116230. */
  116231. target: NodeMaterialBlockTargets;
  116232. /**
  116233. * Gets the list of emitted counters
  116234. */
  116235. counters: {
  116236. [key: string]: number;
  116237. };
  116238. /**
  116239. * Shared data between multiple NodeMaterialBuildState instances
  116240. */
  116241. sharedData: NodeMaterialBuildStateSharedData;
  116242. /** @hidden */
  116243. _vertexState: NodeMaterialBuildState;
  116244. /** @hidden */
  116245. _attributeDeclaration: string;
  116246. /** @hidden */
  116247. _uniformDeclaration: string;
  116248. /** @hidden */
  116249. _samplerDeclaration: string;
  116250. /** @hidden */
  116251. _varyingTransfer: string;
  116252. private _repeatableContentAnchorIndex;
  116253. /** @hidden */
  116254. _builtCompilationString: string;
  116255. /**
  116256. * Gets the emitted compilation strings
  116257. */
  116258. compilationString: string;
  116259. /**
  116260. * Finalize the compilation strings
  116261. * @param state defines the current compilation state
  116262. */
  116263. finalize(state: NodeMaterialBuildState): void;
  116264. /** @hidden */
  116265. readonly _repeatableContentAnchor: string;
  116266. /** @hidden */
  116267. _getFreeVariableName(prefix: string): string;
  116268. /** @hidden */
  116269. _getFreeDefineName(prefix: string): string;
  116270. /** @hidden */
  116271. _excludeVariableName(name: string): void;
  116272. /** @hidden */
  116273. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  116274. /** @hidden */
  116275. _emitFunction(name: string, code: string, comments: string): void;
  116276. /** @hidden */
  116277. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  116278. replaceStrings?: {
  116279. search: RegExp;
  116280. replace: string;
  116281. }[];
  116282. repeatKey?: string;
  116283. }): string;
  116284. /** @hidden */
  116285. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  116286. repeatKey?: string;
  116287. removeAttributes?: boolean;
  116288. removeUniforms?: boolean;
  116289. removeVaryings?: boolean;
  116290. removeIfDef?: boolean;
  116291. replaceStrings?: {
  116292. search: RegExp;
  116293. replace: string;
  116294. }[];
  116295. }, storeKey?: string): void;
  116296. /** @hidden */
  116297. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116298. /** @hidden */
  116299. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  116300. }
  116301. }
  116302. declare module BABYLON {
  116303. /**
  116304. * Defines a block that can be used inside a node based material
  116305. */
  116306. export class NodeMaterialBlock {
  116307. private _buildId;
  116308. private _buildTarget;
  116309. private _target;
  116310. private _isFinalMerger;
  116311. private _isInput;
  116312. /** @hidden */
  116313. _inputs: NodeMaterialConnectionPoint[];
  116314. /** @hidden */
  116315. _outputs: NodeMaterialConnectionPoint[];
  116316. /**
  116317. * Gets or sets the name of the block
  116318. */
  116319. name: string;
  116320. /**
  116321. * Gets or sets the unique id of the node
  116322. */
  116323. uniqueId: number;
  116324. /**
  116325. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  116326. */
  116327. readonly isFinalMerger: boolean;
  116328. /**
  116329. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  116330. */
  116331. readonly isInput: boolean;
  116332. /**
  116333. * Gets or sets the build Id
  116334. */
  116335. buildId: number;
  116336. /**
  116337. * Gets or sets the target of the block
  116338. */
  116339. target: NodeMaterialBlockTargets;
  116340. /**
  116341. * Gets the list of input points
  116342. */
  116343. readonly inputs: NodeMaterialConnectionPoint[];
  116344. /** Gets the list of output points */
  116345. readonly outputs: NodeMaterialConnectionPoint[];
  116346. /**
  116347. * Find an input by its name
  116348. * @param name defines the name of the input to look for
  116349. * @returns the input or null if not found
  116350. */
  116351. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116352. /**
  116353. * Find an output by its name
  116354. * @param name defines the name of the outputto look for
  116355. * @returns the output or null if not found
  116356. */
  116357. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  116358. /**
  116359. * Creates a new NodeMaterialBlock
  116360. * @param name defines the block name
  116361. * @param target defines the target of that block (Vertex by default)
  116362. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  116363. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  116364. */
  116365. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  116366. /**
  116367. * Initialize the block and prepare the context for build
  116368. * @param state defines the state that will be used for the build
  116369. */
  116370. initialize(state: NodeMaterialBuildState): void;
  116371. /**
  116372. * Bind data to effect. Will only be called for blocks with isBindable === true
  116373. * @param effect defines the effect to bind data to
  116374. * @param nodeMaterial defines the hosting NodeMaterial
  116375. * @param mesh defines the mesh that will be rendered
  116376. */
  116377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116378. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  116379. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  116380. protected _writeFloat(value: number): string;
  116381. /**
  116382. * Gets the current class name e.g. "NodeMaterialBlock"
  116383. * @returns the class name
  116384. */
  116385. getClassName(): string;
  116386. /**
  116387. * Register a new input. Must be called inside a block constructor
  116388. * @param name defines the connection point name
  116389. * @param type defines the connection point type
  116390. * @param isOptional defines a boolean indicating that this input can be omitted
  116391. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116392. * @returns the current block
  116393. */
  116394. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  116395. /**
  116396. * Register a new output. Must be called inside a block constructor
  116397. * @param name defines the connection point name
  116398. * @param type defines the connection point type
  116399. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  116400. * @returns the current block
  116401. */
  116402. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  116403. /**
  116404. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  116405. * @param forOutput defines an optional connection point to check compatibility with
  116406. * @returns the first available input or null
  116407. */
  116408. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  116409. /**
  116410. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  116411. * @param forBlock defines an optional block to check compatibility with
  116412. * @returns the first available input or null
  116413. */
  116414. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  116415. /**
  116416. * Connect current block with another block
  116417. * @param other defines the block to connect with
  116418. * @param options define the various options to help pick the right connections
  116419. * @returns the current block
  116420. */
  116421. connectTo(other: NodeMaterialBlock, options?: {
  116422. input?: string;
  116423. output?: string;
  116424. outputSwizzle?: string;
  116425. }): this | undefined;
  116426. protected _buildBlock(state: NodeMaterialBuildState): void;
  116427. /**
  116428. * Add uniforms, samplers and uniform buffers at compilation time
  116429. * @param state defines the state to update
  116430. * @param nodeMaterial defines the node material requesting the update
  116431. * @param defines defines the material defines to update
  116432. */
  116433. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116434. /**
  116435. * Add potential fallbacks if shader compilation fails
  116436. * @param mesh defines the mesh to be rendered
  116437. * @param fallbacks defines the current prioritized list of fallbacks
  116438. */
  116439. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116440. /**
  116441. * Update defines for shader compilation
  116442. * @param mesh defines the mesh to be rendered
  116443. * @param nodeMaterial defines the node material requesting the update
  116444. * @param defines defines the material defines to update
  116445. * @param useInstances specifies that instances should be used
  116446. */
  116447. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116448. /**
  116449. * Initialize defines for shader compilation
  116450. * @param mesh defines the mesh to be rendered
  116451. * @param nodeMaterial defines the node material requesting the update
  116452. * @param defines defines the material defines to be prepared
  116453. * @param useInstances specifies that instances should be used
  116454. */
  116455. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116456. /**
  116457. * Lets the block try to connect some inputs automatically
  116458. */
  116459. autoConfigure(): void;
  116460. /**
  116461. * Function called when a block is declared as repeatable content generator
  116462. * @param vertexShaderState defines the current compilation state for the vertex shader
  116463. * @param fragmentShaderState defines the current compilation state for the fragment shader
  116464. * @param mesh defines the mesh to be rendered
  116465. * @param defines defines the material defines to update
  116466. */
  116467. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116468. /**
  116469. * Checks if the block is ready
  116470. * @param mesh defines the mesh to be rendered
  116471. * @param nodeMaterial defines the node material requesting the update
  116472. * @param defines defines the material defines to update
  116473. * @param useInstances specifies that instances should be used
  116474. * @returns true if the block is ready
  116475. */
  116476. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  116477. private _processBuild;
  116478. /**
  116479. * Compile the current node and generate the shader code
  116480. * @param state defines the current compilation state (uniforms, samplers, current string)
  116481. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  116482. * @returns true if already built
  116483. */
  116484. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  116485. /**
  116486. * Serializes this block in a JSON representation
  116487. * @returns the serialized block object
  116488. */
  116489. serialize(): any;
  116490. /** @hidden */
  116491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116492. }
  116493. }
  116494. declare module BABYLON {
  116495. /**
  116496. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  116497. */
  116498. export enum NodeMaterialBlockConnectionPointMode {
  116499. /** Value is an uniform */
  116500. Uniform = 0,
  116501. /** Value is a mesh attribute */
  116502. Attribute = 1,
  116503. /** Value is a varying between vertex and fragment shaders */
  116504. Varying = 2,
  116505. /** Mode is undefined */
  116506. Undefined = 3
  116507. }
  116508. }
  116509. declare module BABYLON {
  116510. /**
  116511. * Enum used to define well known values e.g. values automatically provided by the system
  116512. */
  116513. export enum NodeMaterialWellKnownValues {
  116514. /** World */
  116515. World = 1,
  116516. /** View */
  116517. View = 2,
  116518. /** Projection */
  116519. Projection = 3,
  116520. /** ViewProjection */
  116521. ViewProjection = 4,
  116522. /** WorldView */
  116523. WorldView = 5,
  116524. /** WorldViewProjection */
  116525. WorldViewProjection = 6,
  116526. /** CameraPosition */
  116527. CameraPosition = 7,
  116528. /** Fog Color */
  116529. FogColor = 8
  116530. }
  116531. }
  116532. declare module BABYLON {
  116533. /**
  116534. * Contains position and normal vectors for a vertex
  116535. */
  116536. export class PositionNormalVertex {
  116537. /** the position of the vertex (defaut: 0,0,0) */
  116538. position: Vector3;
  116539. /** the normal of the vertex (defaut: 0,1,0) */
  116540. normal: Vector3;
  116541. /**
  116542. * Creates a PositionNormalVertex
  116543. * @param position the position of the vertex (defaut: 0,0,0)
  116544. * @param normal the normal of the vertex (defaut: 0,1,0)
  116545. */
  116546. constructor(
  116547. /** the position of the vertex (defaut: 0,0,0) */
  116548. position?: Vector3,
  116549. /** the normal of the vertex (defaut: 0,1,0) */
  116550. normal?: Vector3);
  116551. /**
  116552. * Clones the PositionNormalVertex
  116553. * @returns the cloned PositionNormalVertex
  116554. */
  116555. clone(): PositionNormalVertex;
  116556. }
  116557. /**
  116558. * Contains position, normal and uv vectors for a vertex
  116559. */
  116560. export class PositionNormalTextureVertex {
  116561. /** the position of the vertex (defaut: 0,0,0) */
  116562. position: Vector3;
  116563. /** the normal of the vertex (defaut: 0,1,0) */
  116564. normal: Vector3;
  116565. /** the uv of the vertex (default: 0,0) */
  116566. uv: Vector2;
  116567. /**
  116568. * Creates a PositionNormalTextureVertex
  116569. * @param position the position of the vertex (defaut: 0,0,0)
  116570. * @param normal the normal of the vertex (defaut: 0,1,0)
  116571. * @param uv the uv of the vertex (default: 0,0)
  116572. */
  116573. constructor(
  116574. /** the position of the vertex (defaut: 0,0,0) */
  116575. position?: Vector3,
  116576. /** the normal of the vertex (defaut: 0,1,0) */
  116577. normal?: Vector3,
  116578. /** the uv of the vertex (default: 0,0) */
  116579. uv?: Vector2);
  116580. /**
  116581. * Clones the PositionNormalTextureVertex
  116582. * @returns the cloned PositionNormalTextureVertex
  116583. */
  116584. clone(): PositionNormalTextureVertex;
  116585. }
  116586. }
  116587. declare module BABYLON {
  116588. /**
  116589. * Block used to expose an input value
  116590. */
  116591. export class InputBlock extends NodeMaterialBlock {
  116592. private _mode;
  116593. private _associatedVariableName;
  116594. private _storedValue;
  116595. private _valueCallback;
  116596. private _type;
  116597. /** @hidden */
  116598. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116599. /**
  116600. * Gets or sets the connection point type (default is float)
  116601. */
  116602. readonly type: NodeMaterialBlockConnectionPointTypes;
  116603. /**
  116604. * Creates a new InputBlock
  116605. * @param name defines the block name
  116606. * @param target defines the target of that block (Vertex by default)
  116607. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  116608. */
  116609. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  116610. /**
  116611. * Gets the output component
  116612. */
  116613. readonly output: NodeMaterialConnectionPoint;
  116614. /**
  116615. * Set the source of this connection point to a vertex attribute
  116616. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  116617. * @returns the current connection point
  116618. */
  116619. setAsAttribute(attributeName?: string): InputBlock;
  116620. /**
  116621. * Set the source of this connection point to a well known value
  116622. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  116623. * @returns the current connection point
  116624. */
  116625. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  116626. /**
  116627. * Gets or sets the value of that point.
  116628. * Please note that this value will be ignored if valueCallback is defined
  116629. */
  116630. value: any;
  116631. /**
  116632. * Gets or sets a callback used to get the value of that point.
  116633. * Please note that setting this value will force the connection point to ignore the value property
  116634. */
  116635. valueCallback: () => any;
  116636. /**
  116637. * Gets or sets the associated variable name in the shader
  116638. */
  116639. associatedVariableName: string;
  116640. /**
  116641. * Gets a boolean indicating that this connection point not defined yet
  116642. */
  116643. readonly isUndefined: boolean;
  116644. /**
  116645. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  116646. * In this case the connection point name must be the name of the uniform to use.
  116647. * Can only be set on inputs
  116648. */
  116649. isUniform: boolean;
  116650. /**
  116651. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  116652. * In this case the connection point name must be the name of the attribute to use
  116653. * Can only be set on inputs
  116654. */
  116655. isAttribute: boolean;
  116656. /**
  116657. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  116658. * Can only be set on exit points
  116659. */
  116660. isVarying: boolean;
  116661. /**
  116662. * Gets a boolean indicating that the current connection point is a well known value
  116663. */
  116664. readonly isWellKnownValue: boolean;
  116665. /**
  116666. * Gets or sets the current well known value or null if not defined as well know value
  116667. */
  116668. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116669. /**
  116670. * Gets the current class name
  116671. * @returns the class name
  116672. */
  116673. getClassName(): string;
  116674. private _emitDefine;
  116675. /**
  116676. * Set the input block to its default value (based on its type)
  116677. */
  116678. setDefaultValue(): void;
  116679. private _emit;
  116680. /** @hidden */
  116681. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  116682. /** @hidden */
  116683. _transmit(effect: Effect, scene: Scene): void;
  116684. protected _buildBlock(state: NodeMaterialBuildState): void;
  116685. serialize(): any;
  116686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116687. }
  116688. }
  116689. declare module BABYLON {
  116690. /**
  116691. * Defines a connection point for a block
  116692. */
  116693. export class NodeMaterialConnectionPoint {
  116694. /** @hidden */
  116695. _ownerBlock: NodeMaterialBlock;
  116696. /** @hidden */
  116697. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116698. private _endpoints;
  116699. private _associatedVariableName;
  116700. /** @hidden */
  116701. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  116702. private _type;
  116703. /** @hidden */
  116704. _enforceAssociatedVariableName: boolean;
  116705. /**
  116706. * Gets or sets the additional types supported byt this connection point
  116707. */
  116708. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  116709. /**
  116710. * Gets or sets the associated variable name in the shader
  116711. */
  116712. associatedVariableName: string;
  116713. /**
  116714. * Gets or sets the connection point type (default is float)
  116715. */
  116716. type: NodeMaterialBlockConnectionPointTypes;
  116717. /**
  116718. * Gets or sets the connection point name
  116719. */
  116720. name: string;
  116721. /**
  116722. * Gets or sets a boolean indicating that this connection point can be omitted
  116723. */
  116724. isOptional: boolean;
  116725. /**
  116726. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  116727. */
  116728. define: string;
  116729. /** Gets or sets the target of that connection point */
  116730. target: NodeMaterialBlockTargets;
  116731. /**
  116732. * Gets a boolean indicating that the current point is connected
  116733. */
  116734. readonly isConnected: boolean;
  116735. /**
  116736. * Gets a boolean indicating that the current point is connected to an input block
  116737. */
  116738. readonly isConnectedToInput: boolean;
  116739. /**
  116740. * Gets a the connected input block (if any)
  116741. */
  116742. readonly connectInputBlock: Nullable<InputBlock>;
  116743. /** Get the other side of the connection (if any) */
  116744. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116745. /** Get the block that owns this connection point */
  116746. readonly ownerBlock: NodeMaterialBlock;
  116747. /** Get the block connected on the other side of this connection (if any) */
  116748. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  116749. /** Get the block connected on the endpoints of this connection (if any) */
  116750. readonly connectedBlocks: Array<NodeMaterialBlock>;
  116751. /** Gets the list of connected endpoints */
  116752. readonly endpoints: NodeMaterialConnectionPoint[];
  116753. /**
  116754. * Creates a new connection point
  116755. * @param name defines the connection point name
  116756. * @param ownerBlock defines the block hosting this connection point
  116757. */
  116758. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116759. /**
  116760. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116761. * @returns the class name
  116762. */
  116763. getClassName(): string;
  116764. /**
  116765. * Gets an boolean indicating if the current point can be connected to another point
  116766. * @param connectionPoint defines the other connection point
  116767. * @returns true if the connection is possible
  116768. */
  116769. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116770. /**
  116771. * Connect this point to another connection point
  116772. * @param connectionPoint defines the other connection point
  116773. * @returns the current connection point
  116774. */
  116775. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116776. /**
  116777. * Disconnect this point from one of his endpoint
  116778. * @param endpoint defines the other connection point
  116779. * @returns the current connection point
  116780. */
  116781. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116782. /**
  116783. * Serializes this point in a JSON representation
  116784. * @returns the serialized point object
  116785. */
  116786. serialize(): any;
  116787. }
  116788. }
  116789. declare module BABYLON {
  116790. /**
  116791. * Block used to add support for vertex skinning (bones)
  116792. */
  116793. export class BonesBlock extends NodeMaterialBlock {
  116794. /**
  116795. * Creates a new BonesBlock
  116796. * @param name defines the block name
  116797. */
  116798. constructor(name: string);
  116799. /**
  116800. * Initialize the block and prepare the context for build
  116801. * @param state defines the state that will be used for the build
  116802. */
  116803. initialize(state: NodeMaterialBuildState): void;
  116804. /**
  116805. * Gets the current class name
  116806. * @returns the class name
  116807. */
  116808. getClassName(): string;
  116809. /**
  116810. * Gets the matrix indices input component
  116811. */
  116812. readonly matricesIndices: NodeMaterialConnectionPoint;
  116813. /**
  116814. * Gets the matrix weights input component
  116815. */
  116816. readonly matricesWeights: NodeMaterialConnectionPoint;
  116817. /**
  116818. * Gets the extra matrix indices input component
  116819. */
  116820. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116821. /**
  116822. * Gets the extra matrix weights input component
  116823. */
  116824. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116825. /**
  116826. * Gets the world input component
  116827. */
  116828. readonly world: NodeMaterialConnectionPoint;
  116829. /**
  116830. * Gets the output component
  116831. */
  116832. readonly output: NodeMaterialConnectionPoint;
  116833. autoConfigure(): void;
  116834. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116835. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116836. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116837. protected _buildBlock(state: NodeMaterialBuildState): this;
  116838. }
  116839. }
  116840. declare module BABYLON {
  116841. /**
  116842. * Block used to add support for instances
  116843. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116844. */
  116845. export class InstancesBlock extends NodeMaterialBlock {
  116846. /**
  116847. * Creates a new InstancesBlock
  116848. * @param name defines the block name
  116849. */
  116850. constructor(name: string);
  116851. /**
  116852. * Gets the current class name
  116853. * @returns the class name
  116854. */
  116855. getClassName(): string;
  116856. /**
  116857. * Gets the first world row input component
  116858. */
  116859. readonly world0: NodeMaterialConnectionPoint;
  116860. /**
  116861. * Gets the second world row input component
  116862. */
  116863. readonly world1: NodeMaterialConnectionPoint;
  116864. /**
  116865. * Gets the third world row input component
  116866. */
  116867. readonly world2: NodeMaterialConnectionPoint;
  116868. /**
  116869. * Gets the forth world row input component
  116870. */
  116871. readonly world3: NodeMaterialConnectionPoint;
  116872. /**
  116873. * Gets the world input component
  116874. */
  116875. readonly world: NodeMaterialConnectionPoint;
  116876. /**
  116877. * Gets the output component
  116878. */
  116879. readonly output: NodeMaterialConnectionPoint;
  116880. autoConfigure(): void;
  116881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116882. protected _buildBlock(state: NodeMaterialBuildState): this;
  116883. }
  116884. }
  116885. declare module BABYLON {
  116886. /**
  116887. * Block used to add morph targets support to vertex shader
  116888. */
  116889. export class MorphTargetsBlock extends NodeMaterialBlock {
  116890. private _repeatableContentAnchor;
  116891. private _repeatebleContentGenerated;
  116892. /**
  116893. * Create a new MorphTargetsBlock
  116894. * @param name defines the block name
  116895. */
  116896. constructor(name: string);
  116897. /**
  116898. * Gets the current class name
  116899. * @returns the class name
  116900. */
  116901. getClassName(): string;
  116902. /**
  116903. * Gets the position input component
  116904. */
  116905. readonly position: NodeMaterialConnectionPoint;
  116906. /**
  116907. * Gets the normal input component
  116908. */
  116909. readonly normal: NodeMaterialConnectionPoint;
  116910. /**
  116911. * Gets the tangent input component
  116912. */
  116913. readonly tangent: NodeMaterialConnectionPoint;
  116914. /**
  116915. * Gets the tangent input component
  116916. */
  116917. readonly uv: NodeMaterialConnectionPoint;
  116918. /**
  116919. * Gets the position output component
  116920. */
  116921. readonly positionOutput: NodeMaterialConnectionPoint;
  116922. /**
  116923. * Gets the normal output component
  116924. */
  116925. readonly normalOutput: NodeMaterialConnectionPoint;
  116926. /**
  116927. * Gets the tangent output component
  116928. */
  116929. readonly tangentOutput: NodeMaterialConnectionPoint;
  116930. /**
  116931. * Gets the tangent output component
  116932. */
  116933. readonly uvOutput: NodeMaterialConnectionPoint;
  116934. initialize(state: NodeMaterialBuildState): void;
  116935. autoConfigure(): void;
  116936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116938. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116939. protected _buildBlock(state: NodeMaterialBuildState): this;
  116940. }
  116941. }
  116942. declare module BABYLON {
  116943. /**
  116944. * Block used to add an alpha test in the fragment shader
  116945. */
  116946. export class AlphaTestBlock extends NodeMaterialBlock {
  116947. /**
  116948. * Gets or sets the alpha value where alpha testing happens
  116949. */
  116950. alphaCutOff: number;
  116951. /**
  116952. * Create a new AlphaTestBlock
  116953. * @param name defines the block name
  116954. */
  116955. constructor(name: string);
  116956. /**
  116957. * Gets the current class name
  116958. * @returns the class name
  116959. */
  116960. getClassName(): string;
  116961. /**
  116962. * Gets the color input component
  116963. */
  116964. readonly color: NodeMaterialConnectionPoint;
  116965. /**
  116966. * Gets the alpha input component
  116967. */
  116968. readonly alpha: NodeMaterialConnectionPoint;
  116969. protected _buildBlock(state: NodeMaterialBuildState): this;
  116970. }
  116971. }
  116972. declare module BABYLON {
  116973. /**
  116974. * Block used to create a Color3/4 out of individual inputs (one for each component)
  116975. */
  116976. export class ColorMergerBlock extends NodeMaterialBlock {
  116977. /**
  116978. * Create a new ColorMergerBlock
  116979. * @param name defines the block name
  116980. */
  116981. constructor(name: string);
  116982. /**
  116983. * Gets the current class name
  116984. * @returns the class name
  116985. */
  116986. getClassName(): string;
  116987. /**
  116988. * Gets the r component (input)
  116989. */
  116990. readonly r: NodeMaterialConnectionPoint;
  116991. /**
  116992. * Gets the g component (input)
  116993. */
  116994. readonly g: NodeMaterialConnectionPoint;
  116995. /**
  116996. * Gets the b component (input)
  116997. */
  116998. readonly b: NodeMaterialConnectionPoint;
  116999. /**
  117000. * Gets the a component (input)
  117001. */
  117002. readonly a: NodeMaterialConnectionPoint;
  117003. /**
  117004. * Gets the rgba component (output)
  117005. */
  117006. readonly rgba: NodeMaterialConnectionPoint;
  117007. /**
  117008. * Gets the rgb component (output)
  117009. */
  117010. readonly rgb: NodeMaterialConnectionPoint;
  117011. protected _buildBlock(state: NodeMaterialBuildState): this;
  117012. }
  117013. }
  117014. declare module BABYLON {
  117015. /**
  117016. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  117017. */
  117018. export class VectorMergerBlock extends NodeMaterialBlock {
  117019. /**
  117020. * Create a new VectorMergerBlock
  117021. * @param name defines the block name
  117022. */
  117023. constructor(name: string);
  117024. /**
  117025. * Gets the current class name
  117026. * @returns the class name
  117027. */
  117028. getClassName(): string;
  117029. /**
  117030. * Gets the x component (input)
  117031. */
  117032. readonly x: NodeMaterialConnectionPoint;
  117033. /**
  117034. * Gets the y component (input)
  117035. */
  117036. readonly y: NodeMaterialConnectionPoint;
  117037. /**
  117038. * Gets the z component (input)
  117039. */
  117040. readonly z: NodeMaterialConnectionPoint;
  117041. /**
  117042. * Gets the w component (input)
  117043. */
  117044. readonly w: NodeMaterialConnectionPoint;
  117045. /**
  117046. * Gets the xyzw component (output)
  117047. */
  117048. readonly xyzw: NodeMaterialConnectionPoint;
  117049. /**
  117050. * Gets the xyz component (output)
  117051. */
  117052. readonly xyz: NodeMaterialConnectionPoint;
  117053. /**
  117054. * Gets the xy component (output)
  117055. */
  117056. readonly xy: NodeMaterialConnectionPoint;
  117057. protected _buildBlock(state: NodeMaterialBuildState): this;
  117058. }
  117059. }
  117060. declare module BABYLON {
  117061. /**
  117062. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  117063. */
  117064. export class ColorSplitterBlock extends NodeMaterialBlock {
  117065. /**
  117066. * Create a new ColorSplitterBlock
  117067. * @param name defines the block name
  117068. */
  117069. constructor(name: string);
  117070. /**
  117071. * Gets the current class name
  117072. * @returns the class name
  117073. */
  117074. getClassName(): string;
  117075. /**
  117076. * Gets the rgba component (input)
  117077. */
  117078. readonly rgba: NodeMaterialConnectionPoint;
  117079. /**
  117080. * Gets the rgb component (input)
  117081. */
  117082. readonly rgbIn: NodeMaterialConnectionPoint;
  117083. /**
  117084. * Gets the rgb component (output)
  117085. */
  117086. readonly rgbOut: NodeMaterialConnectionPoint;
  117087. /**
  117088. * Gets the r component (output)
  117089. */
  117090. readonly r: NodeMaterialConnectionPoint;
  117091. /**
  117092. * Gets the g component (output)
  117093. */
  117094. readonly g: NodeMaterialConnectionPoint;
  117095. /**
  117096. * Gets the b component (output)
  117097. */
  117098. readonly b: NodeMaterialConnectionPoint;
  117099. /**
  117100. * Gets the a component (output)
  117101. */
  117102. readonly a: NodeMaterialConnectionPoint;
  117103. protected _buildBlock(state: NodeMaterialBuildState): this;
  117104. }
  117105. }
  117106. declare module BABYLON {
  117107. /**
  117108. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  117109. */
  117110. export class VectorSplitterBlock extends NodeMaterialBlock {
  117111. /**
  117112. * Create a new VectorSplitterBlock
  117113. * @param name defines the block name
  117114. */
  117115. constructor(name: string);
  117116. /**
  117117. * Gets the current class name
  117118. * @returns the class name
  117119. */
  117120. getClassName(): string;
  117121. /**
  117122. * Gets the xyzw component (input)
  117123. */
  117124. readonly xyzw: NodeMaterialConnectionPoint;
  117125. /**
  117126. * Gets the xyz component (input)
  117127. */
  117128. readonly xyzIn: NodeMaterialConnectionPoint;
  117129. /**
  117130. * Gets the xyz component (output)
  117131. */
  117132. readonly xyzOut: NodeMaterialConnectionPoint;
  117133. /**
  117134. * Gets the xy component (output)
  117135. */
  117136. readonly xy: NodeMaterialConnectionPoint;
  117137. /**
  117138. * Gets the x component (output)
  117139. */
  117140. readonly x: NodeMaterialConnectionPoint;
  117141. /**
  117142. * Gets the y component (output)
  117143. */
  117144. readonly y: NodeMaterialConnectionPoint;
  117145. /**
  117146. * Gets the z component (output)
  117147. */
  117148. readonly z: NodeMaterialConnectionPoint;
  117149. /**
  117150. * Gets the w component (output)
  117151. */
  117152. readonly w: NodeMaterialConnectionPoint;
  117153. protected _buildBlock(state: NodeMaterialBuildState): this;
  117154. }
  117155. }
  117156. declare module BABYLON {
  117157. /**
  117158. * Block used to add image processing support to fragment shader
  117159. */
  117160. export class ImageProcessingBlock extends NodeMaterialBlock {
  117161. /**
  117162. * Create a new ImageProcessingBlock
  117163. * @param name defines the block name
  117164. */
  117165. constructor(name: string);
  117166. /**
  117167. * Gets the current class name
  117168. * @returns the class name
  117169. */
  117170. getClassName(): string;
  117171. /**
  117172. * Gets the color input component
  117173. */
  117174. readonly color: NodeMaterialConnectionPoint;
  117175. /**
  117176. * Gets the output component
  117177. */
  117178. readonly output: NodeMaterialConnectionPoint;
  117179. /**
  117180. * Initialize the block and prepare the context for build
  117181. * @param state defines the state that will be used for the build
  117182. */
  117183. initialize(state: NodeMaterialBuildState): void;
  117184. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  117185. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117187. protected _buildBlock(state: NodeMaterialBuildState): this;
  117188. }
  117189. }
  117190. declare module BABYLON {
  117191. /**
  117192. * Block used to add support for scene fog
  117193. */
  117194. export class FogBlock extends NodeMaterialBlock {
  117195. private _fogDistanceName;
  117196. private _fogParameters;
  117197. /**
  117198. * Create a new FogBlock
  117199. * @param name defines the block name
  117200. */
  117201. constructor(name: string);
  117202. /**
  117203. * Gets the current class name
  117204. * @returns the class name
  117205. */
  117206. getClassName(): string;
  117207. /**
  117208. * Gets the world position input component
  117209. */
  117210. readonly worldPosition: NodeMaterialConnectionPoint;
  117211. /**
  117212. * Gets the view input component
  117213. */
  117214. readonly view: NodeMaterialConnectionPoint;
  117215. /**
  117216. * Gets the color input component
  117217. */
  117218. readonly color: NodeMaterialConnectionPoint;
  117219. /**
  117220. * Gets the fog color input component
  117221. */
  117222. readonly fogColor: NodeMaterialConnectionPoint;
  117223. /**
  117224. * Gets the output component
  117225. */
  117226. readonly output: NodeMaterialConnectionPoint;
  117227. autoConfigure(): void;
  117228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117230. protected _buildBlock(state: NodeMaterialBuildState): this;
  117231. }
  117232. }
  117233. declare module BABYLON {
  117234. /**
  117235. * Block used to add light in the fragment shader
  117236. */
  117237. export class LightBlock extends NodeMaterialBlock {
  117238. private _lightId;
  117239. /**
  117240. * Gets or sets the light associated with this block
  117241. */
  117242. light: Nullable<Light>;
  117243. /**
  117244. * Create a new LightBlock
  117245. * @param name defines the block name
  117246. */
  117247. constructor(name: string);
  117248. /**
  117249. * Gets the current class name
  117250. * @returns the class name
  117251. */
  117252. getClassName(): string;
  117253. /**
  117254. * Gets the world position input component
  117255. */
  117256. readonly worldPosition: NodeMaterialConnectionPoint;
  117257. /**
  117258. * Gets the world normal input component
  117259. */
  117260. readonly worldNormal: NodeMaterialConnectionPoint;
  117261. /**
  117262. * Gets the camera (or eye) position component
  117263. */
  117264. readonly cameraPosition: NodeMaterialConnectionPoint;
  117265. /**
  117266. * Gets the diffuse output component
  117267. */
  117268. readonly diffuseOutput: NodeMaterialConnectionPoint;
  117269. /**
  117270. * Gets the specular output component
  117271. */
  117272. readonly specularOutput: NodeMaterialConnectionPoint;
  117273. autoConfigure(): void;
  117274. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117275. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  117276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  117277. private _injectVertexCode;
  117278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  117279. serialize(): any;
  117280. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117281. }
  117282. }
  117283. declare module BABYLON {
  117284. /**
  117285. * Block used to multiply 2 values
  117286. */
  117287. export class MultiplyBlock extends NodeMaterialBlock {
  117288. /**
  117289. * Creates a new MultiplyBlock
  117290. * @param name defines the block name
  117291. */
  117292. constructor(name: string);
  117293. /**
  117294. * Gets the current class name
  117295. * @returns the class name
  117296. */
  117297. getClassName(): string;
  117298. /**
  117299. * Gets the left operand input component
  117300. */
  117301. readonly left: NodeMaterialConnectionPoint;
  117302. /**
  117303. * Gets the right operand input component
  117304. */
  117305. readonly right: NodeMaterialConnectionPoint;
  117306. /**
  117307. * Gets the output component
  117308. */
  117309. readonly output: NodeMaterialConnectionPoint;
  117310. protected _buildBlock(state: NodeMaterialBuildState): this;
  117311. }
  117312. }
  117313. declare module BABYLON {
  117314. /**
  117315. * Block used to add 2 vectors
  117316. */
  117317. export class AddBlock extends NodeMaterialBlock {
  117318. /**
  117319. * Creates a new AddBlock
  117320. * @param name defines the block name
  117321. */
  117322. constructor(name: string);
  117323. /**
  117324. * Gets the current class name
  117325. * @returns the class name
  117326. */
  117327. getClassName(): string;
  117328. /**
  117329. * Gets the left operand input component
  117330. */
  117331. readonly left: NodeMaterialConnectionPoint;
  117332. /**
  117333. * Gets the right operand input component
  117334. */
  117335. readonly right: NodeMaterialConnectionPoint;
  117336. /**
  117337. * Gets the output component
  117338. */
  117339. readonly output: NodeMaterialConnectionPoint;
  117340. protected _buildBlock(state: NodeMaterialBuildState): this;
  117341. }
  117342. }
  117343. declare module BABYLON {
  117344. /**
  117345. * Block used to clamp a float
  117346. */
  117347. export class ClampBlock extends NodeMaterialBlock {
  117348. /** Gets or sets the minimum range */
  117349. minimum: number;
  117350. /** Gets or sets the maximum range */
  117351. maximum: number;
  117352. /**
  117353. * Creates a new ClampBlock
  117354. * @param name defines the block name
  117355. */
  117356. constructor(name: string);
  117357. /**
  117358. * Gets the current class name
  117359. * @returns the class name
  117360. */
  117361. getClassName(): string;
  117362. /**
  117363. * Gets the value input component
  117364. */
  117365. readonly value: NodeMaterialConnectionPoint;
  117366. /**
  117367. * Gets the output component
  117368. */
  117369. readonly output: NodeMaterialConnectionPoint;
  117370. protected _buildBlock(state: NodeMaterialBuildState): this;
  117371. }
  117372. }
  117373. declare module BABYLON {
  117374. /**
  117375. * Block used to apply a cross product between 2 vectors
  117376. */
  117377. export class CrossBlock extends NodeMaterialBlock {
  117378. /**
  117379. * Creates a new CrossBlock
  117380. * @param name defines the block name
  117381. */
  117382. constructor(name: string);
  117383. /**
  117384. * Gets the current class name
  117385. * @returns the class name
  117386. */
  117387. getClassName(): string;
  117388. /**
  117389. * Gets the left operand input component
  117390. */
  117391. readonly left: NodeMaterialConnectionPoint;
  117392. /**
  117393. * Gets the right operand input component
  117394. */
  117395. readonly right: NodeMaterialConnectionPoint;
  117396. /**
  117397. * Gets the output component
  117398. */
  117399. readonly output: NodeMaterialConnectionPoint;
  117400. protected _buildBlock(state: NodeMaterialBuildState): this;
  117401. }
  117402. }
  117403. declare module BABYLON {
  117404. /**
  117405. * Block used to apply a dot product between 2 vectors
  117406. */
  117407. export class DotBlock extends NodeMaterialBlock {
  117408. /**
  117409. * Creates a new DotBlock
  117410. * @param name defines the block name
  117411. */
  117412. constructor(name: string);
  117413. /**
  117414. * Gets the current class name
  117415. * @returns the class name
  117416. */
  117417. getClassName(): string;
  117418. /**
  117419. * Gets the left operand input component
  117420. */
  117421. readonly left: NodeMaterialConnectionPoint;
  117422. /**
  117423. * Gets the right operand input component
  117424. */
  117425. readonly right: NodeMaterialConnectionPoint;
  117426. /**
  117427. * Gets the output component
  117428. */
  117429. readonly output: NodeMaterialConnectionPoint;
  117430. protected _buildBlock(state: NodeMaterialBuildState): this;
  117431. }
  117432. }
  117433. declare module BABYLON {
  117434. /**
  117435. * Block used to remap a float from a range to a new one
  117436. */
  117437. export class RemapBlock extends NodeMaterialBlock {
  117438. /**
  117439. * Gets or sets the source range
  117440. */
  117441. sourceRange: Vector2;
  117442. /**
  117443. * Gets or sets the target range
  117444. */
  117445. targetRange: Vector2;
  117446. /**
  117447. * Creates a new RemapBlock
  117448. * @param name defines the block name
  117449. */
  117450. constructor(name: string);
  117451. /**
  117452. * Gets the current class name
  117453. * @returns the class name
  117454. */
  117455. getClassName(): string;
  117456. /**
  117457. * Gets the input component
  117458. */
  117459. readonly input: NodeMaterialConnectionPoint;
  117460. /**
  117461. * Gets the output component
  117462. */
  117463. readonly output: NodeMaterialConnectionPoint;
  117464. protected _buildBlock(state: NodeMaterialBuildState): this;
  117465. }
  117466. }
  117467. declare module BABYLON {
  117468. /**
  117469. * Block used to normalize a vector
  117470. */
  117471. export class NormalizeBlock extends NodeMaterialBlock {
  117472. /**
  117473. * Creates a new NormalizeBlock
  117474. * @param name defines the block name
  117475. */
  117476. constructor(name: string);
  117477. /**
  117478. * Gets the current class name
  117479. * @returns the class name
  117480. */
  117481. getClassName(): string;
  117482. /**
  117483. * Gets the input component
  117484. */
  117485. readonly input: NodeMaterialConnectionPoint;
  117486. /**
  117487. * Gets the output component
  117488. */
  117489. readonly output: NodeMaterialConnectionPoint;
  117490. protected _buildBlock(state: NodeMaterialBuildState): this;
  117491. }
  117492. }
  117493. declare module BABYLON {
  117494. /**
  117495. * Effect Render Options
  117496. */
  117497. export interface IEffectRendererOptions {
  117498. /**
  117499. * Defines the vertices positions.
  117500. */
  117501. positions?: number[];
  117502. /**
  117503. * Defines the indices.
  117504. */
  117505. indices?: number[];
  117506. }
  117507. /**
  117508. * Helper class to render one or more effects
  117509. */
  117510. export class EffectRenderer {
  117511. private engine;
  117512. private static _DefaultOptions;
  117513. private _vertexBuffers;
  117514. private _indexBuffer;
  117515. private _ringBufferIndex;
  117516. private _ringScreenBuffer;
  117517. private _fullscreenViewport;
  117518. private _getNextFrameBuffer;
  117519. /**
  117520. * Creates an effect renderer
  117521. * @param engine the engine to use for rendering
  117522. * @param options defines the options of the effect renderer
  117523. */
  117524. constructor(engine: Engine, options?: IEffectRendererOptions);
  117525. /**
  117526. * Sets the current viewport in normalized coordinates 0-1
  117527. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  117528. */
  117529. setViewport(viewport?: Viewport): void;
  117530. /**
  117531. * Sets the current effect wrapper to use during draw.
  117532. * The effect needs to be ready before calling this api.
  117533. * This also sets the default full screen position attribute.
  117534. * @param effectWrapper Defines the effect to draw with
  117535. */
  117536. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  117537. /**
  117538. * Draws a full screen quad.
  117539. */
  117540. draw(): void;
  117541. /**
  117542. * renders one or more effects to a specified texture
  117543. * @param effectWrappers list of effects to renderer
  117544. * @param outputTexture texture to draw to, if null it will render to the screen
  117545. */
  117546. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  117547. /**
  117548. * Disposes of the effect renderer
  117549. */
  117550. dispose(): void;
  117551. }
  117552. /**
  117553. * Options to create an EffectWrapper
  117554. */
  117555. interface EffectWrapperCreationOptions {
  117556. /**
  117557. * Engine to use to create the effect
  117558. */
  117559. engine: Engine;
  117560. /**
  117561. * Fragment shader for the effect
  117562. */
  117563. fragmentShader: string;
  117564. /**
  117565. * Vertex shader for the effect
  117566. */
  117567. vertexShader?: string;
  117568. /**
  117569. * Attributes to use in the shader
  117570. */
  117571. attributeNames?: Array<string>;
  117572. /**
  117573. * Uniforms to use in the shader
  117574. */
  117575. uniformNames?: Array<string>;
  117576. /**
  117577. * Texture sampler names to use in the shader
  117578. */
  117579. samplerNames?: Array<string>;
  117580. /**
  117581. * The friendly name of the effect displayed in Spector.
  117582. */
  117583. name?: string;
  117584. }
  117585. /**
  117586. * Wraps an effect to be used for rendering
  117587. */
  117588. export class EffectWrapper {
  117589. /**
  117590. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  117591. */
  117592. onApplyObservable: Observable<{}>;
  117593. /**
  117594. * The underlying effect
  117595. */
  117596. effect: Effect;
  117597. /**
  117598. * Creates an effect to be renderer
  117599. * @param creationOptions options to create the effect
  117600. */
  117601. constructor(creationOptions: EffectWrapperCreationOptions);
  117602. /**
  117603. * Disposes of the effect wrapper
  117604. */
  117605. dispose(): void;
  117606. }
  117607. }
  117608. declare module BABYLON {
  117609. /**
  117610. * Helper class to push actions to a pool of workers.
  117611. */
  117612. export class WorkerPool implements IDisposable {
  117613. private _workerInfos;
  117614. private _pendingActions;
  117615. /**
  117616. * Constructor
  117617. * @param workers Array of workers to use for actions
  117618. */
  117619. constructor(workers: Array<Worker>);
  117620. /**
  117621. * Terminates all workers and clears any pending actions.
  117622. */
  117623. dispose(): void;
  117624. /**
  117625. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117626. * pended until a worker has completed its action.
  117627. * @param action The action to perform. Call onComplete when the action is complete.
  117628. */
  117629. push(action: (worker: Worker, onComplete: () => void) => void): void;
  117630. private _execute;
  117631. }
  117632. }
  117633. declare module BABYLON {
  117634. /**
  117635. * Configuration for Draco compression
  117636. */
  117637. export interface IDracoCompressionConfiguration {
  117638. /**
  117639. * Configuration for the decoder.
  117640. */
  117641. decoder: {
  117642. /**
  117643. * The url to the WebAssembly module.
  117644. */
  117645. wasmUrl?: string;
  117646. /**
  117647. * The url to the WebAssembly binary.
  117648. */
  117649. wasmBinaryUrl?: string;
  117650. /**
  117651. * The url to the fallback JavaScript module.
  117652. */
  117653. fallbackUrl?: string;
  117654. };
  117655. }
  117656. /**
  117657. * Draco compression (https://google.github.io/draco/)
  117658. *
  117659. * This class wraps the Draco module.
  117660. *
  117661. * **Encoder**
  117662. *
  117663. * The encoder is not currently implemented.
  117664. *
  117665. * **Decoder**
  117666. *
  117667. * 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.
  117668. *
  117669. * To update the configuration, use the following code:
  117670. * ```javascript
  117671. * DracoCompression.Configuration = {
  117672. * decoder: {
  117673. * wasmUrl: "<url to the WebAssembly library>",
  117674. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  117675. * fallbackUrl: "<url to the fallback JavaScript library>",
  117676. * }
  117677. * };
  117678. * ```
  117679. *
  117680. * 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.
  117681. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  117682. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  117683. *
  117684. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  117685. * ```javascript
  117686. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  117687. * ```
  117688. *
  117689. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  117690. */
  117691. export class DracoCompression implements IDisposable {
  117692. private _workerPoolPromise?;
  117693. private _decoderModulePromise?;
  117694. /**
  117695. * The configuration. Defaults to the following urls:
  117696. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  117697. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  117698. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  117699. */
  117700. static Configuration: IDracoCompressionConfiguration;
  117701. /**
  117702. * Returns true if the decoder configuration is available.
  117703. */
  117704. static readonly DecoderAvailable: boolean;
  117705. /**
  117706. * Default number of workers to create when creating the draco compression object.
  117707. */
  117708. static DefaultNumWorkers: number;
  117709. private static GetDefaultNumWorkers;
  117710. private static _Default;
  117711. /**
  117712. * Default instance for the draco compression object.
  117713. */
  117714. static readonly Default: DracoCompression;
  117715. /**
  117716. * Constructor
  117717. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  117718. */
  117719. constructor(numWorkers?: number);
  117720. /**
  117721. * Stop all async operations and release resources.
  117722. */
  117723. dispose(): void;
  117724. /**
  117725. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  117726. * @returns a promise that resolves when ready
  117727. */
  117728. whenReadyAsync(): Promise<void>;
  117729. /**
  117730. * Decode Draco compressed mesh data to vertex data.
  117731. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  117732. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  117733. * @returns A promise that resolves with the decoded vertex data
  117734. */
  117735. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  117736. [kind: string]: number;
  117737. }): Promise<VertexData>;
  117738. }
  117739. }
  117740. declare module BABYLON {
  117741. /**
  117742. * Class for building Constructive Solid Geometry
  117743. */
  117744. export class CSG {
  117745. private polygons;
  117746. /**
  117747. * The world matrix
  117748. */
  117749. matrix: Matrix;
  117750. /**
  117751. * Stores the position
  117752. */
  117753. position: Vector3;
  117754. /**
  117755. * Stores the rotation
  117756. */
  117757. rotation: Vector3;
  117758. /**
  117759. * Stores the rotation quaternion
  117760. */
  117761. rotationQuaternion: Nullable<Quaternion>;
  117762. /**
  117763. * Stores the scaling vector
  117764. */
  117765. scaling: Vector3;
  117766. /**
  117767. * Convert the Mesh to CSG
  117768. * @param mesh The Mesh to convert to CSG
  117769. * @returns A new CSG from the Mesh
  117770. */
  117771. static FromMesh(mesh: Mesh): CSG;
  117772. /**
  117773. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  117774. * @param polygons Polygons used to construct a CSG solid
  117775. */
  117776. private static FromPolygons;
  117777. /**
  117778. * Clones, or makes a deep copy, of the CSG
  117779. * @returns A new CSG
  117780. */
  117781. clone(): CSG;
  117782. /**
  117783. * Unions this CSG with another CSG
  117784. * @param csg The CSG to union against this CSG
  117785. * @returns The unioned CSG
  117786. */
  117787. union(csg: CSG): CSG;
  117788. /**
  117789. * Unions this CSG with another CSG in place
  117790. * @param csg The CSG to union against this CSG
  117791. */
  117792. unionInPlace(csg: CSG): void;
  117793. /**
  117794. * Subtracts this CSG with another CSG
  117795. * @param csg The CSG to subtract against this CSG
  117796. * @returns A new CSG
  117797. */
  117798. subtract(csg: CSG): CSG;
  117799. /**
  117800. * Subtracts this CSG with another CSG in place
  117801. * @param csg The CSG to subtact against this CSG
  117802. */
  117803. subtractInPlace(csg: CSG): void;
  117804. /**
  117805. * Intersect this CSG with another CSG
  117806. * @param csg The CSG to intersect against this CSG
  117807. * @returns A new CSG
  117808. */
  117809. intersect(csg: CSG): CSG;
  117810. /**
  117811. * Intersects this CSG with another CSG in place
  117812. * @param csg The CSG to intersect against this CSG
  117813. */
  117814. intersectInPlace(csg: CSG): void;
  117815. /**
  117816. * Return a new CSG solid with solid and empty space switched. This solid is
  117817. * not modified.
  117818. * @returns A new CSG solid with solid and empty space switched
  117819. */
  117820. inverse(): CSG;
  117821. /**
  117822. * Inverses the CSG in place
  117823. */
  117824. inverseInPlace(): void;
  117825. /**
  117826. * This is used to keep meshes transformations so they can be restored
  117827. * when we build back a Babylon Mesh
  117828. * NB : All CSG operations are performed in world coordinates
  117829. * @param csg The CSG to copy the transform attributes from
  117830. * @returns This CSG
  117831. */
  117832. copyTransformAttributes(csg: CSG): CSG;
  117833. /**
  117834. * Build Raw mesh from CSG
  117835. * Coordinates here are in world space
  117836. * @param name The name of the mesh geometry
  117837. * @param scene The Scene
  117838. * @param keepSubMeshes Specifies if the submeshes should be kept
  117839. * @returns A new Mesh
  117840. */
  117841. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  117842. /**
  117843. * Build Mesh from CSG taking material and transforms into account
  117844. * @param name The name of the Mesh
  117845. * @param material The material of the Mesh
  117846. * @param scene The Scene
  117847. * @param keepSubMeshes Specifies if submeshes should be kept
  117848. * @returns The new Mesh
  117849. */
  117850. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  117851. }
  117852. }
  117853. declare module BABYLON {
  117854. /**
  117855. * Class used to create a trail following a mesh
  117856. */
  117857. export class TrailMesh extends Mesh {
  117858. private _generator;
  117859. private _autoStart;
  117860. private _running;
  117861. private _diameter;
  117862. private _length;
  117863. private _sectionPolygonPointsCount;
  117864. private _sectionVectors;
  117865. private _sectionNormalVectors;
  117866. private _beforeRenderObserver;
  117867. /**
  117868. * @constructor
  117869. * @param name The value used by scene.getMeshByName() to do a lookup.
  117870. * @param generator The mesh to generate a trail.
  117871. * @param scene The scene to add this mesh to.
  117872. * @param diameter Diameter of trailing mesh. Default is 1.
  117873. * @param length Length of trailing mesh. Default is 60.
  117874. * @param autoStart Automatically start trailing mesh. Default true.
  117875. */
  117876. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  117877. /**
  117878. * "TrailMesh"
  117879. * @returns "TrailMesh"
  117880. */
  117881. getClassName(): string;
  117882. private _createMesh;
  117883. /**
  117884. * Start trailing mesh.
  117885. */
  117886. start(): void;
  117887. /**
  117888. * Stop trailing mesh.
  117889. */
  117890. stop(): void;
  117891. /**
  117892. * Update trailing mesh geometry.
  117893. */
  117894. update(): void;
  117895. /**
  117896. * Returns a new TrailMesh object.
  117897. * @param name is a string, the name given to the new mesh
  117898. * @param newGenerator use new generator object for cloned trail mesh
  117899. * @returns a new mesh
  117900. */
  117901. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117902. /**
  117903. * Serializes this trail mesh
  117904. * @param serializationObject object to write serialization to
  117905. */
  117906. serialize(serializationObject: any): void;
  117907. /**
  117908. * Parses a serialized trail mesh
  117909. * @param parsedMesh the serialized mesh
  117910. * @param scene the scene to create the trail mesh in
  117911. * @returns the created trail mesh
  117912. */
  117913. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117914. }
  117915. }
  117916. declare module BABYLON {
  117917. /**
  117918. * Class containing static functions to help procedurally build meshes
  117919. */
  117920. export class TiledBoxBuilder {
  117921. /**
  117922. * Creates a box mesh
  117923. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  117924. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117928. * @param name defines the name of the mesh
  117929. * @param options defines the options used to create the mesh
  117930. * @param scene defines the hosting scene
  117931. * @returns the box mesh
  117932. */
  117933. static CreateTiledBox(name: string, options: {
  117934. pattern?: number;
  117935. width?: number;
  117936. height?: number;
  117937. depth?: number;
  117938. tileSize?: number;
  117939. tileWidth?: number;
  117940. tileHeight?: number;
  117941. alignHorizontal?: number;
  117942. alignVertical?: number;
  117943. faceUV?: Vector4[];
  117944. faceColors?: Color4[];
  117945. sideOrientation?: number;
  117946. updatable?: boolean;
  117947. }, scene?: Nullable<Scene>): Mesh;
  117948. }
  117949. }
  117950. declare module BABYLON {
  117951. /**
  117952. * Class containing static functions to help procedurally build meshes
  117953. */
  117954. export class TorusKnotBuilder {
  117955. /**
  117956. * Creates a torus knot mesh
  117957. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117958. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117959. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117960. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117964. * @param name defines the name of the mesh
  117965. * @param options defines the options used to create the mesh
  117966. * @param scene defines the hosting scene
  117967. * @returns the torus knot mesh
  117968. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117969. */
  117970. static CreateTorusKnot(name: string, options: {
  117971. radius?: number;
  117972. tube?: number;
  117973. radialSegments?: number;
  117974. tubularSegments?: number;
  117975. p?: number;
  117976. q?: number;
  117977. updatable?: boolean;
  117978. sideOrientation?: number;
  117979. frontUVs?: Vector4;
  117980. backUVs?: Vector4;
  117981. }, scene: any): Mesh;
  117982. }
  117983. }
  117984. declare module BABYLON {
  117985. /**
  117986. * Polygon
  117987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117988. */
  117989. export class Polygon {
  117990. /**
  117991. * Creates a rectangle
  117992. * @param xmin bottom X coord
  117993. * @param ymin bottom Y coord
  117994. * @param xmax top X coord
  117995. * @param ymax top Y coord
  117996. * @returns points that make the resulting rectation
  117997. */
  117998. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117999. /**
  118000. * Creates a circle
  118001. * @param radius radius of circle
  118002. * @param cx scale in x
  118003. * @param cy scale in y
  118004. * @param numberOfSides number of sides that make up the circle
  118005. * @returns points that make the resulting circle
  118006. */
  118007. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  118008. /**
  118009. * Creates a polygon from input string
  118010. * @param input Input polygon data
  118011. * @returns the parsed points
  118012. */
  118013. static Parse(input: string): Vector2[];
  118014. /**
  118015. * Starts building a polygon from x and y coordinates
  118016. * @param x x coordinate
  118017. * @param y y coordinate
  118018. * @returns the started path2
  118019. */
  118020. static StartingAt(x: number, y: number): Path2;
  118021. }
  118022. /**
  118023. * Builds a polygon
  118024. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  118025. */
  118026. export class PolygonMeshBuilder {
  118027. private _points;
  118028. private _outlinepoints;
  118029. private _holes;
  118030. private _name;
  118031. private _scene;
  118032. private _epoints;
  118033. private _eholes;
  118034. private _addToepoint;
  118035. /**
  118036. * Babylon reference to the earcut plugin.
  118037. */
  118038. bjsEarcut: any;
  118039. /**
  118040. * Creates a PolygonMeshBuilder
  118041. * @param name name of the builder
  118042. * @param contours Path of the polygon
  118043. * @param scene scene to add to when creating the mesh
  118044. * @param earcutInjection can be used to inject your own earcut reference
  118045. */
  118046. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  118047. /**
  118048. * Adds a whole within the polygon
  118049. * @param hole Array of points defining the hole
  118050. * @returns this
  118051. */
  118052. addHole(hole: Vector2[]): PolygonMeshBuilder;
  118053. /**
  118054. * Creates the polygon
  118055. * @param updatable If the mesh should be updatable
  118056. * @param depth The depth of the mesh created
  118057. * @returns the created mesh
  118058. */
  118059. build(updatable?: boolean, depth?: number): Mesh;
  118060. /**
  118061. * Creates the polygon
  118062. * @param depth The depth of the mesh created
  118063. * @returns the created VertexData
  118064. */
  118065. buildVertexData(depth?: number): VertexData;
  118066. /**
  118067. * Adds a side to the polygon
  118068. * @param positions points that make the polygon
  118069. * @param normals normals of the polygon
  118070. * @param uvs uvs of the polygon
  118071. * @param indices indices of the polygon
  118072. * @param bounds bounds of the polygon
  118073. * @param points points of the polygon
  118074. * @param depth depth of the polygon
  118075. * @param flip flip of the polygon
  118076. */
  118077. private addSide;
  118078. }
  118079. }
  118080. declare module BABYLON {
  118081. /**
  118082. * Class containing static functions to help procedurally build meshes
  118083. */
  118084. export class PolygonBuilder {
  118085. /**
  118086. * Creates a polygon mesh
  118087. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118088. * * 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
  118089. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118092. * * Remember you can only change the shape positions, not their number when updating a polygon
  118093. * @param name defines the name of the mesh
  118094. * @param options defines the options used to create the mesh
  118095. * @param scene defines the hosting scene
  118096. * @param earcutInjection can be used to inject your own earcut reference
  118097. * @returns the polygon mesh
  118098. */
  118099. static CreatePolygon(name: string, options: {
  118100. shape: Vector3[];
  118101. holes?: Vector3[][];
  118102. depth?: number;
  118103. faceUV?: Vector4[];
  118104. faceColors?: Color4[];
  118105. updatable?: boolean;
  118106. sideOrientation?: number;
  118107. frontUVs?: Vector4;
  118108. backUVs?: Vector4;
  118109. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118110. /**
  118111. * Creates an extruded polygon mesh, with depth in the Y direction.
  118112. * * 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)
  118113. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118114. * @param name defines the name of the mesh
  118115. * @param options defines the options used to create the mesh
  118116. * @param scene defines the hosting scene
  118117. * @param earcutInjection can be used to inject your own earcut reference
  118118. * @returns the polygon mesh
  118119. */
  118120. static ExtrudePolygon(name: string, options: {
  118121. shape: Vector3[];
  118122. holes?: Vector3[][];
  118123. depth?: number;
  118124. faceUV?: Vector4[];
  118125. faceColors?: Color4[];
  118126. updatable?: boolean;
  118127. sideOrientation?: number;
  118128. frontUVs?: Vector4;
  118129. backUVs?: Vector4;
  118130. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118131. }
  118132. }
  118133. declare module BABYLON {
  118134. /**
  118135. * Class containing static functions to help procedurally build meshes
  118136. */
  118137. export class LatheBuilder {
  118138. /**
  118139. * Creates lathe mesh.
  118140. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118141. * * 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
  118142. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118143. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118144. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118145. * * 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
  118146. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118147. * * 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
  118148. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118149. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118150. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118152. * @param name defines the name of the mesh
  118153. * @param options defines the options used to create the mesh
  118154. * @param scene defines the hosting scene
  118155. * @returns the lathe mesh
  118156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118157. */
  118158. static CreateLathe(name: string, options: {
  118159. shape: Vector3[];
  118160. radius?: number;
  118161. tessellation?: number;
  118162. clip?: number;
  118163. arc?: number;
  118164. closed?: boolean;
  118165. updatable?: boolean;
  118166. sideOrientation?: number;
  118167. frontUVs?: Vector4;
  118168. backUVs?: Vector4;
  118169. cap?: number;
  118170. invertUV?: boolean;
  118171. }, scene?: Nullable<Scene>): Mesh;
  118172. }
  118173. }
  118174. declare module BABYLON {
  118175. /**
  118176. * Class containing static functions to help procedurally build meshes
  118177. */
  118178. export class TiledPlaneBuilder {
  118179. /**
  118180. * Creates a tiled plane mesh
  118181. * * The parameter `pattern` will, depending on value, do nothing or
  118182. * * * flip (reflect about central vertical) alternate tiles across and up
  118183. * * * flip every tile on alternate rows
  118184. * * * rotate (180 degs) alternate tiles across and up
  118185. * * * rotate every tile on alternate rows
  118186. * * * flip and rotate alternate tiles across and up
  118187. * * * flip and rotate every tile on alternate rows
  118188. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  118189. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  118190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118191. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118192. * * 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)
  118193. * * 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)
  118194. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118195. * @param name defines the name of the mesh
  118196. * @param options defines the options used to create the mesh
  118197. * @param scene defines the hosting scene
  118198. * @returns the box mesh
  118199. */
  118200. static CreateTiledPlane(name: string, options: {
  118201. pattern?: number;
  118202. tileSize?: number;
  118203. tileWidth?: number;
  118204. tileHeight?: number;
  118205. size?: number;
  118206. width?: number;
  118207. height?: number;
  118208. alignHorizontal?: number;
  118209. alignVertical?: number;
  118210. sideOrientation?: number;
  118211. frontUVs?: Vector4;
  118212. backUVs?: Vector4;
  118213. updatable?: boolean;
  118214. }, scene?: Nullable<Scene>): Mesh;
  118215. }
  118216. }
  118217. declare module BABYLON {
  118218. /**
  118219. * Class containing static functions to help procedurally build meshes
  118220. */
  118221. export class TubeBuilder {
  118222. /**
  118223. * Creates a tube mesh.
  118224. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118225. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118226. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118227. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118228. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118229. * * 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)
  118230. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118231. * * 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
  118232. * * 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
  118233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118237. * @param name defines the name of the mesh
  118238. * @param options defines the options used to create the mesh
  118239. * @param scene defines the hosting scene
  118240. * @returns the tube mesh
  118241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118242. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118243. */
  118244. static CreateTube(name: string, options: {
  118245. path: Vector3[];
  118246. radius?: number;
  118247. tessellation?: number;
  118248. radiusFunction?: {
  118249. (i: number, distance: number): number;
  118250. };
  118251. cap?: number;
  118252. arc?: number;
  118253. updatable?: boolean;
  118254. sideOrientation?: number;
  118255. frontUVs?: Vector4;
  118256. backUVs?: Vector4;
  118257. instance?: Mesh;
  118258. invertUV?: boolean;
  118259. }, scene?: Nullable<Scene>): Mesh;
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /**
  118264. * Class containing static functions to help procedurally build meshes
  118265. */
  118266. export class IcoSphereBuilder {
  118267. /**
  118268. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118269. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118270. * * 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`)
  118271. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118272. * * 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
  118273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118276. * @param name defines the name of the mesh
  118277. * @param options defines the options used to create the mesh
  118278. * @param scene defines the hosting scene
  118279. * @returns the icosahedron mesh
  118280. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118281. */
  118282. static CreateIcoSphere(name: string, options: {
  118283. radius?: number;
  118284. radiusX?: number;
  118285. radiusY?: number;
  118286. radiusZ?: number;
  118287. flat?: boolean;
  118288. subdivisions?: number;
  118289. sideOrientation?: number;
  118290. frontUVs?: Vector4;
  118291. backUVs?: Vector4;
  118292. updatable?: boolean;
  118293. }, scene?: Nullable<Scene>): Mesh;
  118294. }
  118295. }
  118296. declare module BABYLON {
  118297. /**
  118298. * Class containing static functions to help procedurally build meshes
  118299. */
  118300. export class DecalBuilder {
  118301. /**
  118302. * Creates a decal mesh.
  118303. * 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
  118304. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118305. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118306. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118307. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118308. * @param name defines the name of the mesh
  118309. * @param sourceMesh defines the mesh where the decal must be applied
  118310. * @param options defines the options used to create the mesh
  118311. * @param scene defines the hosting scene
  118312. * @returns the decal mesh
  118313. * @see https://doc.babylonjs.com/how_to/decals
  118314. */
  118315. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118316. position?: Vector3;
  118317. normal?: Vector3;
  118318. size?: Vector3;
  118319. angle?: number;
  118320. }): Mesh;
  118321. }
  118322. }
  118323. declare module BABYLON {
  118324. /**
  118325. * Class containing static functions to help procedurally build meshes
  118326. */
  118327. export class MeshBuilder {
  118328. /**
  118329. * Creates a box mesh
  118330. * * The parameter `size` sets the size (float) of each box side (default 1)
  118331. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  118332. * * 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)
  118333. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118337. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  118338. * @param name defines the name of the mesh
  118339. * @param options defines the options used to create the mesh
  118340. * @param scene defines the hosting scene
  118341. * @returns the box mesh
  118342. */
  118343. static CreateBox(name: string, options: {
  118344. size?: number;
  118345. width?: number;
  118346. height?: number;
  118347. depth?: number;
  118348. faceUV?: Vector4[];
  118349. faceColors?: Color4[];
  118350. sideOrientation?: number;
  118351. frontUVs?: Vector4;
  118352. backUVs?: Vector4;
  118353. updatable?: boolean;
  118354. }, scene?: Nullable<Scene>): Mesh;
  118355. /**
  118356. * Creates a tiled box mesh
  118357. * * faceTiles sets the pattern, tile size and number of tiles for a face
  118358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118359. * @param name defines the name of the mesh
  118360. * @param options defines the options used to create the mesh
  118361. * @param scene defines the hosting scene
  118362. * @returns the tiled box mesh
  118363. */
  118364. static CreateTiledBox(name: string, options: {
  118365. pattern?: number;
  118366. size?: number;
  118367. width?: number;
  118368. height?: number;
  118369. depth: number;
  118370. tileSize?: number;
  118371. tileWidth?: number;
  118372. tileHeight?: number;
  118373. faceUV?: Vector4[];
  118374. faceColors?: Color4[];
  118375. alignHorizontal?: number;
  118376. alignVertical?: number;
  118377. sideOrientation?: number;
  118378. updatable?: boolean;
  118379. }, scene?: Nullable<Scene>): Mesh;
  118380. /**
  118381. * Creates a sphere mesh
  118382. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118383. * * 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`)
  118384. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118385. * * 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
  118386. * * 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)
  118387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118390. * @param name defines the name of the mesh
  118391. * @param options defines the options used to create the mesh
  118392. * @param scene defines the hosting scene
  118393. * @returns the sphere mesh
  118394. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118395. */
  118396. static CreateSphere(name: string, options: {
  118397. segments?: number;
  118398. diameter?: number;
  118399. diameterX?: number;
  118400. diameterY?: number;
  118401. diameterZ?: number;
  118402. arc?: number;
  118403. slice?: number;
  118404. sideOrientation?: number;
  118405. frontUVs?: Vector4;
  118406. backUVs?: Vector4;
  118407. updatable?: boolean;
  118408. }, scene?: Nullable<Scene>): Mesh;
  118409. /**
  118410. * Creates a plane polygonal mesh. By default, this is a disc
  118411. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  118412. * * 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
  118413. * * 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
  118414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118417. * @param name defines the name of the mesh
  118418. * @param options defines the options used to create the mesh
  118419. * @param scene defines the hosting scene
  118420. * @returns the plane polygonal mesh
  118421. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  118422. */
  118423. static CreateDisc(name: string, options: {
  118424. radius?: number;
  118425. tessellation?: number;
  118426. arc?: number;
  118427. updatable?: boolean;
  118428. sideOrientation?: number;
  118429. frontUVs?: Vector4;
  118430. backUVs?: Vector4;
  118431. }, scene?: Nullable<Scene>): Mesh;
  118432. /**
  118433. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  118434. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  118435. * * 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`)
  118436. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  118437. * * 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
  118438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118441. * @param name defines the name of the mesh
  118442. * @param options defines the options used to create the mesh
  118443. * @param scene defines the hosting scene
  118444. * @returns the icosahedron mesh
  118445. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  118446. */
  118447. static CreateIcoSphere(name: string, options: {
  118448. radius?: number;
  118449. radiusX?: number;
  118450. radiusY?: number;
  118451. radiusZ?: number;
  118452. flat?: boolean;
  118453. subdivisions?: number;
  118454. sideOrientation?: number;
  118455. frontUVs?: Vector4;
  118456. backUVs?: Vector4;
  118457. updatable?: boolean;
  118458. }, scene?: Nullable<Scene>): Mesh;
  118459. /**
  118460. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118461. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  118462. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  118463. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  118464. * * 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
  118465. * * 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
  118466. * * 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
  118467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118470. * * 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
  118471. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  118472. * * 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
  118473. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  118474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118475. * @param name defines the name of the mesh
  118476. * @param options defines the options used to create the mesh
  118477. * @param scene defines the hosting scene
  118478. * @returns the ribbon mesh
  118479. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  118480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118481. */
  118482. static CreateRibbon(name: string, options: {
  118483. pathArray: Vector3[][];
  118484. closeArray?: boolean;
  118485. closePath?: boolean;
  118486. offset?: number;
  118487. updatable?: boolean;
  118488. sideOrientation?: number;
  118489. frontUVs?: Vector4;
  118490. backUVs?: Vector4;
  118491. instance?: Mesh;
  118492. invertUV?: boolean;
  118493. uvs?: Vector2[];
  118494. colors?: Color4[];
  118495. }, scene?: Nullable<Scene>): Mesh;
  118496. /**
  118497. * Creates a cylinder or a cone mesh
  118498. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  118499. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  118500. * * 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.
  118501. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  118502. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  118503. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  118504. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  118505. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  118506. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  118507. * * 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).
  118508. * * 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
  118509. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  118510. * * 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
  118511. * * 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.
  118512. * * If `enclose` is false, a ring surface is one element.
  118513. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  118514. * * 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
  118515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118518. * @param name defines the name of the mesh
  118519. * @param options defines the options used to create the mesh
  118520. * @param scene defines the hosting scene
  118521. * @returns the cylinder mesh
  118522. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  118523. */
  118524. static CreateCylinder(name: string, options: {
  118525. height?: number;
  118526. diameterTop?: number;
  118527. diameterBottom?: number;
  118528. diameter?: number;
  118529. tessellation?: number;
  118530. subdivisions?: number;
  118531. arc?: number;
  118532. faceColors?: Color4[];
  118533. faceUV?: Vector4[];
  118534. updatable?: boolean;
  118535. hasRings?: boolean;
  118536. enclose?: boolean;
  118537. cap?: number;
  118538. sideOrientation?: number;
  118539. frontUVs?: Vector4;
  118540. backUVs?: Vector4;
  118541. }, scene?: Nullable<Scene>): Mesh;
  118542. /**
  118543. * Creates a torus mesh
  118544. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  118545. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  118546. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  118547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118550. * @param name defines the name of the mesh
  118551. * @param options defines the options used to create the mesh
  118552. * @param scene defines the hosting scene
  118553. * @returns the torus mesh
  118554. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  118555. */
  118556. static CreateTorus(name: string, options: {
  118557. diameter?: number;
  118558. thickness?: number;
  118559. tessellation?: number;
  118560. updatable?: boolean;
  118561. sideOrientation?: number;
  118562. frontUVs?: Vector4;
  118563. backUVs?: Vector4;
  118564. }, scene?: Nullable<Scene>): Mesh;
  118565. /**
  118566. * Creates a torus knot mesh
  118567. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  118568. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  118569. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  118570. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  118571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118574. * @param name defines the name of the mesh
  118575. * @param options defines the options used to create the mesh
  118576. * @param scene defines the hosting scene
  118577. * @returns the torus knot mesh
  118578. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  118579. */
  118580. static CreateTorusKnot(name: string, options: {
  118581. radius?: number;
  118582. tube?: number;
  118583. radialSegments?: number;
  118584. tubularSegments?: number;
  118585. p?: number;
  118586. q?: number;
  118587. updatable?: boolean;
  118588. sideOrientation?: number;
  118589. frontUVs?: Vector4;
  118590. backUVs?: Vector4;
  118591. }, scene?: Nullable<Scene>): Mesh;
  118592. /**
  118593. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118594. * * 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
  118595. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118596. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118597. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118598. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118599. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118600. * * 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
  118601. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118604. * @param name defines the name of the new line system
  118605. * @param options defines the options used to create the line system
  118606. * @param scene defines the hosting scene
  118607. * @returns a new line system mesh
  118608. */
  118609. static CreateLineSystem(name: string, options: {
  118610. lines: Vector3[][];
  118611. updatable?: boolean;
  118612. instance?: Nullable<LinesMesh>;
  118613. colors?: Nullable<Color4[][]>;
  118614. useVertexAlpha?: boolean;
  118615. }, scene: Nullable<Scene>): LinesMesh;
  118616. /**
  118617. * Creates a line mesh
  118618. * 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
  118619. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118620. * * The parameter `points` is an array successive Vector3
  118621. * * 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
  118622. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118623. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118624. * * When updating an instance, remember that only point positions can change, not the number of points
  118625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118627. * @param name defines the name of the new line system
  118628. * @param options defines the options used to create the line system
  118629. * @param scene defines the hosting scene
  118630. * @returns a new line mesh
  118631. */
  118632. static CreateLines(name: string, options: {
  118633. points: Vector3[];
  118634. updatable?: boolean;
  118635. instance?: Nullable<LinesMesh>;
  118636. colors?: Color4[];
  118637. useVertexAlpha?: boolean;
  118638. }, scene?: Nullable<Scene>): LinesMesh;
  118639. /**
  118640. * Creates a dashed line mesh
  118641. * * 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
  118642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118643. * * The parameter `points` is an array successive Vector3
  118644. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118645. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118646. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118647. * * 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
  118648. * * When updating an instance, remember that only point positions can change, not the number of points
  118649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118650. * @param name defines the name of the mesh
  118651. * @param options defines the options used to create the mesh
  118652. * @param scene defines the hosting scene
  118653. * @returns the dashed line mesh
  118654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118655. */
  118656. static CreateDashedLines(name: string, options: {
  118657. points: Vector3[];
  118658. dashSize?: number;
  118659. gapSize?: number;
  118660. dashNb?: number;
  118661. updatable?: boolean;
  118662. instance?: LinesMesh;
  118663. }, scene?: Nullable<Scene>): LinesMesh;
  118664. /**
  118665. * 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.
  118666. * * 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.
  118667. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118668. * * 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.
  118669. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118670. * * 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
  118671. * * 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
  118672. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118677. * @param name defines the name of the mesh
  118678. * @param options defines the options used to create the mesh
  118679. * @param scene defines the hosting scene
  118680. * @returns the extruded shape mesh
  118681. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118683. */
  118684. static ExtrudeShape(name: string, options: {
  118685. shape: Vector3[];
  118686. path: Vector3[];
  118687. scale?: number;
  118688. rotation?: number;
  118689. cap?: number;
  118690. updatable?: boolean;
  118691. sideOrientation?: number;
  118692. frontUVs?: Vector4;
  118693. backUVs?: Vector4;
  118694. instance?: Mesh;
  118695. invertUV?: boolean;
  118696. }, scene?: Nullable<Scene>): Mesh;
  118697. /**
  118698. * Creates an custom extruded shape mesh.
  118699. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118700. * * 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.
  118701. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118702. * * 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
  118703. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118704. * * 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
  118705. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118706. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118707. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118708. * * 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
  118709. * * 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
  118710. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118715. * @param name defines the name of the mesh
  118716. * @param options defines the options used to create the mesh
  118717. * @param scene defines the hosting scene
  118718. * @returns the custom extruded shape mesh
  118719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118722. */
  118723. static ExtrudeShapeCustom(name: string, options: {
  118724. shape: Vector3[];
  118725. path: Vector3[];
  118726. scaleFunction?: any;
  118727. rotationFunction?: any;
  118728. ribbonCloseArray?: boolean;
  118729. ribbonClosePath?: boolean;
  118730. cap?: number;
  118731. updatable?: boolean;
  118732. sideOrientation?: number;
  118733. frontUVs?: Vector4;
  118734. backUVs?: Vector4;
  118735. instance?: Mesh;
  118736. invertUV?: boolean;
  118737. }, scene?: Nullable<Scene>): Mesh;
  118738. /**
  118739. * Creates lathe mesh.
  118740. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118741. * * 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
  118742. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118743. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118744. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118745. * * 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
  118746. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118747. * * 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
  118748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118752. * @param name defines the name of the mesh
  118753. * @param options defines the options used to create the mesh
  118754. * @param scene defines the hosting scene
  118755. * @returns the lathe mesh
  118756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118757. */
  118758. static CreateLathe(name: string, options: {
  118759. shape: Vector3[];
  118760. radius?: number;
  118761. tessellation?: number;
  118762. clip?: number;
  118763. arc?: number;
  118764. closed?: boolean;
  118765. updatable?: boolean;
  118766. sideOrientation?: number;
  118767. frontUVs?: Vector4;
  118768. backUVs?: Vector4;
  118769. cap?: number;
  118770. invertUV?: boolean;
  118771. }, scene?: Nullable<Scene>): Mesh;
  118772. /**
  118773. * Creates a tiled plane mesh
  118774. * * You can set a limited pattern arrangement with the tiles
  118775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118778. * @param name defines the name of the mesh
  118779. * @param options defines the options used to create the mesh
  118780. * @param scene defines the hosting scene
  118781. * @returns the plane mesh
  118782. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118783. */
  118784. static CreateTiledPlane(name: string, options: {
  118785. pattern?: number;
  118786. tileSize?: number;
  118787. tileWidth?: number;
  118788. tileHeight?: number;
  118789. size?: number;
  118790. width?: number;
  118791. height?: number;
  118792. alignHorizontal?: number;
  118793. alignVertical?: number;
  118794. sideOrientation?: number;
  118795. frontUVs?: Vector4;
  118796. backUVs?: Vector4;
  118797. updatable?: boolean;
  118798. }, scene?: Nullable<Scene>): Mesh;
  118799. /**
  118800. * Creates a plane mesh
  118801. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  118802. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  118803. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  118804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118807. * @param name defines the name of the mesh
  118808. * @param options defines the options used to create the mesh
  118809. * @param scene defines the hosting scene
  118810. * @returns the plane mesh
  118811. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118812. */
  118813. static CreatePlane(name: string, options: {
  118814. size?: number;
  118815. width?: number;
  118816. height?: number;
  118817. sideOrientation?: number;
  118818. frontUVs?: Vector4;
  118819. backUVs?: Vector4;
  118820. updatable?: boolean;
  118821. sourcePlane?: Plane;
  118822. }, scene?: Nullable<Scene>): Mesh;
  118823. /**
  118824. * Creates a ground mesh
  118825. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118826. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118828. * @param name defines the name of the mesh
  118829. * @param options defines the options used to create the mesh
  118830. * @param scene defines the hosting scene
  118831. * @returns the ground mesh
  118832. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118833. */
  118834. static CreateGround(name: string, options: {
  118835. width?: number;
  118836. height?: number;
  118837. subdivisions?: number;
  118838. subdivisionsX?: number;
  118839. subdivisionsY?: number;
  118840. updatable?: boolean;
  118841. }, scene?: Nullable<Scene>): Mesh;
  118842. /**
  118843. * Creates a tiled ground mesh
  118844. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118845. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118846. * * 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
  118847. * * 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
  118848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118849. * @param name defines the name of the mesh
  118850. * @param options defines the options used to create the mesh
  118851. * @param scene defines the hosting scene
  118852. * @returns the tiled ground mesh
  118853. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118854. */
  118855. static CreateTiledGround(name: string, options: {
  118856. xmin: number;
  118857. zmin: number;
  118858. xmax: number;
  118859. zmax: number;
  118860. subdivisions?: {
  118861. w: number;
  118862. h: number;
  118863. };
  118864. precision?: {
  118865. w: number;
  118866. h: number;
  118867. };
  118868. updatable?: boolean;
  118869. }, scene?: Nullable<Scene>): Mesh;
  118870. /**
  118871. * Creates a ground mesh from a height map
  118872. * * The parameter `url` sets the URL of the height map image resource.
  118873. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118874. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118875. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118876. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118877. * * 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.
  118878. * * 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).
  118879. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118880. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118881. * @param name defines the name of the mesh
  118882. * @param url defines the url to the height map
  118883. * @param options defines the options used to create the mesh
  118884. * @param scene defines the hosting scene
  118885. * @returns the ground mesh
  118886. * @see https://doc.babylonjs.com/babylon101/height_map
  118887. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118888. */
  118889. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118890. width?: number;
  118891. height?: number;
  118892. subdivisions?: number;
  118893. minHeight?: number;
  118894. maxHeight?: number;
  118895. colorFilter?: Color3;
  118896. alphaFilter?: number;
  118897. updatable?: boolean;
  118898. onReady?: (mesh: GroundMesh) => void;
  118899. }, scene?: Nullable<Scene>): GroundMesh;
  118900. /**
  118901. * Creates a polygon mesh
  118902. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118903. * * 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
  118904. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118907. * * Remember you can only change the shape positions, not their number when updating a polygon
  118908. * @param name defines the name of the mesh
  118909. * @param options defines the options used to create the mesh
  118910. * @param scene defines the hosting scene
  118911. * @param earcutInjection can be used to inject your own earcut reference
  118912. * @returns the polygon mesh
  118913. */
  118914. static CreatePolygon(name: string, options: {
  118915. shape: Vector3[];
  118916. holes?: Vector3[][];
  118917. depth?: number;
  118918. faceUV?: Vector4[];
  118919. faceColors?: Color4[];
  118920. updatable?: boolean;
  118921. sideOrientation?: number;
  118922. frontUVs?: Vector4;
  118923. backUVs?: Vector4;
  118924. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118925. /**
  118926. * Creates an extruded polygon mesh, with depth in the Y direction.
  118927. * * 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)
  118928. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118929. * @param name defines the name of the mesh
  118930. * @param options defines the options used to create the mesh
  118931. * @param scene defines the hosting scene
  118932. * @param earcutInjection can be used to inject your own earcut reference
  118933. * @returns the polygon mesh
  118934. */
  118935. static ExtrudePolygon(name: string, options: {
  118936. shape: Vector3[];
  118937. holes?: Vector3[][];
  118938. depth?: number;
  118939. faceUV?: Vector4[];
  118940. faceColors?: Color4[];
  118941. updatable?: boolean;
  118942. sideOrientation?: number;
  118943. frontUVs?: Vector4;
  118944. backUVs?: Vector4;
  118945. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118946. /**
  118947. * Creates a tube mesh.
  118948. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118949. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118950. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118951. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118952. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118953. * * 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)
  118954. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118955. * * 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
  118956. * * 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
  118957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118959. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118961. * @param name defines the name of the mesh
  118962. * @param options defines the options used to create the mesh
  118963. * @param scene defines the hosting scene
  118964. * @returns the tube mesh
  118965. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118966. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118967. */
  118968. static CreateTube(name: string, options: {
  118969. path: Vector3[];
  118970. radius?: number;
  118971. tessellation?: number;
  118972. radiusFunction?: {
  118973. (i: number, distance: number): number;
  118974. };
  118975. cap?: number;
  118976. arc?: number;
  118977. updatable?: boolean;
  118978. sideOrientation?: number;
  118979. frontUVs?: Vector4;
  118980. backUVs?: Vector4;
  118981. instance?: Mesh;
  118982. invertUV?: boolean;
  118983. }, scene?: Nullable<Scene>): Mesh;
  118984. /**
  118985. * Creates a polyhedron mesh
  118986. * * 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
  118987. * * The parameter `size` (positive float, default 1) sets the polygon size
  118988. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118989. * * 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`
  118990. * * 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
  118991. * * 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)`)
  118992. * * 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
  118993. * * 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
  118994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118997. * @param name defines the name of the mesh
  118998. * @param options defines the options used to create the mesh
  118999. * @param scene defines the hosting scene
  119000. * @returns the polyhedron mesh
  119001. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119002. */
  119003. static CreatePolyhedron(name: string, options: {
  119004. type?: number;
  119005. size?: number;
  119006. sizeX?: number;
  119007. sizeY?: number;
  119008. sizeZ?: number;
  119009. custom?: any;
  119010. faceUV?: Vector4[];
  119011. faceColors?: Color4[];
  119012. flat?: boolean;
  119013. updatable?: boolean;
  119014. sideOrientation?: number;
  119015. frontUVs?: Vector4;
  119016. backUVs?: Vector4;
  119017. }, scene?: Nullable<Scene>): Mesh;
  119018. /**
  119019. * Creates a decal mesh.
  119020. * 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
  119021. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  119022. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  119023. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  119024. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  119025. * @param name defines the name of the mesh
  119026. * @param sourceMesh defines the mesh where the decal must be applied
  119027. * @param options defines the options used to create the mesh
  119028. * @param scene defines the hosting scene
  119029. * @returns the decal mesh
  119030. * @see https://doc.babylonjs.com/how_to/decals
  119031. */
  119032. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  119033. position?: Vector3;
  119034. normal?: Vector3;
  119035. size?: Vector3;
  119036. angle?: number;
  119037. }): Mesh;
  119038. }
  119039. }
  119040. declare module BABYLON {
  119041. /**
  119042. * A simplifier interface for future simplification implementations
  119043. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119044. */
  119045. export interface ISimplifier {
  119046. /**
  119047. * Simplification of a given mesh according to the given settings.
  119048. * Since this requires computation, it is assumed that the function runs async.
  119049. * @param settings The settings of the simplification, including quality and distance
  119050. * @param successCallback A callback that will be called after the mesh was simplified.
  119051. * @param errorCallback in case of an error, this callback will be called. optional.
  119052. */
  119053. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  119054. }
  119055. /**
  119056. * Expected simplification settings.
  119057. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  119058. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119059. */
  119060. export interface ISimplificationSettings {
  119061. /**
  119062. * Gets or sets the expected quality
  119063. */
  119064. quality: number;
  119065. /**
  119066. * Gets or sets the distance when this optimized version should be used
  119067. */
  119068. distance: number;
  119069. /**
  119070. * Gets an already optimized mesh
  119071. */
  119072. optimizeMesh?: boolean;
  119073. }
  119074. /**
  119075. * Class used to specify simplification options
  119076. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119077. */
  119078. export class SimplificationSettings implements ISimplificationSettings {
  119079. /** expected quality */
  119080. quality: number;
  119081. /** distance when this optimized version should be used */
  119082. distance: number;
  119083. /** already optimized mesh */
  119084. optimizeMesh?: boolean | undefined;
  119085. /**
  119086. * Creates a SimplificationSettings
  119087. * @param quality expected quality
  119088. * @param distance distance when this optimized version should be used
  119089. * @param optimizeMesh already optimized mesh
  119090. */
  119091. constructor(
  119092. /** expected quality */
  119093. quality: number,
  119094. /** distance when this optimized version should be used */
  119095. distance: number,
  119096. /** already optimized mesh */
  119097. optimizeMesh?: boolean | undefined);
  119098. }
  119099. /**
  119100. * Interface used to define a simplification task
  119101. */
  119102. export interface ISimplificationTask {
  119103. /**
  119104. * Array of settings
  119105. */
  119106. settings: Array<ISimplificationSettings>;
  119107. /**
  119108. * Simplification type
  119109. */
  119110. simplificationType: SimplificationType;
  119111. /**
  119112. * Mesh to simplify
  119113. */
  119114. mesh: Mesh;
  119115. /**
  119116. * Callback called on success
  119117. */
  119118. successCallback?: () => void;
  119119. /**
  119120. * Defines if parallel processing can be used
  119121. */
  119122. parallelProcessing: boolean;
  119123. }
  119124. /**
  119125. * Queue used to order the simplification tasks
  119126. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119127. */
  119128. export class SimplificationQueue {
  119129. private _simplificationArray;
  119130. /**
  119131. * Gets a boolean indicating that the process is still running
  119132. */
  119133. running: boolean;
  119134. /**
  119135. * Creates a new queue
  119136. */
  119137. constructor();
  119138. /**
  119139. * Adds a new simplification task
  119140. * @param task defines a task to add
  119141. */
  119142. addTask(task: ISimplificationTask): void;
  119143. /**
  119144. * Execute next task
  119145. */
  119146. executeNext(): void;
  119147. /**
  119148. * Execute a simplification task
  119149. * @param task defines the task to run
  119150. */
  119151. runSimplification(task: ISimplificationTask): void;
  119152. private getSimplifier;
  119153. }
  119154. /**
  119155. * The implemented types of simplification
  119156. * At the moment only Quadratic Error Decimation is implemented
  119157. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119158. */
  119159. export enum SimplificationType {
  119160. /** Quadratic error decimation */
  119161. QUADRATIC = 0
  119162. }
  119163. }
  119164. declare module BABYLON {
  119165. interface Scene {
  119166. /** @hidden (Backing field) */
  119167. _simplificationQueue: SimplificationQueue;
  119168. /**
  119169. * Gets or sets the simplification queue attached to the scene
  119170. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  119171. */
  119172. simplificationQueue: SimplificationQueue;
  119173. }
  119174. interface Mesh {
  119175. /**
  119176. * Simplify the mesh according to the given array of settings.
  119177. * Function will return immediately and will simplify async
  119178. * @param settings a collection of simplification settings
  119179. * @param parallelProcessing should all levels calculate parallel or one after the other
  119180. * @param simplificationType the type of simplification to run
  119181. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  119182. * @returns the current mesh
  119183. */
  119184. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  119185. }
  119186. /**
  119187. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  119188. * created in a scene
  119189. */
  119190. export class SimplicationQueueSceneComponent implements ISceneComponent {
  119191. /**
  119192. * The component name helpfull to identify the component in the list of scene components.
  119193. */
  119194. readonly name: string;
  119195. /**
  119196. * The scene the component belongs to.
  119197. */
  119198. scene: Scene;
  119199. /**
  119200. * Creates a new instance of the component for the given scene
  119201. * @param scene Defines the scene to register the component in
  119202. */
  119203. constructor(scene: Scene);
  119204. /**
  119205. * Registers the component in a given scene
  119206. */
  119207. register(): void;
  119208. /**
  119209. * Rebuilds the elements related to this component in case of
  119210. * context lost for instance.
  119211. */
  119212. rebuild(): void;
  119213. /**
  119214. * Disposes the component and the associated ressources
  119215. */
  119216. dispose(): void;
  119217. private _beforeCameraUpdate;
  119218. }
  119219. }
  119220. declare module BABYLON {
  119221. /**
  119222. * Navigation plugin interface to add navigation constrained by a navigation mesh
  119223. */
  119224. export interface INavigationEnginePlugin {
  119225. /**
  119226. * plugin name
  119227. */
  119228. name: string;
  119229. /**
  119230. * Creates a navigation mesh
  119231. * @param meshes array of all the geometry used to compute the navigatio mesh
  119232. * @param parameters bunch of parameters used to filter geometry
  119233. */
  119234. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119235. /**
  119236. * Create a navigation mesh debug mesh
  119237. * @param scene is where the mesh will be added
  119238. * @returns debug display mesh
  119239. */
  119240. createDebugNavMesh(scene: Scene): Mesh;
  119241. /**
  119242. * Get a navigation mesh constrained position, closest to the parameter position
  119243. * @param position world position
  119244. * @returns the closest point to position constrained by the navigation mesh
  119245. */
  119246. getClosestPoint(position: Vector3): Vector3;
  119247. /**
  119248. * Get a navigation mesh constrained position, within a particular radius
  119249. * @param position world position
  119250. * @param maxRadius the maximum distance to the constrained world position
  119251. * @returns the closest point to position constrained by the navigation mesh
  119252. */
  119253. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119254. /**
  119255. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119256. * @param start world position
  119257. * @param end world position
  119258. * @returns array containing world position composing the path
  119259. */
  119260. computePath(start: Vector3, end: Vector3): Vector3[];
  119261. /**
  119262. * If this plugin is supported
  119263. * @returns true if plugin is supported
  119264. */
  119265. isSupported(): boolean;
  119266. /**
  119267. * Create a new Crowd so you can add agents
  119268. * @param maxAgents the maximum agent count in the crowd
  119269. * @param maxAgentRadius the maximum radius an agent can have
  119270. * @param scene to attach the crowd to
  119271. * @returns the crowd you can add agents to
  119272. */
  119273. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119274. /**
  119275. * Release all resources
  119276. */
  119277. dispose(): void;
  119278. }
  119279. /**
  119280. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  119281. */
  119282. export interface ICrowd {
  119283. /**
  119284. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119285. * You can attach anything to that node. The node position is updated in the scene update tick.
  119286. * @param pos world position that will be constrained by the navigation mesh
  119287. * @param parameters agent parameters
  119288. * @param transform hooked to the agent that will be update by the scene
  119289. * @returns agent index
  119290. */
  119291. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119292. /**
  119293. * Returns the agent position in world space
  119294. * @param index agent index returned by addAgent
  119295. * @returns world space position
  119296. */
  119297. getAgentPosition(index: number): Vector3;
  119298. /**
  119299. * Gets the agent velocity in world space
  119300. * @param index agent index returned by addAgent
  119301. * @returns world space velocity
  119302. */
  119303. getAgentVelocity(index: number): Vector3;
  119304. /**
  119305. * remove a particular agent previously created
  119306. * @param index agent index returned by addAgent
  119307. */
  119308. removeAgent(index: number): void;
  119309. /**
  119310. * get the list of all agents attached to this crowd
  119311. * @returns list of agent indices
  119312. */
  119313. getAgents(): number[];
  119314. /**
  119315. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119316. * @param deltaTime in seconds
  119317. */
  119318. update(deltaTime: number): void;
  119319. /**
  119320. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119321. * @param index agent index returned by addAgent
  119322. * @param destination targeted world position
  119323. */
  119324. agentGoto(index: number, destination: Vector3): void;
  119325. /**
  119326. * Release all resources
  119327. */
  119328. dispose(): void;
  119329. }
  119330. /**
  119331. * Configures an agent
  119332. */
  119333. export interface IAgentParameters {
  119334. /**
  119335. * Agent radius. [Limit: >= 0]
  119336. */
  119337. radius: number;
  119338. /**
  119339. * Agent height. [Limit: > 0]
  119340. */
  119341. height: number;
  119342. /**
  119343. * Maximum allowed acceleration. [Limit: >= 0]
  119344. */
  119345. maxAcceleration: number;
  119346. /**
  119347. * Maximum allowed speed. [Limit: >= 0]
  119348. */
  119349. maxSpeed: number;
  119350. /**
  119351. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  119352. */
  119353. collisionQueryRange: number;
  119354. /**
  119355. * The path visibility optimization range. [Limit: > 0]
  119356. */
  119357. pathOptimizationRange: number;
  119358. /**
  119359. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  119360. */
  119361. separationWeight: number;
  119362. }
  119363. /**
  119364. * Configures the navigation mesh creation
  119365. */
  119366. export interface INavMeshParameters {
  119367. /**
  119368. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  119369. */
  119370. cs: number;
  119371. /**
  119372. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  119373. */
  119374. ch: number;
  119375. /**
  119376. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  119377. */
  119378. walkableSlopeAngle: number;
  119379. /**
  119380. * Minimum floor to 'ceiling' height that will still allow the floor area to
  119381. * be considered walkable. [Limit: >= 3] [Units: vx]
  119382. */
  119383. walkableHeight: number;
  119384. /**
  119385. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  119386. */
  119387. walkableClimb: number;
  119388. /**
  119389. * The distance to erode/shrink the walkable area of the heightfield away from
  119390. * obstructions. [Limit: >=0] [Units: vx]
  119391. */
  119392. walkableRadius: number;
  119393. /**
  119394. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  119395. */
  119396. maxEdgeLen: number;
  119397. /**
  119398. * The maximum distance a simplfied contour's border edges should deviate
  119399. * the original raw contour. [Limit: >=0] [Units: vx]
  119400. */
  119401. maxSimplificationError: number;
  119402. /**
  119403. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  119404. */
  119405. minRegionArea: number;
  119406. /**
  119407. * Any regions with a span count smaller than this value will, if possible,
  119408. * be merged with larger regions. [Limit: >=0] [Units: vx]
  119409. */
  119410. mergeRegionArea: number;
  119411. /**
  119412. * The maximum number of vertices allowed for polygons generated during the
  119413. * contour to polygon conversion process. [Limit: >= 3]
  119414. */
  119415. maxVertsPerPoly: number;
  119416. /**
  119417. * Sets the sampling distance to use when generating the detail mesh.
  119418. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  119419. */
  119420. detailSampleDist: number;
  119421. /**
  119422. * The maximum distance the detail mesh surface should deviate from heightfield
  119423. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  119424. */
  119425. detailSampleMaxError: number;
  119426. }
  119427. }
  119428. declare module BABYLON {
  119429. /**
  119430. * RecastJS navigation plugin
  119431. */
  119432. export class RecastJSPlugin implements INavigationEnginePlugin {
  119433. /**
  119434. * Reference to the Recast library
  119435. */
  119436. bjsRECAST: any;
  119437. /**
  119438. * plugin name
  119439. */
  119440. name: string;
  119441. /**
  119442. * the first navmesh created. We might extend this to support multiple navmeshes
  119443. */
  119444. navMesh: any;
  119445. /**
  119446. * Initializes the recastJS plugin
  119447. * @param recastInjection can be used to inject your own recast reference
  119448. */
  119449. constructor(recastInjection?: any);
  119450. /**
  119451. * Creates a navigation mesh
  119452. * @param meshes array of all the geometry used to compute the navigatio mesh
  119453. * @param parameters bunch of parameters used to filter geometry
  119454. */
  119455. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  119456. /**
  119457. * Create a navigation mesh debug mesh
  119458. * @param scene is where the mesh will be added
  119459. * @returns debug display mesh
  119460. */
  119461. createDebugNavMesh(scene: Scene): Mesh;
  119462. /**
  119463. * Get a navigation mesh constrained position, closest to the parameter position
  119464. * @param position world position
  119465. * @returns the closest point to position constrained by the navigation mesh
  119466. */
  119467. getClosestPoint(position: Vector3): Vector3;
  119468. /**
  119469. * Get a navigation mesh constrained position, within a particular radius
  119470. * @param position world position
  119471. * @param maxRadius the maximum distance to the constrained world position
  119472. * @returns the closest point to position constrained by the navigation mesh
  119473. */
  119474. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  119475. /**
  119476. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  119477. * @param start world position
  119478. * @param end world position
  119479. * @returns array containing world position composing the path
  119480. */
  119481. computePath(start: Vector3, end: Vector3): Vector3[];
  119482. /**
  119483. * Create a new Crowd so you can add agents
  119484. * @param maxAgents the maximum agent count in the crowd
  119485. * @param maxAgentRadius the maximum radius an agent can have
  119486. * @param scene to attach the crowd to
  119487. * @returns the crowd you can add agents to
  119488. */
  119489. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  119490. /**
  119491. * Disposes
  119492. */
  119493. dispose(): void;
  119494. /**
  119495. * If this plugin is supported
  119496. * @returns true if plugin is supported
  119497. */
  119498. isSupported(): boolean;
  119499. }
  119500. /**
  119501. * Recast detour crowd implementation
  119502. */
  119503. export class RecastJSCrowd implements ICrowd {
  119504. /**
  119505. * Recast/detour plugin
  119506. */
  119507. bjsRECASTPlugin: RecastJSPlugin;
  119508. /**
  119509. * Link to the detour crowd
  119510. */
  119511. recastCrowd: any;
  119512. /**
  119513. * One transform per agent
  119514. */
  119515. transforms: TransformNode[];
  119516. /**
  119517. * All agents created
  119518. */
  119519. agents: number[];
  119520. /**
  119521. * Link to the scene is kept to unregister the crowd from the scene
  119522. */
  119523. private _scene;
  119524. /**
  119525. * Observer for crowd updates
  119526. */
  119527. private _onBeforeAnimationsObserver;
  119528. /**
  119529. * Constructor
  119530. * @param plugin recastJS plugin
  119531. * @param maxAgents the maximum agent count in the crowd
  119532. * @param maxAgentRadius the maximum radius an agent can have
  119533. * @param scene to attach the crowd to
  119534. * @returns the crowd you can add agents to
  119535. */
  119536. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  119537. /**
  119538. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  119539. * You can attach anything to that node. The node position is updated in the scene update tick.
  119540. * @param pos world position that will be constrained by the navigation mesh
  119541. * @param parameters agent parameters
  119542. * @param transform hooked to the agent that will be update by the scene
  119543. * @returns agent index
  119544. */
  119545. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  119546. /**
  119547. * Returns the agent position in world space
  119548. * @param index agent index returned by addAgent
  119549. * @returns world space position
  119550. */
  119551. getAgentPosition(index: number): Vector3;
  119552. /**
  119553. * Returns the agent velocity in world space
  119554. * @param index agent index returned by addAgent
  119555. * @returns world space velocity
  119556. */
  119557. getAgentVelocity(index: number): Vector3;
  119558. /**
  119559. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  119560. * @param index agent index returned by addAgent
  119561. * @param destination targeted world position
  119562. */
  119563. agentGoto(index: number, destination: Vector3): void;
  119564. /**
  119565. * remove a particular agent previously created
  119566. * @param index agent index returned by addAgent
  119567. */
  119568. removeAgent(index: number): void;
  119569. /**
  119570. * get the list of all agents attached to this crowd
  119571. * @returns list of agent indices
  119572. */
  119573. getAgents(): number[];
  119574. /**
  119575. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  119576. * @param deltaTime in seconds
  119577. */
  119578. update(deltaTime: number): void;
  119579. /**
  119580. * Release all resources
  119581. */
  119582. dispose(): void;
  119583. }
  119584. }
  119585. declare module BABYLON {
  119586. /**
  119587. * Class used to enable access to IndexedDB
  119588. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119589. */
  119590. export class Database implements IOfflineProvider {
  119591. private _callbackManifestChecked;
  119592. private _currentSceneUrl;
  119593. private _db;
  119594. private _enableSceneOffline;
  119595. private _enableTexturesOffline;
  119596. private _manifestVersionFound;
  119597. private _mustUpdateRessources;
  119598. private _hasReachedQuota;
  119599. private _isSupported;
  119600. private _idbFactory;
  119601. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  119602. private static IsUASupportingBlobStorage;
  119603. /**
  119604. * Gets a boolean indicating if Database storate is enabled (off by default)
  119605. */
  119606. static IDBStorageEnabled: boolean;
  119607. /**
  119608. * Gets a boolean indicating if scene must be saved in the database
  119609. */
  119610. readonly enableSceneOffline: boolean;
  119611. /**
  119612. * Gets a boolean indicating if textures must be saved in the database
  119613. */
  119614. readonly enableTexturesOffline: boolean;
  119615. /**
  119616. * Creates a new Database
  119617. * @param urlToScene defines the url to load the scene
  119618. * @param callbackManifestChecked defines the callback to use when manifest is checked
  119619. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  119620. */
  119621. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  119622. private static _ParseURL;
  119623. private static _ReturnFullUrlLocation;
  119624. private _checkManifestFile;
  119625. /**
  119626. * Open the database and make it available
  119627. * @param successCallback defines the callback to call on success
  119628. * @param errorCallback defines the callback to call on error
  119629. */
  119630. open(successCallback: () => void, errorCallback: () => void): void;
  119631. /**
  119632. * Loads an image from the database
  119633. * @param url defines the url to load from
  119634. * @param image defines the target DOM image
  119635. */
  119636. loadImage(url: string, image: HTMLImageElement): void;
  119637. private _loadImageFromDBAsync;
  119638. private _saveImageIntoDBAsync;
  119639. private _checkVersionFromDB;
  119640. private _loadVersionFromDBAsync;
  119641. private _saveVersionIntoDBAsync;
  119642. /**
  119643. * Loads a file from database
  119644. * @param url defines the URL to load from
  119645. * @param sceneLoaded defines a callback to call on success
  119646. * @param progressCallBack defines a callback to call when progress changed
  119647. * @param errorCallback defines a callback to call on error
  119648. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  119649. */
  119650. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  119651. private _loadFileAsync;
  119652. private _saveFileAsync;
  119653. /**
  119654. * Validates if xhr data is correct
  119655. * @param xhr defines the request to validate
  119656. * @param dataType defines the expected data type
  119657. * @returns true if data is correct
  119658. */
  119659. private static _ValidateXHRData;
  119660. }
  119661. }
  119662. declare module BABYLON {
  119663. /** @hidden */
  119664. export var gpuUpdateParticlesPixelShader: {
  119665. name: string;
  119666. shader: string;
  119667. };
  119668. }
  119669. declare module BABYLON {
  119670. /** @hidden */
  119671. export var gpuUpdateParticlesVertexShader: {
  119672. name: string;
  119673. shader: string;
  119674. };
  119675. }
  119676. declare module BABYLON {
  119677. /** @hidden */
  119678. export var clipPlaneFragmentDeclaration2: {
  119679. name: string;
  119680. shader: string;
  119681. };
  119682. }
  119683. declare module BABYLON {
  119684. /** @hidden */
  119685. export var gpuRenderParticlesPixelShader: {
  119686. name: string;
  119687. shader: string;
  119688. };
  119689. }
  119690. declare module BABYLON {
  119691. /** @hidden */
  119692. export var clipPlaneVertexDeclaration2: {
  119693. name: string;
  119694. shader: string;
  119695. };
  119696. }
  119697. declare module BABYLON {
  119698. /** @hidden */
  119699. export var gpuRenderParticlesVertexShader: {
  119700. name: string;
  119701. shader: string;
  119702. };
  119703. }
  119704. declare module BABYLON {
  119705. /**
  119706. * This represents a GPU particle system in Babylon
  119707. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  119708. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  119709. */
  119710. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  119711. /**
  119712. * The layer mask we are rendering the particles through.
  119713. */
  119714. layerMask: number;
  119715. private _capacity;
  119716. private _activeCount;
  119717. private _currentActiveCount;
  119718. private _accumulatedCount;
  119719. private _renderEffect;
  119720. private _updateEffect;
  119721. private _buffer0;
  119722. private _buffer1;
  119723. private _spriteBuffer;
  119724. private _updateVAO;
  119725. private _renderVAO;
  119726. private _targetIndex;
  119727. private _sourceBuffer;
  119728. private _targetBuffer;
  119729. private _engine;
  119730. private _currentRenderId;
  119731. private _started;
  119732. private _stopped;
  119733. private _timeDelta;
  119734. private _randomTexture;
  119735. private _randomTexture2;
  119736. private _attributesStrideSize;
  119737. private _updateEffectOptions;
  119738. private _randomTextureSize;
  119739. private _actualFrame;
  119740. private readonly _rawTextureWidth;
  119741. /**
  119742. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  119743. */
  119744. static readonly IsSupported: boolean;
  119745. /**
  119746. * An event triggered when the system is disposed.
  119747. */
  119748. onDisposeObservable: Observable<GPUParticleSystem>;
  119749. /**
  119750. * Gets the maximum number of particles active at the same time.
  119751. * @returns The max number of active particles.
  119752. */
  119753. getCapacity(): number;
  119754. /**
  119755. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  119756. * to override the particles.
  119757. */
  119758. forceDepthWrite: boolean;
  119759. /**
  119760. * Gets or set the number of active particles
  119761. */
  119762. activeParticleCount: number;
  119763. private _preWarmDone;
  119764. /**
  119765. * Is this system ready to be used/rendered
  119766. * @return true if the system is ready
  119767. */
  119768. isReady(): boolean;
  119769. /**
  119770. * Gets if the system has been started. (Note: this will still be true after stop is called)
  119771. * @returns True if it has been started, otherwise false.
  119772. */
  119773. isStarted(): boolean;
  119774. /**
  119775. * Starts the particle system and begins to emit
  119776. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  119777. */
  119778. start(delay?: number): void;
  119779. /**
  119780. * Stops the particle system.
  119781. */
  119782. stop(): void;
  119783. /**
  119784. * Remove all active particles
  119785. */
  119786. reset(): void;
  119787. /**
  119788. * Returns the string "GPUParticleSystem"
  119789. * @returns a string containing the class name
  119790. */
  119791. getClassName(): string;
  119792. private _colorGradientsTexture;
  119793. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  119794. /**
  119795. * Adds a new color gradient
  119796. * @param gradient defines the gradient to use (between 0 and 1)
  119797. * @param color1 defines the color to affect to the specified gradient
  119798. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  119799. * @returns the current particle system
  119800. */
  119801. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  119802. /**
  119803. * Remove a specific color gradient
  119804. * @param gradient defines the gradient to remove
  119805. * @returns the current particle system
  119806. */
  119807. removeColorGradient(gradient: number): GPUParticleSystem;
  119808. private _angularSpeedGradientsTexture;
  119809. private _sizeGradientsTexture;
  119810. private _velocityGradientsTexture;
  119811. private _limitVelocityGradientsTexture;
  119812. private _dragGradientsTexture;
  119813. private _addFactorGradient;
  119814. /**
  119815. * Adds a new size gradient
  119816. * @param gradient defines the gradient to use (between 0 and 1)
  119817. * @param factor defines the size factor to affect to the specified gradient
  119818. * @returns the current particle system
  119819. */
  119820. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  119821. /**
  119822. * Remove a specific size gradient
  119823. * @param gradient defines the gradient to remove
  119824. * @returns the current particle system
  119825. */
  119826. removeSizeGradient(gradient: number): GPUParticleSystem;
  119827. /**
  119828. * Adds a new angular speed gradient
  119829. * @param gradient defines the gradient to use (between 0 and 1)
  119830. * @param factor defines the angular speed to affect to the specified gradient
  119831. * @returns the current particle system
  119832. */
  119833. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  119834. /**
  119835. * Remove a specific angular speed gradient
  119836. * @param gradient defines the gradient to remove
  119837. * @returns the current particle system
  119838. */
  119839. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  119840. /**
  119841. * Adds a new velocity gradient
  119842. * @param gradient defines the gradient to use (between 0 and 1)
  119843. * @param factor defines the velocity to affect to the specified gradient
  119844. * @returns the current particle system
  119845. */
  119846. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119847. /**
  119848. * Remove a specific velocity gradient
  119849. * @param gradient defines the gradient to remove
  119850. * @returns the current particle system
  119851. */
  119852. removeVelocityGradient(gradient: number): GPUParticleSystem;
  119853. /**
  119854. * Adds a new limit velocity gradient
  119855. * @param gradient defines the gradient to use (between 0 and 1)
  119856. * @param factor defines the limit velocity value to affect to the specified gradient
  119857. * @returns the current particle system
  119858. */
  119859. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119860. /**
  119861. * Remove a specific limit velocity gradient
  119862. * @param gradient defines the gradient to remove
  119863. * @returns the current particle system
  119864. */
  119865. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  119866. /**
  119867. * Adds a new drag gradient
  119868. * @param gradient defines the gradient to use (between 0 and 1)
  119869. * @param factor defines the drag value to affect to the specified gradient
  119870. * @returns the current particle system
  119871. */
  119872. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  119873. /**
  119874. * Remove a specific drag gradient
  119875. * @param gradient defines the gradient to remove
  119876. * @returns the current particle system
  119877. */
  119878. removeDragGradient(gradient: number): GPUParticleSystem;
  119879. /**
  119880. * Not supported by GPUParticleSystem
  119881. * @param gradient defines the gradient to use (between 0 and 1)
  119882. * @param factor defines the emit rate value to affect to the specified gradient
  119883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119884. * @returns the current particle system
  119885. */
  119886. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119887. /**
  119888. * Not supported by GPUParticleSystem
  119889. * @param gradient defines the gradient to remove
  119890. * @returns the current particle system
  119891. */
  119892. removeEmitRateGradient(gradient: number): IParticleSystem;
  119893. /**
  119894. * Not supported by GPUParticleSystem
  119895. * @param gradient defines the gradient to use (between 0 and 1)
  119896. * @param factor defines the start size value to affect to the specified gradient
  119897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119898. * @returns the current particle system
  119899. */
  119900. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119901. /**
  119902. * Not supported by GPUParticleSystem
  119903. * @param gradient defines the gradient to remove
  119904. * @returns the current particle system
  119905. */
  119906. removeStartSizeGradient(gradient: number): IParticleSystem;
  119907. /**
  119908. * Not supported by GPUParticleSystem
  119909. * @param gradient defines the gradient to use (between 0 and 1)
  119910. * @param min defines the color remap minimal range
  119911. * @param max defines the color remap maximal range
  119912. * @returns the current particle system
  119913. */
  119914. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119915. /**
  119916. * Not supported by GPUParticleSystem
  119917. * @param gradient defines the gradient to remove
  119918. * @returns the current particle system
  119919. */
  119920. removeColorRemapGradient(): IParticleSystem;
  119921. /**
  119922. * Not supported by GPUParticleSystem
  119923. * @param gradient defines the gradient to use (between 0 and 1)
  119924. * @param min defines the alpha remap minimal range
  119925. * @param max defines the alpha remap maximal range
  119926. * @returns the current particle system
  119927. */
  119928. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119929. /**
  119930. * Not supported by GPUParticleSystem
  119931. * @param gradient defines the gradient to remove
  119932. * @returns the current particle system
  119933. */
  119934. removeAlphaRemapGradient(): IParticleSystem;
  119935. /**
  119936. * Not supported by GPUParticleSystem
  119937. * @param gradient defines the gradient to use (between 0 and 1)
  119938. * @param color defines the color to affect to the specified gradient
  119939. * @returns the current particle system
  119940. */
  119941. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119942. /**
  119943. * Not supported by GPUParticleSystem
  119944. * @param gradient defines the gradient to remove
  119945. * @returns the current particle system
  119946. */
  119947. removeRampGradient(): IParticleSystem;
  119948. /**
  119949. * Not supported by GPUParticleSystem
  119950. * @returns the list of ramp gradients
  119951. */
  119952. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119953. /**
  119954. * Not supported by GPUParticleSystem
  119955. * Gets or sets a boolean indicating that ramp gradients must be used
  119956. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119957. */
  119958. useRampGradients: boolean;
  119959. /**
  119960. * Not supported by GPUParticleSystem
  119961. * @param gradient defines the gradient to use (between 0 and 1)
  119962. * @param factor defines the life time factor to affect to the specified gradient
  119963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119964. * @returns the current particle system
  119965. */
  119966. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119967. /**
  119968. * Not supported by GPUParticleSystem
  119969. * @param gradient defines the gradient to remove
  119970. * @returns the current particle system
  119971. */
  119972. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119973. /**
  119974. * Instantiates a GPU particle system.
  119975. * 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.
  119976. * @param name The name of the particle system
  119977. * @param options The options used to create the system
  119978. * @param scene The scene the particle system belongs to
  119979. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119980. */
  119981. constructor(name: string, options: Partial<{
  119982. capacity: number;
  119983. randomTextureSize: number;
  119984. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119985. protected _reset(): void;
  119986. private _createUpdateVAO;
  119987. private _createRenderVAO;
  119988. private _initialize;
  119989. /** @hidden */
  119990. _recreateUpdateEffect(): void;
  119991. /** @hidden */
  119992. _recreateRenderEffect(): void;
  119993. /**
  119994. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119995. * @param preWarm defines if we are in the pre-warmimg phase
  119996. */
  119997. animate(preWarm?: boolean): void;
  119998. private _createFactorGradientTexture;
  119999. private _createSizeGradientTexture;
  120000. private _createAngularSpeedGradientTexture;
  120001. private _createVelocityGradientTexture;
  120002. private _createLimitVelocityGradientTexture;
  120003. private _createDragGradientTexture;
  120004. private _createColorGradientTexture;
  120005. /**
  120006. * Renders the particle system in its current state
  120007. * @param preWarm defines if the system should only update the particles but not render them
  120008. * @returns the current number of particles
  120009. */
  120010. render(preWarm?: boolean): number;
  120011. /**
  120012. * Rebuilds the particle system
  120013. */
  120014. rebuild(): void;
  120015. private _releaseBuffers;
  120016. private _releaseVAOs;
  120017. /**
  120018. * Disposes the particle system and free the associated resources
  120019. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  120020. */
  120021. dispose(disposeTexture?: boolean): void;
  120022. /**
  120023. * Clones the particle system.
  120024. * @param name The name of the cloned object
  120025. * @param newEmitter The new emitter to use
  120026. * @returns the cloned particle system
  120027. */
  120028. clone(name: string, newEmitter: any): GPUParticleSystem;
  120029. /**
  120030. * Serializes the particle system to a JSON object.
  120031. * @returns the JSON object
  120032. */
  120033. serialize(): any;
  120034. /**
  120035. * Parses a JSON object to create a GPU particle system.
  120036. * @param parsedParticleSystem The JSON object to parse
  120037. * @param scene The scene to create the particle system in
  120038. * @param rootUrl The root url to use to load external dependencies like texture
  120039. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  120040. * @returns the parsed GPU particle system
  120041. */
  120042. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  120043. }
  120044. }
  120045. declare module BABYLON {
  120046. /**
  120047. * Represents a set of particle systems working together to create a specific effect
  120048. */
  120049. export class ParticleSystemSet implements IDisposable {
  120050. private _emitterCreationOptions;
  120051. private _emitterNode;
  120052. /**
  120053. * Gets the particle system list
  120054. */
  120055. systems: IParticleSystem[];
  120056. /**
  120057. * Gets the emitter node used with this set
  120058. */
  120059. readonly emitterNode: Nullable<TransformNode>;
  120060. /**
  120061. * Creates a new emitter mesh as a sphere
  120062. * @param options defines the options used to create the sphere
  120063. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  120064. * @param scene defines the hosting scene
  120065. */
  120066. setEmitterAsSphere(options: {
  120067. diameter: number;
  120068. segments: number;
  120069. color: Color3;
  120070. }, renderingGroupId: number, scene: Scene): void;
  120071. /**
  120072. * Starts all particle systems of the set
  120073. * @param emitter defines an optional mesh to use as emitter for the particle systems
  120074. */
  120075. start(emitter?: AbstractMesh): void;
  120076. /**
  120077. * Release all associated resources
  120078. */
  120079. dispose(): void;
  120080. /**
  120081. * Serialize the set into a JSON compatible object
  120082. * @returns a JSON compatible representation of the set
  120083. */
  120084. serialize(): any;
  120085. /**
  120086. * Parse a new ParticleSystemSet from a serialized source
  120087. * @param data defines a JSON compatible representation of the set
  120088. * @param scene defines the hosting scene
  120089. * @param gpu defines if we want GPU particles or CPU particles
  120090. * @returns a new ParticleSystemSet
  120091. */
  120092. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  120093. }
  120094. }
  120095. declare module BABYLON {
  120096. /**
  120097. * This class is made for on one-liner static method to help creating particle system set.
  120098. */
  120099. export class ParticleHelper {
  120100. /**
  120101. * Gets or sets base Assets URL
  120102. */
  120103. static BaseAssetsUrl: string;
  120104. /**
  120105. * Create a default particle system that you can tweak
  120106. * @param emitter defines the emitter to use
  120107. * @param capacity defines the system capacity (default is 500 particles)
  120108. * @param scene defines the hosting scene
  120109. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  120110. * @returns the new Particle system
  120111. */
  120112. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  120113. /**
  120114. * This is the main static method (one-liner) of this helper to create different particle systems
  120115. * @param type This string represents the type to the particle system to create
  120116. * @param scene The scene where the particle system should live
  120117. * @param gpu If the system will use gpu
  120118. * @returns the ParticleSystemSet created
  120119. */
  120120. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  120121. /**
  120122. * Static function used to export a particle system to a ParticleSystemSet variable.
  120123. * Please note that the emitter shape is not exported
  120124. * @param systems defines the particle systems to export
  120125. * @returns the created particle system set
  120126. */
  120127. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  120128. }
  120129. }
  120130. declare module BABYLON {
  120131. interface Engine {
  120132. /**
  120133. * Create an effect to use with particle systems.
  120134. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  120135. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  120136. * @param uniformsNames defines a list of attribute names
  120137. * @param samplers defines an array of string used to represent textures
  120138. * @param defines defines the string containing the defines to use to compile the shaders
  120139. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120140. * @param onCompiled defines a function to call when the effect creation is successful
  120141. * @param onError defines a function to call when the effect creation has failed
  120142. * @returns the new Effect
  120143. */
  120144. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  120145. }
  120146. interface Mesh {
  120147. /**
  120148. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  120149. * @returns an array of IParticleSystem
  120150. */
  120151. getEmittedParticleSystems(): IParticleSystem[];
  120152. /**
  120153. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  120154. * @returns an array of IParticleSystem
  120155. */
  120156. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  120157. }
  120158. /**
  120159. * @hidden
  120160. */
  120161. export var _IDoNeedToBeInTheBuild: number;
  120162. }
  120163. declare module BABYLON {
  120164. interface Scene {
  120165. /** @hidden (Backing field) */
  120166. _physicsEngine: Nullable<IPhysicsEngine>;
  120167. /**
  120168. * Gets the current physics engine
  120169. * @returns a IPhysicsEngine or null if none attached
  120170. */
  120171. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  120172. /**
  120173. * Enables physics to the current scene
  120174. * @param gravity defines the scene's gravity for the physics engine
  120175. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  120176. * @return a boolean indicating if the physics engine was initialized
  120177. */
  120178. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  120179. /**
  120180. * Disables and disposes the physics engine associated with the scene
  120181. */
  120182. disablePhysicsEngine(): void;
  120183. /**
  120184. * Gets a boolean indicating if there is an active physics engine
  120185. * @returns a boolean indicating if there is an active physics engine
  120186. */
  120187. isPhysicsEnabled(): boolean;
  120188. /**
  120189. * Deletes a physics compound impostor
  120190. * @param compound defines the compound to delete
  120191. */
  120192. deleteCompoundImpostor(compound: any): void;
  120193. /**
  120194. * An event triggered when physic simulation is about to be run
  120195. */
  120196. onBeforePhysicsObservable: Observable<Scene>;
  120197. /**
  120198. * An event triggered when physic simulation has been done
  120199. */
  120200. onAfterPhysicsObservable: Observable<Scene>;
  120201. }
  120202. interface AbstractMesh {
  120203. /** @hidden */
  120204. _physicsImpostor: Nullable<PhysicsImpostor>;
  120205. /**
  120206. * Gets or sets impostor used for physic simulation
  120207. * @see http://doc.babylonjs.com/features/physics_engine
  120208. */
  120209. physicsImpostor: Nullable<PhysicsImpostor>;
  120210. /**
  120211. * Gets the current physics impostor
  120212. * @see http://doc.babylonjs.com/features/physics_engine
  120213. * @returns a physics impostor or null
  120214. */
  120215. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  120216. /** Apply a physic impulse to the mesh
  120217. * @param force defines the force to apply
  120218. * @param contactPoint defines where to apply the force
  120219. * @returns the current mesh
  120220. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120221. */
  120222. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  120223. /**
  120224. * Creates a physic joint between two meshes
  120225. * @param otherMesh defines the other mesh to use
  120226. * @param pivot1 defines the pivot to use on this mesh
  120227. * @param pivot2 defines the pivot to use on the other mesh
  120228. * @param options defines additional options (can be plugin dependent)
  120229. * @returns the current mesh
  120230. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  120231. */
  120232. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  120233. /** @hidden */
  120234. _disposePhysicsObserver: Nullable<Observer<Node>>;
  120235. }
  120236. /**
  120237. * Defines the physics engine scene component responsible to manage a physics engine
  120238. */
  120239. export class PhysicsEngineSceneComponent implements ISceneComponent {
  120240. /**
  120241. * The component name helpful to identify the component in the list of scene components.
  120242. */
  120243. readonly name: string;
  120244. /**
  120245. * The scene the component belongs to.
  120246. */
  120247. scene: Scene;
  120248. /**
  120249. * Creates a new instance of the component for the given scene
  120250. * @param scene Defines the scene to register the component in
  120251. */
  120252. constructor(scene: Scene);
  120253. /**
  120254. * Registers the component in a given scene
  120255. */
  120256. register(): void;
  120257. /**
  120258. * Rebuilds the elements related to this component in case of
  120259. * context lost for instance.
  120260. */
  120261. rebuild(): void;
  120262. /**
  120263. * Disposes the component and the associated ressources
  120264. */
  120265. dispose(): void;
  120266. }
  120267. }
  120268. declare module BABYLON {
  120269. /**
  120270. * A helper for physics simulations
  120271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120272. */
  120273. export class PhysicsHelper {
  120274. private _scene;
  120275. private _physicsEngine;
  120276. /**
  120277. * Initializes the Physics helper
  120278. * @param scene Babylon.js scene
  120279. */
  120280. constructor(scene: Scene);
  120281. /**
  120282. * Applies a radial explosion impulse
  120283. * @param origin the origin of the explosion
  120284. * @param radiusOrEventOptions the radius or the options of radial explosion
  120285. * @param strength the explosion strength
  120286. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120287. * @returns A physics radial explosion event, or null
  120288. */
  120289. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120290. /**
  120291. * Applies a radial explosion force
  120292. * @param origin the origin of the explosion
  120293. * @param radiusOrEventOptions the radius or the options of radial explosion
  120294. * @param strength the explosion strength
  120295. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120296. * @returns A physics radial explosion event, or null
  120297. */
  120298. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  120299. /**
  120300. * Creates a gravitational field
  120301. * @param origin the origin of the explosion
  120302. * @param radiusOrEventOptions the radius or the options of radial explosion
  120303. * @param strength the explosion strength
  120304. * @param falloff possible options: Constant & Linear. Defaults to Constant
  120305. * @returns A physics gravitational field event, or null
  120306. */
  120307. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  120308. /**
  120309. * Creates a physics updraft event
  120310. * @param origin the origin of the updraft
  120311. * @param radiusOrEventOptions the radius or the options of the updraft
  120312. * @param strength the strength of the updraft
  120313. * @param height the height of the updraft
  120314. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  120315. * @returns A physics updraft event, or null
  120316. */
  120317. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  120318. /**
  120319. * Creates a physics vortex event
  120320. * @param origin the of the vortex
  120321. * @param radiusOrEventOptions the radius or the options of the vortex
  120322. * @param strength the strength of the vortex
  120323. * @param height the height of the vortex
  120324. * @returns a Physics vortex event, or null
  120325. * A physics vortex event or null
  120326. */
  120327. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  120328. }
  120329. /**
  120330. * Represents a physics radial explosion event
  120331. */
  120332. class PhysicsRadialExplosionEvent {
  120333. private _scene;
  120334. private _options;
  120335. private _sphere;
  120336. private _dataFetched;
  120337. /**
  120338. * Initializes a radial explosioin event
  120339. * @param _scene BabylonJS scene
  120340. * @param _options The options for the vortex event
  120341. */
  120342. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  120343. /**
  120344. * Returns the data related to the radial explosion event (sphere).
  120345. * @returns The radial explosion event data
  120346. */
  120347. getData(): PhysicsRadialExplosionEventData;
  120348. /**
  120349. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  120350. * @param impostor A physics imposter
  120351. * @param origin the origin of the explosion
  120352. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  120353. */
  120354. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  120355. /**
  120356. * Triggers affecterd impostors callbacks
  120357. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  120358. */
  120359. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  120360. /**
  120361. * Disposes the sphere.
  120362. * @param force Specifies if the sphere should be disposed by force
  120363. */
  120364. dispose(force?: boolean): void;
  120365. /*** Helpers ***/
  120366. private _prepareSphere;
  120367. private _intersectsWithSphere;
  120368. }
  120369. /**
  120370. * Represents a gravitational field event
  120371. */
  120372. class PhysicsGravitationalFieldEvent {
  120373. private _physicsHelper;
  120374. private _scene;
  120375. private _origin;
  120376. private _options;
  120377. private _tickCallback;
  120378. private _sphere;
  120379. private _dataFetched;
  120380. /**
  120381. * Initializes the physics gravitational field event
  120382. * @param _physicsHelper A physics helper
  120383. * @param _scene BabylonJS scene
  120384. * @param _origin The origin position of the gravitational field event
  120385. * @param _options The options for the vortex event
  120386. */
  120387. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  120388. /**
  120389. * Returns the data related to the gravitational field event (sphere).
  120390. * @returns A gravitational field event
  120391. */
  120392. getData(): PhysicsGravitationalFieldEventData;
  120393. /**
  120394. * Enables the gravitational field.
  120395. */
  120396. enable(): void;
  120397. /**
  120398. * Disables the gravitational field.
  120399. */
  120400. disable(): void;
  120401. /**
  120402. * Disposes the sphere.
  120403. * @param force The force to dispose from the gravitational field event
  120404. */
  120405. dispose(force?: boolean): void;
  120406. private _tick;
  120407. }
  120408. /**
  120409. * Represents a physics updraft event
  120410. */
  120411. class PhysicsUpdraftEvent {
  120412. private _scene;
  120413. private _origin;
  120414. private _options;
  120415. private _physicsEngine;
  120416. private _originTop;
  120417. private _originDirection;
  120418. private _tickCallback;
  120419. private _cylinder;
  120420. private _cylinderPosition;
  120421. private _dataFetched;
  120422. /**
  120423. * Initializes the physics updraft event
  120424. * @param _scene BabylonJS scene
  120425. * @param _origin The origin position of the updraft
  120426. * @param _options The options for the updraft event
  120427. */
  120428. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  120429. /**
  120430. * Returns the data related to the updraft event (cylinder).
  120431. * @returns A physics updraft event
  120432. */
  120433. getData(): PhysicsUpdraftEventData;
  120434. /**
  120435. * Enables the updraft.
  120436. */
  120437. enable(): void;
  120438. /**
  120439. * Disables the updraft.
  120440. */
  120441. disable(): void;
  120442. /**
  120443. * Disposes the cylinder.
  120444. * @param force Specifies if the updraft should be disposed by force
  120445. */
  120446. dispose(force?: boolean): void;
  120447. private getImpostorHitData;
  120448. private _tick;
  120449. /*** Helpers ***/
  120450. private _prepareCylinder;
  120451. private _intersectsWithCylinder;
  120452. }
  120453. /**
  120454. * Represents a physics vortex event
  120455. */
  120456. class PhysicsVortexEvent {
  120457. private _scene;
  120458. private _origin;
  120459. private _options;
  120460. private _physicsEngine;
  120461. private _originTop;
  120462. private _tickCallback;
  120463. private _cylinder;
  120464. private _cylinderPosition;
  120465. private _dataFetched;
  120466. /**
  120467. * Initializes the physics vortex event
  120468. * @param _scene The BabylonJS scene
  120469. * @param _origin The origin position of the vortex
  120470. * @param _options The options for the vortex event
  120471. */
  120472. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  120473. /**
  120474. * Returns the data related to the vortex event (cylinder).
  120475. * @returns The physics vortex event data
  120476. */
  120477. getData(): PhysicsVortexEventData;
  120478. /**
  120479. * Enables the vortex.
  120480. */
  120481. enable(): void;
  120482. /**
  120483. * Disables the cortex.
  120484. */
  120485. disable(): void;
  120486. /**
  120487. * Disposes the sphere.
  120488. * @param force
  120489. */
  120490. dispose(force?: boolean): void;
  120491. private getImpostorHitData;
  120492. private _tick;
  120493. /*** Helpers ***/
  120494. private _prepareCylinder;
  120495. private _intersectsWithCylinder;
  120496. }
  120497. /**
  120498. * Options fot the radial explosion event
  120499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120500. */
  120501. export class PhysicsRadialExplosionEventOptions {
  120502. /**
  120503. * The radius of the sphere for the radial explosion.
  120504. */
  120505. radius: number;
  120506. /**
  120507. * The strenth of the explosion.
  120508. */
  120509. strength: number;
  120510. /**
  120511. * The strenght of the force in correspondence to the distance of the affected object
  120512. */
  120513. falloff: PhysicsRadialImpulseFalloff;
  120514. /**
  120515. * Sphere options for the radial explosion.
  120516. */
  120517. sphere: {
  120518. segments: number;
  120519. diameter: number;
  120520. };
  120521. /**
  120522. * Sphere options for the radial explosion.
  120523. */
  120524. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  120525. }
  120526. /**
  120527. * Options fot the updraft event
  120528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120529. */
  120530. export class PhysicsUpdraftEventOptions {
  120531. /**
  120532. * The radius of the cylinder for the vortex
  120533. */
  120534. radius: number;
  120535. /**
  120536. * The strenth of the updraft.
  120537. */
  120538. strength: number;
  120539. /**
  120540. * The height of the cylinder for the updraft.
  120541. */
  120542. height: number;
  120543. /**
  120544. * The mode for the the updraft.
  120545. */
  120546. updraftMode: PhysicsUpdraftMode;
  120547. }
  120548. /**
  120549. * Options fot the vortex event
  120550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120551. */
  120552. export class PhysicsVortexEventOptions {
  120553. /**
  120554. * The radius of the cylinder for the vortex
  120555. */
  120556. radius: number;
  120557. /**
  120558. * The strenth of the vortex.
  120559. */
  120560. strength: number;
  120561. /**
  120562. * The height of the cylinder for the vortex.
  120563. */
  120564. height: number;
  120565. /**
  120566. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  120567. */
  120568. centripetalForceThreshold: number;
  120569. /**
  120570. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  120571. */
  120572. centripetalForceMultiplier: number;
  120573. /**
  120574. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  120575. */
  120576. centrifugalForceMultiplier: number;
  120577. /**
  120578. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  120579. */
  120580. updraftForceMultiplier: number;
  120581. }
  120582. /**
  120583. * The strenght of the force in correspondence to the distance of the affected object
  120584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120585. */
  120586. export enum PhysicsRadialImpulseFalloff {
  120587. /** Defines that impulse is constant in strength across it's whole radius */
  120588. Constant = 0,
  120589. /** Defines that impulse gets weaker if it's further from the origin */
  120590. Linear = 1
  120591. }
  120592. /**
  120593. * The strength of the force in correspondence to the distance of the affected object
  120594. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120595. */
  120596. export enum PhysicsUpdraftMode {
  120597. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  120598. Center = 0,
  120599. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  120600. Perpendicular = 1
  120601. }
  120602. /**
  120603. * Interface for a physics hit data
  120604. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120605. */
  120606. export interface PhysicsHitData {
  120607. /**
  120608. * The force applied at the contact point
  120609. */
  120610. force: Vector3;
  120611. /**
  120612. * The contact point
  120613. */
  120614. contactPoint: Vector3;
  120615. /**
  120616. * The distance from the origin to the contact point
  120617. */
  120618. distanceFromOrigin: number;
  120619. }
  120620. /**
  120621. * Interface for radial explosion event data
  120622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120623. */
  120624. export interface PhysicsRadialExplosionEventData {
  120625. /**
  120626. * A sphere used for the radial explosion event
  120627. */
  120628. sphere: Mesh;
  120629. }
  120630. /**
  120631. * Interface for gravitational field event data
  120632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120633. */
  120634. export interface PhysicsGravitationalFieldEventData {
  120635. /**
  120636. * A sphere mesh used for the gravitational field event
  120637. */
  120638. sphere: Mesh;
  120639. }
  120640. /**
  120641. * Interface for updraft event data
  120642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120643. */
  120644. export interface PhysicsUpdraftEventData {
  120645. /**
  120646. * A cylinder used for the updraft event
  120647. */
  120648. cylinder: Mesh;
  120649. }
  120650. /**
  120651. * Interface for vortex event data
  120652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120653. */
  120654. export interface PhysicsVortexEventData {
  120655. /**
  120656. * A cylinder used for the vortex event
  120657. */
  120658. cylinder: Mesh;
  120659. }
  120660. /**
  120661. * Interface for an affected physics impostor
  120662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120663. */
  120664. export interface PhysicsAffectedImpostorWithData {
  120665. /**
  120666. * The impostor affected by the effect
  120667. */
  120668. impostor: PhysicsImpostor;
  120669. /**
  120670. * The data about the hit/horce from the explosion
  120671. */
  120672. hitData: PhysicsHitData;
  120673. }
  120674. }
  120675. declare module BABYLON {
  120676. /** @hidden */
  120677. export var blackAndWhitePixelShader: {
  120678. name: string;
  120679. shader: string;
  120680. };
  120681. }
  120682. declare module BABYLON {
  120683. /**
  120684. * Post process used to render in black and white
  120685. */
  120686. export class BlackAndWhitePostProcess extends PostProcess {
  120687. /**
  120688. * Linear about to convert he result to black and white (default: 1)
  120689. */
  120690. degree: number;
  120691. /**
  120692. * Creates a black and white post process
  120693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120694. * @param name The name of the effect.
  120695. * @param options The required width/height ratio to downsize to before computing the render pass.
  120696. * @param camera The camera to apply the render pass to.
  120697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120698. * @param engine The engine which the post process will be applied. (default: current engine)
  120699. * @param reusable If the post process can be reused on the same frame. (default: false)
  120700. */
  120701. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120702. }
  120703. }
  120704. declare module BABYLON {
  120705. /**
  120706. * This represents a set of one or more post processes in Babylon.
  120707. * A post process can be used to apply a shader to a texture after it is rendered.
  120708. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120709. */
  120710. export class PostProcessRenderEffect {
  120711. private _postProcesses;
  120712. private _getPostProcesses;
  120713. private _singleInstance;
  120714. private _cameras;
  120715. private _indicesForCamera;
  120716. /**
  120717. * Name of the effect
  120718. * @hidden
  120719. */
  120720. _name: string;
  120721. /**
  120722. * Instantiates a post process render effect.
  120723. * A post process can be used to apply a shader to a texture after it is rendered.
  120724. * @param engine The engine the effect is tied to
  120725. * @param name The name of the effect
  120726. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120727. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120728. */
  120729. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  120730. /**
  120731. * Checks if all the post processes in the effect are supported.
  120732. */
  120733. readonly isSupported: boolean;
  120734. /**
  120735. * Updates the current state of the effect
  120736. * @hidden
  120737. */
  120738. _update(): void;
  120739. /**
  120740. * Attaches the effect on cameras
  120741. * @param cameras The camera to attach to.
  120742. * @hidden
  120743. */
  120744. _attachCameras(cameras: Camera): void;
  120745. /**
  120746. * Attaches the effect on cameras
  120747. * @param cameras The camera to attach to.
  120748. * @hidden
  120749. */
  120750. _attachCameras(cameras: Camera[]): void;
  120751. /**
  120752. * Detaches the effect on cameras
  120753. * @param cameras The camera to detatch from.
  120754. * @hidden
  120755. */
  120756. _detachCameras(cameras: Camera): void;
  120757. /**
  120758. * Detatches the effect on cameras
  120759. * @param cameras The camera to detatch from.
  120760. * @hidden
  120761. */
  120762. _detachCameras(cameras: Camera[]): void;
  120763. /**
  120764. * Enables the effect on given cameras
  120765. * @param cameras The camera to enable.
  120766. * @hidden
  120767. */
  120768. _enable(cameras: Camera): void;
  120769. /**
  120770. * Enables the effect on given cameras
  120771. * @param cameras The camera to enable.
  120772. * @hidden
  120773. */
  120774. _enable(cameras: Nullable<Camera[]>): void;
  120775. /**
  120776. * Disables the effect on the given cameras
  120777. * @param cameras The camera to disable.
  120778. * @hidden
  120779. */
  120780. _disable(cameras: Camera): void;
  120781. /**
  120782. * Disables the effect on the given cameras
  120783. * @param cameras The camera to disable.
  120784. * @hidden
  120785. */
  120786. _disable(cameras: Nullable<Camera[]>): void;
  120787. /**
  120788. * Gets a list of the post processes contained in the effect.
  120789. * @param camera The camera to get the post processes on.
  120790. * @returns The list of the post processes in the effect.
  120791. */
  120792. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  120793. }
  120794. }
  120795. declare module BABYLON {
  120796. /** @hidden */
  120797. export var extractHighlightsPixelShader: {
  120798. name: string;
  120799. shader: string;
  120800. };
  120801. }
  120802. declare module BABYLON {
  120803. /**
  120804. * 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.
  120805. */
  120806. export class ExtractHighlightsPostProcess extends PostProcess {
  120807. /**
  120808. * The luminance threshold, pixels below this value will be set to black.
  120809. */
  120810. threshold: number;
  120811. /** @hidden */
  120812. _exposure: number;
  120813. /**
  120814. * Post process which has the input texture to be used when performing highlight extraction
  120815. * @hidden
  120816. */
  120817. _inputPostProcess: Nullable<PostProcess>;
  120818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120819. }
  120820. }
  120821. declare module BABYLON {
  120822. /** @hidden */
  120823. export var bloomMergePixelShader: {
  120824. name: string;
  120825. shader: string;
  120826. };
  120827. }
  120828. declare module BABYLON {
  120829. /**
  120830. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120831. */
  120832. export class BloomMergePostProcess extends PostProcess {
  120833. /** Weight of the bloom to be added to the original input. */
  120834. weight: number;
  120835. /**
  120836. * Creates a new instance of @see BloomMergePostProcess
  120837. * @param name The name of the effect.
  120838. * @param originalFromInput Post process which's input will be used for the merge.
  120839. * @param blurred Blurred highlights post process which's output will be used.
  120840. * @param weight Weight of the bloom to be added to the original input.
  120841. * @param options The required width/height ratio to downsize to before computing the render pass.
  120842. * @param camera The camera to apply the render pass to.
  120843. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120844. * @param engine The engine which the post process will be applied. (default: current engine)
  120845. * @param reusable If the post process can be reused on the same frame. (default: false)
  120846. * @param textureType Type of textures used when performing the post process. (default: 0)
  120847. * @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)
  120848. */
  120849. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  120850. /** Weight of the bloom to be added to the original input. */
  120851. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120852. }
  120853. }
  120854. declare module BABYLON {
  120855. /**
  120856. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120857. */
  120858. export class BloomEffect extends PostProcessRenderEffect {
  120859. private bloomScale;
  120860. /**
  120861. * @hidden Internal
  120862. */
  120863. _effects: Array<PostProcess>;
  120864. /**
  120865. * @hidden Internal
  120866. */
  120867. _downscale: ExtractHighlightsPostProcess;
  120868. private _blurX;
  120869. private _blurY;
  120870. private _merge;
  120871. /**
  120872. * The luminance threshold to find bright areas of the image to bloom.
  120873. */
  120874. threshold: number;
  120875. /**
  120876. * The strength of the bloom.
  120877. */
  120878. weight: number;
  120879. /**
  120880. * Specifies the size of the bloom blur kernel, relative to the final output size
  120881. */
  120882. kernel: number;
  120883. /**
  120884. * Creates a new instance of @see BloomEffect
  120885. * @param scene The scene the effect belongs to.
  120886. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120887. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120888. * @param bloomWeight The the strength of bloom.
  120889. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120890. * @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)
  120891. */
  120892. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120893. /**
  120894. * Disposes each of the internal effects for a given camera.
  120895. * @param camera The camera to dispose the effect on.
  120896. */
  120897. disposeEffects(camera: Camera): void;
  120898. /**
  120899. * @hidden Internal
  120900. */
  120901. _updateEffects(): void;
  120902. /**
  120903. * Internal
  120904. * @returns if all the contained post processes are ready.
  120905. * @hidden
  120906. */
  120907. _isReady(): boolean;
  120908. }
  120909. }
  120910. declare module BABYLON {
  120911. /** @hidden */
  120912. export var chromaticAberrationPixelShader: {
  120913. name: string;
  120914. shader: string;
  120915. };
  120916. }
  120917. declare module BABYLON {
  120918. /**
  120919. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120920. */
  120921. export class ChromaticAberrationPostProcess extends PostProcess {
  120922. /**
  120923. * The amount of seperation of rgb channels (default: 30)
  120924. */
  120925. aberrationAmount: number;
  120926. /**
  120927. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120928. */
  120929. radialIntensity: number;
  120930. /**
  120931. * 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))
  120932. */
  120933. direction: Vector2;
  120934. /**
  120935. * 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))
  120936. */
  120937. centerPosition: Vector2;
  120938. /**
  120939. * Creates a new instance ChromaticAberrationPostProcess
  120940. * @param name The name of the effect.
  120941. * @param screenWidth The width of the screen to apply the effect on.
  120942. * @param screenHeight The height of the screen to apply the effect on.
  120943. * @param options The required width/height ratio to downsize to before computing the render pass.
  120944. * @param camera The camera to apply the render pass to.
  120945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120946. * @param engine The engine which the post process will be applied. (default: current engine)
  120947. * @param reusable If the post process can be reused on the same frame. (default: false)
  120948. * @param textureType Type of textures used when performing the post process. (default: 0)
  120949. * @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)
  120950. */
  120951. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120952. }
  120953. }
  120954. declare module BABYLON {
  120955. /** @hidden */
  120956. export var circleOfConfusionPixelShader: {
  120957. name: string;
  120958. shader: string;
  120959. };
  120960. }
  120961. declare module BABYLON {
  120962. /**
  120963. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120964. */
  120965. export class CircleOfConfusionPostProcess extends PostProcess {
  120966. /**
  120967. * 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.
  120968. */
  120969. lensSize: number;
  120970. /**
  120971. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120972. */
  120973. fStop: number;
  120974. /**
  120975. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120976. */
  120977. focusDistance: number;
  120978. /**
  120979. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120980. */
  120981. focalLength: number;
  120982. private _depthTexture;
  120983. /**
  120984. * Creates a new instance CircleOfConfusionPostProcess
  120985. * @param name The name of the effect.
  120986. * @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.
  120987. * @param options The required width/height ratio to downsize to before computing the render pass.
  120988. * @param camera The camera to apply the render pass to.
  120989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120990. * @param engine The engine which the post process will be applied. (default: current engine)
  120991. * @param reusable If the post process can be reused on the same frame. (default: false)
  120992. * @param textureType Type of textures used when performing the post process. (default: 0)
  120993. * @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)
  120994. */
  120995. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120996. /**
  120997. * 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.
  120998. */
  120999. depthTexture: RenderTargetTexture;
  121000. }
  121001. }
  121002. declare module BABYLON {
  121003. /** @hidden */
  121004. export var colorCorrectionPixelShader: {
  121005. name: string;
  121006. shader: string;
  121007. };
  121008. }
  121009. declare module BABYLON {
  121010. /**
  121011. *
  121012. * This post-process allows the modification of rendered colors by using
  121013. * a 'look-up table' (LUT). This effect is also called Color Grading.
  121014. *
  121015. * The object needs to be provided an url to a texture containing the color
  121016. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  121017. * Use an image editing software to tweak the LUT to match your needs.
  121018. *
  121019. * For an example of a color LUT, see here:
  121020. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  121021. * For explanations on color grading, see here:
  121022. * @see http://udn.epicgames.com/Three/ColorGrading.html
  121023. *
  121024. */
  121025. export class ColorCorrectionPostProcess extends PostProcess {
  121026. private _colorTableTexture;
  121027. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121028. }
  121029. }
  121030. declare module BABYLON {
  121031. /** @hidden */
  121032. export var convolutionPixelShader: {
  121033. name: string;
  121034. shader: string;
  121035. };
  121036. }
  121037. declare module BABYLON {
  121038. /**
  121039. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  121040. * input texture to perform effects such as edge detection or sharpening
  121041. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121042. */
  121043. export class ConvolutionPostProcess extends PostProcess {
  121044. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121045. kernel: number[];
  121046. /**
  121047. * Creates a new instance ConvolutionPostProcess
  121048. * @param name The name of the effect.
  121049. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  121050. * @param options The required width/height ratio to downsize to before computing the render pass.
  121051. * @param camera The camera to apply the render pass to.
  121052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121053. * @param engine The engine which the post process will be applied. (default: current engine)
  121054. * @param reusable If the post process can be reused on the same frame. (default: false)
  121055. * @param textureType Type of textures used when performing the post process. (default: 0)
  121056. */
  121057. constructor(name: string,
  121058. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  121059. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121060. /**
  121061. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121062. */
  121063. static EdgeDetect0Kernel: number[];
  121064. /**
  121065. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121066. */
  121067. static EdgeDetect1Kernel: number[];
  121068. /**
  121069. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121070. */
  121071. static EdgeDetect2Kernel: number[];
  121072. /**
  121073. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121074. */
  121075. static SharpenKernel: number[];
  121076. /**
  121077. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121078. */
  121079. static EmbossKernel: number[];
  121080. /**
  121081. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  121082. */
  121083. static GaussianKernel: number[];
  121084. }
  121085. }
  121086. declare module BABYLON {
  121087. /**
  121088. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  121089. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  121090. * based on samples that have a large difference in distance than the center pixel.
  121091. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  121092. */
  121093. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  121094. direction: Vector2;
  121095. /**
  121096. * Creates a new instance CircleOfConfusionPostProcess
  121097. * @param name The name of the effect.
  121098. * @param scene The scene the effect belongs to.
  121099. * @param direction The direction the blur should be applied.
  121100. * @param kernel The size of the kernel used to blur.
  121101. * @param options The required width/height ratio to downsize to before computing the render pass.
  121102. * @param camera The camera to apply the render pass to.
  121103. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  121104. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  121105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121106. * @param engine The engine which the post process will be applied. (default: current engine)
  121107. * @param reusable If the post process can be reused on the same frame. (default: false)
  121108. * @param textureType Type of textures used when performing the post process. (default: 0)
  121109. * @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)
  121110. */
  121111. 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);
  121112. }
  121113. }
  121114. declare module BABYLON {
  121115. /** @hidden */
  121116. export var depthOfFieldMergePixelShader: {
  121117. name: string;
  121118. shader: string;
  121119. };
  121120. }
  121121. declare module BABYLON {
  121122. /**
  121123. * Options to be set when merging outputs from the default pipeline.
  121124. */
  121125. export class DepthOfFieldMergePostProcessOptions {
  121126. /**
  121127. * The original image to merge on top of
  121128. */
  121129. originalFromInput: PostProcess;
  121130. /**
  121131. * Parameters to perform the merge of the depth of field effect
  121132. */
  121133. depthOfField?: {
  121134. circleOfConfusion: PostProcess;
  121135. blurSteps: Array<PostProcess>;
  121136. };
  121137. /**
  121138. * Parameters to perform the merge of bloom effect
  121139. */
  121140. bloom?: {
  121141. blurred: PostProcess;
  121142. weight: number;
  121143. };
  121144. }
  121145. /**
  121146. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  121147. */
  121148. export class DepthOfFieldMergePostProcess extends PostProcess {
  121149. private blurSteps;
  121150. /**
  121151. * Creates a new instance of DepthOfFieldMergePostProcess
  121152. * @param name The name of the effect.
  121153. * @param originalFromInput Post process which's input will be used for the merge.
  121154. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  121155. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  121156. * @param options The required width/height ratio to downsize to before computing the render pass.
  121157. * @param camera The camera to apply the render pass to.
  121158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121159. * @param engine The engine which the post process will be applied. (default: current engine)
  121160. * @param reusable If the post process can be reused on the same frame. (default: false)
  121161. * @param textureType Type of textures used when performing the post process. (default: 0)
  121162. * @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)
  121163. */
  121164. 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);
  121165. /**
  121166. * Updates the effect with the current post process compile time values and recompiles the shader.
  121167. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  121168. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  121169. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  121170. * @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
  121171. * @param onCompiled Called when the shader has been compiled.
  121172. * @param onError Called if there is an error when compiling a shader.
  121173. */
  121174. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  121175. }
  121176. }
  121177. declare module BABYLON {
  121178. /**
  121179. * Specifies the level of max blur that should be applied when using the depth of field effect
  121180. */
  121181. export enum DepthOfFieldEffectBlurLevel {
  121182. /**
  121183. * Subtle blur
  121184. */
  121185. Low = 0,
  121186. /**
  121187. * Medium blur
  121188. */
  121189. Medium = 1,
  121190. /**
  121191. * Large blur
  121192. */
  121193. High = 2
  121194. }
  121195. /**
  121196. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  121197. */
  121198. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  121199. private _circleOfConfusion;
  121200. /**
  121201. * @hidden Internal, blurs from high to low
  121202. */
  121203. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  121204. private _depthOfFieldBlurY;
  121205. private _dofMerge;
  121206. /**
  121207. * @hidden Internal post processes in depth of field effect
  121208. */
  121209. _effects: Array<PostProcess>;
  121210. /**
  121211. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  121212. */
  121213. focalLength: number;
  121214. /**
  121215. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  121216. */
  121217. fStop: number;
  121218. /**
  121219. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  121220. */
  121221. focusDistance: number;
  121222. /**
  121223. * 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.
  121224. */
  121225. lensSize: number;
  121226. /**
  121227. * Creates a new instance DepthOfFieldEffect
  121228. * @param scene The scene the effect belongs to.
  121229. * @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.
  121230. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  121231. * @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)
  121232. */
  121233. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  121234. /**
  121235. * Get the current class name of the current effet
  121236. * @returns "DepthOfFieldEffect"
  121237. */
  121238. getClassName(): string;
  121239. /**
  121240. * 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.
  121241. */
  121242. depthTexture: RenderTargetTexture;
  121243. /**
  121244. * Disposes each of the internal effects for a given camera.
  121245. * @param camera The camera to dispose the effect on.
  121246. */
  121247. disposeEffects(camera: Camera): void;
  121248. /**
  121249. * @hidden Internal
  121250. */
  121251. _updateEffects(): void;
  121252. /**
  121253. * Internal
  121254. * @returns if all the contained post processes are ready.
  121255. * @hidden
  121256. */
  121257. _isReady(): boolean;
  121258. }
  121259. }
  121260. declare module BABYLON {
  121261. /** @hidden */
  121262. export var displayPassPixelShader: {
  121263. name: string;
  121264. shader: string;
  121265. };
  121266. }
  121267. declare module BABYLON {
  121268. /**
  121269. * DisplayPassPostProcess which produces an output the same as it's input
  121270. */
  121271. export class DisplayPassPostProcess extends PostProcess {
  121272. /**
  121273. * Creates the DisplayPassPostProcess
  121274. * @param name The name of the effect.
  121275. * @param options The required width/height ratio to downsize to before computing the render pass.
  121276. * @param camera The camera to apply the render pass to.
  121277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121278. * @param engine The engine which the post process will be applied. (default: current engine)
  121279. * @param reusable If the post process can be reused on the same frame. (default: false)
  121280. */
  121281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121282. }
  121283. }
  121284. declare module BABYLON {
  121285. /** @hidden */
  121286. export var filterPixelShader: {
  121287. name: string;
  121288. shader: string;
  121289. };
  121290. }
  121291. declare module BABYLON {
  121292. /**
  121293. * Applies a kernel filter to the image
  121294. */
  121295. export class FilterPostProcess extends PostProcess {
  121296. /** The matrix to be applied to the image */
  121297. kernelMatrix: Matrix;
  121298. /**
  121299. *
  121300. * @param name The name of the effect.
  121301. * @param kernelMatrix The matrix to be applied to the image
  121302. * @param options The required width/height ratio to downsize to before computing the render pass.
  121303. * @param camera The camera to apply the render pass to.
  121304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121305. * @param engine The engine which the post process will be applied. (default: current engine)
  121306. * @param reusable If the post process can be reused on the same frame. (default: false)
  121307. */
  121308. constructor(name: string,
  121309. /** The matrix to be applied to the image */
  121310. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121311. }
  121312. }
  121313. declare module BABYLON {
  121314. /** @hidden */
  121315. export var fxaaPixelShader: {
  121316. name: string;
  121317. shader: string;
  121318. };
  121319. }
  121320. declare module BABYLON {
  121321. /** @hidden */
  121322. export var fxaaVertexShader: {
  121323. name: string;
  121324. shader: string;
  121325. };
  121326. }
  121327. declare module BABYLON {
  121328. /**
  121329. * Fxaa post process
  121330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  121331. */
  121332. export class FxaaPostProcess extends PostProcess {
  121333. /** @hidden */
  121334. texelWidth: number;
  121335. /** @hidden */
  121336. texelHeight: number;
  121337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121338. private _getDefines;
  121339. }
  121340. }
  121341. declare module BABYLON {
  121342. /** @hidden */
  121343. export var grainPixelShader: {
  121344. name: string;
  121345. shader: string;
  121346. };
  121347. }
  121348. declare module BABYLON {
  121349. /**
  121350. * The GrainPostProcess adds noise to the image at mid luminance levels
  121351. */
  121352. export class GrainPostProcess extends PostProcess {
  121353. /**
  121354. * The intensity of the grain added (default: 30)
  121355. */
  121356. intensity: number;
  121357. /**
  121358. * If the grain should be randomized on every frame
  121359. */
  121360. animated: boolean;
  121361. /**
  121362. * Creates a new instance of @see GrainPostProcess
  121363. * @param name The name of the effect.
  121364. * @param options The required width/height ratio to downsize to before computing the render pass.
  121365. * @param camera The camera to apply the render pass to.
  121366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121367. * @param engine The engine which the post process will be applied. (default: current engine)
  121368. * @param reusable If the post process can be reused on the same frame. (default: false)
  121369. * @param textureType Type of textures used when performing the post process. (default: 0)
  121370. * @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)
  121371. */
  121372. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121373. }
  121374. }
  121375. declare module BABYLON {
  121376. /** @hidden */
  121377. export var highlightsPixelShader: {
  121378. name: string;
  121379. shader: string;
  121380. };
  121381. }
  121382. declare module BABYLON {
  121383. /**
  121384. * Extracts highlights from the image
  121385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121386. */
  121387. export class HighlightsPostProcess extends PostProcess {
  121388. /**
  121389. * Extracts highlights from the image
  121390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  121391. * @param name The name of the effect.
  121392. * @param options The required width/height ratio to downsize to before computing the render pass.
  121393. * @param camera The camera to apply the render pass to.
  121394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121395. * @param engine The engine which the post process will be applied. (default: current engine)
  121396. * @param reusable If the post process can be reused on the same frame. (default: false)
  121397. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  121398. */
  121399. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  121400. }
  121401. }
  121402. declare module BABYLON {
  121403. /** @hidden */
  121404. export var mrtFragmentDeclaration: {
  121405. name: string;
  121406. shader: string;
  121407. };
  121408. }
  121409. declare module BABYLON {
  121410. /** @hidden */
  121411. export var geometryPixelShader: {
  121412. name: string;
  121413. shader: string;
  121414. };
  121415. }
  121416. declare module BABYLON {
  121417. /** @hidden */
  121418. export var geometryVertexShader: {
  121419. name: string;
  121420. shader: string;
  121421. };
  121422. }
  121423. declare module BABYLON {
  121424. /** @hidden */
  121425. interface ISavedTransformationMatrix {
  121426. world: Matrix;
  121427. viewProjection: Matrix;
  121428. }
  121429. /**
  121430. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121431. */
  121432. export class GeometryBufferRenderer {
  121433. /**
  121434. * Constant used to retrieve the position texture index in the G-Buffer textures array
  121435. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  121436. */
  121437. static readonly POSITION_TEXTURE_TYPE: number;
  121438. /**
  121439. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  121440. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  121441. */
  121442. static readonly VELOCITY_TEXTURE_TYPE: number;
  121443. /**
  121444. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121445. * in order to compute objects velocities when enableVelocity is set to "true"
  121446. * @hidden
  121447. */
  121448. _previousTransformationMatrices: {
  121449. [index: number]: ISavedTransformationMatrix;
  121450. };
  121451. /**
  121452. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  121453. * in order to compute objects velocities when enableVelocity is set to "true"
  121454. * @hidden
  121455. */
  121456. _previousBonesTransformationMatrices: {
  121457. [index: number]: Float32Array;
  121458. };
  121459. /**
  121460. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  121461. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  121462. */
  121463. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  121464. private _scene;
  121465. private _multiRenderTarget;
  121466. private _ratio;
  121467. private _enablePosition;
  121468. private _enableVelocity;
  121469. private _positionIndex;
  121470. private _velocityIndex;
  121471. protected _effect: Effect;
  121472. protected _cachedDefines: string;
  121473. /**
  121474. * Set the render list (meshes to be rendered) used in the G buffer.
  121475. */
  121476. renderList: Mesh[];
  121477. /**
  121478. * Gets wether or not G buffer are supported by the running hardware.
  121479. * This requires draw buffer supports
  121480. */
  121481. readonly isSupported: boolean;
  121482. /**
  121483. * Returns the index of the given texture type in the G-Buffer textures array
  121484. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121485. * @returns the index of the given texture type in the G-Buffer textures array
  121486. */
  121487. getTextureIndex(textureType: number): number;
  121488. /**
  121489. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121490. */
  121491. /**
  121492. * Sets whether or not objects positions are enabled for the G buffer.
  121493. */
  121494. enablePosition: boolean;
  121495. /**
  121496. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121497. */
  121498. /**
  121499. * Sets wether or not objects velocities are enabled for the G buffer.
  121500. */
  121501. enableVelocity: boolean;
  121502. /**
  121503. * Gets the scene associated with the buffer.
  121504. */
  121505. readonly scene: Scene;
  121506. /**
  121507. * Gets the ratio used by the buffer during its creation.
  121508. * How big is the buffer related to the main canvas.
  121509. */
  121510. readonly ratio: number;
  121511. /** @hidden */
  121512. static _SceneComponentInitialization: (scene: Scene) => void;
  121513. /**
  121514. * Creates a new G Buffer for the scene
  121515. * @param scene The scene the buffer belongs to
  121516. * @param ratio How big is the buffer related to the main canvas.
  121517. */
  121518. constructor(scene: Scene, ratio?: number);
  121519. /**
  121520. * Checks wether everything is ready to render a submesh to the G buffer.
  121521. * @param subMesh the submesh to check readiness for
  121522. * @param useInstances is the mesh drawn using instance or not
  121523. * @returns true if ready otherwise false
  121524. */
  121525. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  121526. /**
  121527. * Gets the current underlying G Buffer.
  121528. * @returns the buffer
  121529. */
  121530. getGBuffer(): MultiRenderTarget;
  121531. /**
  121532. * Gets the number of samples used to render the buffer (anti aliasing).
  121533. */
  121534. /**
  121535. * Sets the number of samples used to render the buffer (anti aliasing).
  121536. */
  121537. samples: number;
  121538. /**
  121539. * Disposes the renderer and frees up associated resources.
  121540. */
  121541. dispose(): void;
  121542. protected _createRenderTargets(): void;
  121543. private _copyBonesTransformationMatrices;
  121544. }
  121545. }
  121546. declare module BABYLON {
  121547. interface Scene {
  121548. /** @hidden (Backing field) */
  121549. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121550. /**
  121551. * Gets or Sets the current geometry buffer associated to the scene.
  121552. */
  121553. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  121554. /**
  121555. * Enables a GeometryBufferRender and associates it with the scene
  121556. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  121557. * @returns the GeometryBufferRenderer
  121558. */
  121559. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  121560. /**
  121561. * Disables the GeometryBufferRender associated with the scene
  121562. */
  121563. disableGeometryBufferRenderer(): void;
  121564. }
  121565. /**
  121566. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  121567. * in several rendering techniques.
  121568. */
  121569. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  121570. /**
  121571. * The component name helpful to identify the component in the list of scene components.
  121572. */
  121573. readonly name: string;
  121574. /**
  121575. * The scene the component belongs to.
  121576. */
  121577. scene: Scene;
  121578. /**
  121579. * Creates a new instance of the component for the given scene
  121580. * @param scene Defines the scene to register the component in
  121581. */
  121582. constructor(scene: Scene);
  121583. /**
  121584. * Registers the component in a given scene
  121585. */
  121586. register(): void;
  121587. /**
  121588. * Rebuilds the elements related to this component in case of
  121589. * context lost for instance.
  121590. */
  121591. rebuild(): void;
  121592. /**
  121593. * Disposes the component and the associated ressources
  121594. */
  121595. dispose(): void;
  121596. private _gatherRenderTargets;
  121597. }
  121598. }
  121599. declare module BABYLON {
  121600. /** @hidden */
  121601. export var motionBlurPixelShader: {
  121602. name: string;
  121603. shader: string;
  121604. };
  121605. }
  121606. declare module BABYLON {
  121607. /**
  121608. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  121609. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  121610. * As an example, all you have to do is to create the post-process:
  121611. * var mb = new BABYLON.MotionBlurPostProcess(
  121612. * 'mb', // The name of the effect.
  121613. * scene, // The scene containing the objects to blur according to their velocity.
  121614. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  121615. * camera // The camera to apply the render pass to.
  121616. * );
  121617. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  121618. */
  121619. export class MotionBlurPostProcess extends PostProcess {
  121620. /**
  121621. * Defines how much the image is blurred by the movement. Default value is equal to 1
  121622. */
  121623. motionStrength: number;
  121624. /**
  121625. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  121626. */
  121627. /**
  121628. * Sets the number of iterations to be used for motion blur quality
  121629. */
  121630. motionBlurSamples: number;
  121631. private _motionBlurSamples;
  121632. private _geometryBufferRenderer;
  121633. /**
  121634. * Creates a new instance MotionBlurPostProcess
  121635. * @param name The name of the effect.
  121636. * @param scene The scene containing the objects to blur according to their velocity.
  121637. * @param options The required width/height ratio to downsize to before computing the render pass.
  121638. * @param camera The camera to apply the render pass to.
  121639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121640. * @param engine The engine which the post process will be applied. (default: current engine)
  121641. * @param reusable If the post process can be reused on the same frame. (default: false)
  121642. * @param textureType Type of textures used when performing the post process. (default: 0)
  121643. * @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)
  121644. */
  121645. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121646. /**
  121647. * Excludes the given skinned mesh from computing bones velocities.
  121648. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  121649. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  121650. */
  121651. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121652. /**
  121653. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  121654. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  121655. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  121656. */
  121657. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121658. /**
  121659. * Disposes the post process.
  121660. * @param camera The camera to dispose the post process on.
  121661. */
  121662. dispose(camera?: Camera): void;
  121663. }
  121664. }
  121665. declare module BABYLON {
  121666. /** @hidden */
  121667. export var refractionPixelShader: {
  121668. name: string;
  121669. shader: string;
  121670. };
  121671. }
  121672. declare module BABYLON {
  121673. /**
  121674. * Post process which applies a refractin texture
  121675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121676. */
  121677. export class RefractionPostProcess extends PostProcess {
  121678. /** the base color of the refraction (used to taint the rendering) */
  121679. color: Color3;
  121680. /** simulated refraction depth */
  121681. depth: number;
  121682. /** the coefficient of the base color (0 to remove base color tainting) */
  121683. colorLevel: number;
  121684. private _refTexture;
  121685. private _ownRefractionTexture;
  121686. /**
  121687. * Gets or sets the refraction texture
  121688. * Please note that you are responsible for disposing the texture if you set it manually
  121689. */
  121690. refractionTexture: Texture;
  121691. /**
  121692. * Initializes the RefractionPostProcess
  121693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121694. * @param name The name of the effect.
  121695. * @param refractionTextureUrl Url of the refraction texture to use
  121696. * @param color the base color of the refraction (used to taint the rendering)
  121697. * @param depth simulated refraction depth
  121698. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  121699. * @param camera The camera to apply the render pass to.
  121700. * @param options The required width/height ratio to downsize to before computing the render pass.
  121701. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121702. * @param engine The engine which the post process will be applied. (default: current engine)
  121703. * @param reusable If the post process can be reused on the same frame. (default: false)
  121704. */
  121705. constructor(name: string, refractionTextureUrl: string,
  121706. /** the base color of the refraction (used to taint the rendering) */
  121707. color: Color3,
  121708. /** simulated refraction depth */
  121709. depth: number,
  121710. /** the coefficient of the base color (0 to remove base color tainting) */
  121711. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121712. /**
  121713. * Disposes of the post process
  121714. * @param camera Camera to dispose post process on
  121715. */
  121716. dispose(camera: Camera): void;
  121717. }
  121718. }
  121719. declare module BABYLON {
  121720. /** @hidden */
  121721. export var sharpenPixelShader: {
  121722. name: string;
  121723. shader: string;
  121724. };
  121725. }
  121726. declare module BABYLON {
  121727. /**
  121728. * The SharpenPostProcess applies a sharpen kernel to every pixel
  121729. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121730. */
  121731. export class SharpenPostProcess extends PostProcess {
  121732. /**
  121733. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  121734. */
  121735. colorAmount: number;
  121736. /**
  121737. * How much sharpness should be applied (default: 0.3)
  121738. */
  121739. edgeAmount: number;
  121740. /**
  121741. * Creates a new instance ConvolutionPostProcess
  121742. * @param name The name of the effect.
  121743. * @param options The required width/height ratio to downsize to before computing the render pass.
  121744. * @param camera The camera to apply the render pass to.
  121745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121746. * @param engine The engine which the post process will be applied. (default: current engine)
  121747. * @param reusable If the post process can be reused on the same frame. (default: false)
  121748. * @param textureType Type of textures used when performing the post process. (default: 0)
  121749. * @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)
  121750. */
  121751. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121752. }
  121753. }
  121754. declare module BABYLON {
  121755. /**
  121756. * PostProcessRenderPipeline
  121757. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121758. */
  121759. export class PostProcessRenderPipeline {
  121760. private engine;
  121761. private _renderEffects;
  121762. private _renderEffectsForIsolatedPass;
  121763. /**
  121764. * List of inspectable custom properties (used by the Inspector)
  121765. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121766. */
  121767. inspectableCustomProperties: IInspectable[];
  121768. /**
  121769. * @hidden
  121770. */
  121771. protected _cameras: Camera[];
  121772. /** @hidden */
  121773. _name: string;
  121774. /**
  121775. * Gets pipeline name
  121776. */
  121777. readonly name: string;
  121778. /**
  121779. * Initializes a PostProcessRenderPipeline
  121780. * @param engine engine to add the pipeline to
  121781. * @param name name of the pipeline
  121782. */
  121783. constructor(engine: Engine, name: string);
  121784. /**
  121785. * Gets the class name
  121786. * @returns "PostProcessRenderPipeline"
  121787. */
  121788. getClassName(): string;
  121789. /**
  121790. * If all the render effects in the pipeline are supported
  121791. */
  121792. readonly isSupported: boolean;
  121793. /**
  121794. * Adds an effect to the pipeline
  121795. * @param renderEffect the effect to add
  121796. */
  121797. addEffect(renderEffect: PostProcessRenderEffect): void;
  121798. /** @hidden */
  121799. _rebuild(): void;
  121800. /** @hidden */
  121801. _enableEffect(renderEffectName: string, cameras: Camera): void;
  121802. /** @hidden */
  121803. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  121804. /** @hidden */
  121805. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121806. /** @hidden */
  121807. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121808. /** @hidden */
  121809. _attachCameras(cameras: Camera, unique: boolean): void;
  121810. /** @hidden */
  121811. _attachCameras(cameras: Camera[], unique: boolean): void;
  121812. /** @hidden */
  121813. _detachCameras(cameras: Camera): void;
  121814. /** @hidden */
  121815. _detachCameras(cameras: Nullable<Camera[]>): void;
  121816. /** @hidden */
  121817. _update(): void;
  121818. /** @hidden */
  121819. _reset(): void;
  121820. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  121821. /**
  121822. * Disposes of the pipeline
  121823. */
  121824. dispose(): void;
  121825. }
  121826. }
  121827. declare module BABYLON {
  121828. /**
  121829. * PostProcessRenderPipelineManager class
  121830. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121831. */
  121832. export class PostProcessRenderPipelineManager {
  121833. private _renderPipelines;
  121834. /**
  121835. * Initializes a PostProcessRenderPipelineManager
  121836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121837. */
  121838. constructor();
  121839. /**
  121840. * Gets the list of supported render pipelines
  121841. */
  121842. readonly supportedPipelines: PostProcessRenderPipeline[];
  121843. /**
  121844. * Adds a pipeline to the manager
  121845. * @param renderPipeline The pipeline to add
  121846. */
  121847. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  121848. /**
  121849. * Attaches a camera to the pipeline
  121850. * @param renderPipelineName The name of the pipeline to attach to
  121851. * @param cameras the camera to attach
  121852. * @param unique if the camera can be attached multiple times to the pipeline
  121853. */
  121854. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  121855. /**
  121856. * Detaches a camera from the pipeline
  121857. * @param renderPipelineName The name of the pipeline to detach from
  121858. * @param cameras the camera to detach
  121859. */
  121860. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  121861. /**
  121862. * Enables an effect by name on a pipeline
  121863. * @param renderPipelineName the name of the pipeline to enable the effect in
  121864. * @param renderEffectName the name of the effect to enable
  121865. * @param cameras the cameras that the effect should be enabled on
  121866. */
  121867. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121868. /**
  121869. * Disables an effect by name on a pipeline
  121870. * @param renderPipelineName the name of the pipeline to disable the effect in
  121871. * @param renderEffectName the name of the effect to disable
  121872. * @param cameras the cameras that the effect should be disabled on
  121873. */
  121874. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121875. /**
  121876. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121877. */
  121878. update(): void;
  121879. /** @hidden */
  121880. _rebuild(): void;
  121881. /**
  121882. * Disposes of the manager and pipelines
  121883. */
  121884. dispose(): void;
  121885. }
  121886. }
  121887. declare module BABYLON {
  121888. interface Scene {
  121889. /** @hidden (Backing field) */
  121890. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121891. /**
  121892. * Gets the postprocess render pipeline manager
  121893. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121894. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121895. */
  121896. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121897. }
  121898. /**
  121899. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121900. */
  121901. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121902. /**
  121903. * The component name helpfull to identify the component in the list of scene components.
  121904. */
  121905. readonly name: string;
  121906. /**
  121907. * The scene the component belongs to.
  121908. */
  121909. scene: Scene;
  121910. /**
  121911. * Creates a new instance of the component for the given scene
  121912. * @param scene Defines the scene to register the component in
  121913. */
  121914. constructor(scene: Scene);
  121915. /**
  121916. * Registers the component in a given scene
  121917. */
  121918. register(): void;
  121919. /**
  121920. * Rebuilds the elements related to this component in case of
  121921. * context lost for instance.
  121922. */
  121923. rebuild(): void;
  121924. /**
  121925. * Disposes the component and the associated ressources
  121926. */
  121927. dispose(): void;
  121928. private _gatherRenderTargets;
  121929. }
  121930. }
  121931. declare module BABYLON {
  121932. /**
  121933. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121934. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121935. */
  121936. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121937. private _scene;
  121938. private _camerasToBeAttached;
  121939. /**
  121940. * ID of the sharpen post process,
  121941. */
  121942. private readonly SharpenPostProcessId;
  121943. /**
  121944. * @ignore
  121945. * ID of the image processing post process;
  121946. */
  121947. readonly ImageProcessingPostProcessId: string;
  121948. /**
  121949. * @ignore
  121950. * ID of the Fast Approximate Anti-Aliasing post process;
  121951. */
  121952. readonly FxaaPostProcessId: string;
  121953. /**
  121954. * ID of the chromatic aberration post process,
  121955. */
  121956. private readonly ChromaticAberrationPostProcessId;
  121957. /**
  121958. * ID of the grain post process
  121959. */
  121960. private readonly GrainPostProcessId;
  121961. /**
  121962. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121963. */
  121964. sharpen: SharpenPostProcess;
  121965. private _sharpenEffect;
  121966. private bloom;
  121967. /**
  121968. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121969. */
  121970. depthOfField: DepthOfFieldEffect;
  121971. /**
  121972. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121973. */
  121974. fxaa: FxaaPostProcess;
  121975. /**
  121976. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121977. */
  121978. imageProcessing: ImageProcessingPostProcess;
  121979. /**
  121980. * Chromatic aberration post process which will shift rgb colors in the image
  121981. */
  121982. chromaticAberration: ChromaticAberrationPostProcess;
  121983. private _chromaticAberrationEffect;
  121984. /**
  121985. * Grain post process which add noise to the image
  121986. */
  121987. grain: GrainPostProcess;
  121988. private _grainEffect;
  121989. /**
  121990. * Glow post process which adds a glow to emissive areas of the image
  121991. */
  121992. private _glowLayer;
  121993. /**
  121994. * Animations which can be used to tweak settings over a period of time
  121995. */
  121996. animations: Animation[];
  121997. private _imageProcessingConfigurationObserver;
  121998. private _sharpenEnabled;
  121999. private _bloomEnabled;
  122000. private _depthOfFieldEnabled;
  122001. private _depthOfFieldBlurLevel;
  122002. private _fxaaEnabled;
  122003. private _imageProcessingEnabled;
  122004. private _defaultPipelineTextureType;
  122005. private _bloomScale;
  122006. private _chromaticAberrationEnabled;
  122007. private _grainEnabled;
  122008. private _buildAllowed;
  122009. /**
  122010. * Gets active scene
  122011. */
  122012. readonly scene: Scene;
  122013. /**
  122014. * Enable or disable the sharpen process from the pipeline
  122015. */
  122016. sharpenEnabled: boolean;
  122017. private _resizeObserver;
  122018. private _hardwareScaleLevel;
  122019. private _bloomKernel;
  122020. /**
  122021. * Specifies the size of the bloom blur kernel, relative to the final output size
  122022. */
  122023. bloomKernel: number;
  122024. /**
  122025. * Specifies the weight of the bloom in the final rendering
  122026. */
  122027. private _bloomWeight;
  122028. /**
  122029. * Specifies the luma threshold for the area that will be blurred by the bloom
  122030. */
  122031. private _bloomThreshold;
  122032. private _hdr;
  122033. /**
  122034. * The strength of the bloom.
  122035. */
  122036. bloomWeight: number;
  122037. /**
  122038. * The strength of the bloom.
  122039. */
  122040. bloomThreshold: number;
  122041. /**
  122042. * The scale of the bloom, lower value will provide better performance.
  122043. */
  122044. bloomScale: number;
  122045. /**
  122046. * Enable or disable the bloom from the pipeline
  122047. */
  122048. bloomEnabled: boolean;
  122049. private _rebuildBloom;
  122050. /**
  122051. * If the depth of field is enabled.
  122052. */
  122053. depthOfFieldEnabled: boolean;
  122054. /**
  122055. * Blur level of the depth of field effect. (Higher blur will effect performance)
  122056. */
  122057. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  122058. /**
  122059. * If the anti aliasing is enabled.
  122060. */
  122061. fxaaEnabled: boolean;
  122062. private _samples;
  122063. /**
  122064. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122065. */
  122066. samples: number;
  122067. /**
  122068. * If image processing is enabled.
  122069. */
  122070. imageProcessingEnabled: boolean;
  122071. /**
  122072. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  122073. */
  122074. glowLayerEnabled: boolean;
  122075. /**
  122076. * Gets the glow layer (or null if not defined)
  122077. */
  122078. readonly glowLayer: Nullable<GlowLayer>;
  122079. /**
  122080. * Enable or disable the chromaticAberration process from the pipeline
  122081. */
  122082. chromaticAberrationEnabled: boolean;
  122083. /**
  122084. * Enable or disable the grain process from the pipeline
  122085. */
  122086. grainEnabled: boolean;
  122087. /**
  122088. * @constructor
  122089. * @param name - The rendering pipeline name (default: "")
  122090. * @param hdr - If high dynamic range textures should be used (default: true)
  122091. * @param scene - The scene linked to this pipeline (default: the last created scene)
  122092. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  122093. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  122094. */
  122095. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  122096. /**
  122097. * Get the class name
  122098. * @returns "DefaultRenderingPipeline"
  122099. */
  122100. getClassName(): string;
  122101. /**
  122102. * Force the compilation of the entire pipeline.
  122103. */
  122104. prepare(): void;
  122105. private _hasCleared;
  122106. private _prevPostProcess;
  122107. private _prevPrevPostProcess;
  122108. private _setAutoClearAndTextureSharing;
  122109. private _depthOfFieldSceneObserver;
  122110. private _buildPipeline;
  122111. private _disposePostProcesses;
  122112. /**
  122113. * Adds a camera to the pipeline
  122114. * @param camera the camera to be added
  122115. */
  122116. addCamera(camera: Camera): void;
  122117. /**
  122118. * Removes a camera from the pipeline
  122119. * @param camera the camera to remove
  122120. */
  122121. removeCamera(camera: Camera): void;
  122122. /**
  122123. * Dispose of the pipeline and stop all post processes
  122124. */
  122125. dispose(): void;
  122126. /**
  122127. * Serialize the rendering pipeline (Used when exporting)
  122128. * @returns the serialized object
  122129. */
  122130. serialize(): any;
  122131. /**
  122132. * Parse the serialized pipeline
  122133. * @param source Source pipeline.
  122134. * @param scene The scene to load the pipeline to.
  122135. * @param rootUrl The URL of the serialized pipeline.
  122136. * @returns An instantiated pipeline from the serialized object.
  122137. */
  122138. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  122139. }
  122140. }
  122141. declare module BABYLON {
  122142. /** @hidden */
  122143. export var lensHighlightsPixelShader: {
  122144. name: string;
  122145. shader: string;
  122146. };
  122147. }
  122148. declare module BABYLON {
  122149. /** @hidden */
  122150. export var depthOfFieldPixelShader: {
  122151. name: string;
  122152. shader: string;
  122153. };
  122154. }
  122155. declare module BABYLON {
  122156. /**
  122157. * BABYLON.JS Chromatic Aberration GLSL Shader
  122158. * Author: Olivier Guyot
  122159. * Separates very slightly R, G and B colors on the edges of the screen
  122160. * Inspired by Francois Tarlier & Martins Upitis
  122161. */
  122162. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  122163. /**
  122164. * @ignore
  122165. * The chromatic aberration PostProcess id in the pipeline
  122166. */
  122167. LensChromaticAberrationEffect: string;
  122168. /**
  122169. * @ignore
  122170. * The highlights enhancing PostProcess id in the pipeline
  122171. */
  122172. HighlightsEnhancingEffect: string;
  122173. /**
  122174. * @ignore
  122175. * The depth-of-field PostProcess id in the pipeline
  122176. */
  122177. LensDepthOfFieldEffect: string;
  122178. private _scene;
  122179. private _depthTexture;
  122180. private _grainTexture;
  122181. private _chromaticAberrationPostProcess;
  122182. private _highlightsPostProcess;
  122183. private _depthOfFieldPostProcess;
  122184. private _edgeBlur;
  122185. private _grainAmount;
  122186. private _chromaticAberration;
  122187. private _distortion;
  122188. private _highlightsGain;
  122189. private _highlightsThreshold;
  122190. private _dofDistance;
  122191. private _dofAperture;
  122192. private _dofDarken;
  122193. private _dofPentagon;
  122194. private _blurNoise;
  122195. /**
  122196. * @constructor
  122197. *
  122198. * Effect parameters are as follow:
  122199. * {
  122200. * chromatic_aberration: number; // from 0 to x (1 for realism)
  122201. * edge_blur: number; // from 0 to x (1 for realism)
  122202. * distortion: number; // from 0 to x (1 for realism)
  122203. * grain_amount: number; // from 0 to 1
  122204. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  122205. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  122206. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  122207. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  122208. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  122209. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  122210. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  122211. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  122212. * }
  122213. * Note: if an effect parameter is unset, effect is disabled
  122214. *
  122215. * @param name The rendering pipeline name
  122216. * @param parameters - An object containing all parameters (see above)
  122217. * @param scene The scene linked to this pipeline
  122218. * @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)
  122219. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122220. */
  122221. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  122222. /**
  122223. * Get the class name
  122224. * @returns "LensRenderingPipeline"
  122225. */
  122226. getClassName(): string;
  122227. /**
  122228. * Gets associated scene
  122229. */
  122230. readonly scene: Scene;
  122231. /**
  122232. * Gets or sets the edge blur
  122233. */
  122234. edgeBlur: number;
  122235. /**
  122236. * Gets or sets the grain amount
  122237. */
  122238. grainAmount: number;
  122239. /**
  122240. * Gets or sets the chromatic aberration amount
  122241. */
  122242. chromaticAberration: number;
  122243. /**
  122244. * Gets or sets the depth of field aperture
  122245. */
  122246. dofAperture: number;
  122247. /**
  122248. * Gets or sets the edge distortion
  122249. */
  122250. edgeDistortion: number;
  122251. /**
  122252. * Gets or sets the depth of field distortion
  122253. */
  122254. dofDistortion: number;
  122255. /**
  122256. * Gets or sets the darken out of focus amount
  122257. */
  122258. darkenOutOfFocus: number;
  122259. /**
  122260. * Gets or sets a boolean indicating if blur noise is enabled
  122261. */
  122262. blurNoise: boolean;
  122263. /**
  122264. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  122265. */
  122266. pentagonBokeh: boolean;
  122267. /**
  122268. * Gets or sets the highlight grain amount
  122269. */
  122270. highlightsGain: number;
  122271. /**
  122272. * Gets or sets the highlight threshold
  122273. */
  122274. highlightsThreshold: number;
  122275. /**
  122276. * Sets the amount of blur at the edges
  122277. * @param amount blur amount
  122278. */
  122279. setEdgeBlur(amount: number): void;
  122280. /**
  122281. * Sets edge blur to 0
  122282. */
  122283. disableEdgeBlur(): void;
  122284. /**
  122285. * Sets the amout of grain
  122286. * @param amount Amount of grain
  122287. */
  122288. setGrainAmount(amount: number): void;
  122289. /**
  122290. * Set grain amount to 0
  122291. */
  122292. disableGrain(): void;
  122293. /**
  122294. * Sets the chromatic aberration amount
  122295. * @param amount amount of chromatic aberration
  122296. */
  122297. setChromaticAberration(amount: number): void;
  122298. /**
  122299. * Sets chromatic aberration amount to 0
  122300. */
  122301. disableChromaticAberration(): void;
  122302. /**
  122303. * Sets the EdgeDistortion amount
  122304. * @param amount amount of EdgeDistortion
  122305. */
  122306. setEdgeDistortion(amount: number): void;
  122307. /**
  122308. * Sets edge distortion to 0
  122309. */
  122310. disableEdgeDistortion(): void;
  122311. /**
  122312. * Sets the FocusDistance amount
  122313. * @param amount amount of FocusDistance
  122314. */
  122315. setFocusDistance(amount: number): void;
  122316. /**
  122317. * Disables depth of field
  122318. */
  122319. disableDepthOfField(): void;
  122320. /**
  122321. * Sets the Aperture amount
  122322. * @param amount amount of Aperture
  122323. */
  122324. setAperture(amount: number): void;
  122325. /**
  122326. * Sets the DarkenOutOfFocus amount
  122327. * @param amount amount of DarkenOutOfFocus
  122328. */
  122329. setDarkenOutOfFocus(amount: number): void;
  122330. private _pentagonBokehIsEnabled;
  122331. /**
  122332. * Creates a pentagon bokeh effect
  122333. */
  122334. enablePentagonBokeh(): void;
  122335. /**
  122336. * Disables the pentagon bokeh effect
  122337. */
  122338. disablePentagonBokeh(): void;
  122339. /**
  122340. * Enables noise blur
  122341. */
  122342. enableNoiseBlur(): void;
  122343. /**
  122344. * Disables noise blur
  122345. */
  122346. disableNoiseBlur(): void;
  122347. /**
  122348. * Sets the HighlightsGain amount
  122349. * @param amount amount of HighlightsGain
  122350. */
  122351. setHighlightsGain(amount: number): void;
  122352. /**
  122353. * Sets the HighlightsThreshold amount
  122354. * @param amount amount of HighlightsThreshold
  122355. */
  122356. setHighlightsThreshold(amount: number): void;
  122357. /**
  122358. * Disables highlights
  122359. */
  122360. disableHighlights(): void;
  122361. /**
  122362. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  122363. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  122364. */
  122365. dispose(disableDepthRender?: boolean): void;
  122366. private _createChromaticAberrationPostProcess;
  122367. private _createHighlightsPostProcess;
  122368. private _createDepthOfFieldPostProcess;
  122369. private _createGrainTexture;
  122370. }
  122371. }
  122372. declare module BABYLON {
  122373. /** @hidden */
  122374. export var ssao2PixelShader: {
  122375. name: string;
  122376. shader: string;
  122377. };
  122378. }
  122379. declare module BABYLON {
  122380. /** @hidden */
  122381. export var ssaoCombinePixelShader: {
  122382. name: string;
  122383. shader: string;
  122384. };
  122385. }
  122386. declare module BABYLON {
  122387. /**
  122388. * Render pipeline to produce ssao effect
  122389. */
  122390. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  122391. /**
  122392. * @ignore
  122393. * The PassPostProcess id in the pipeline that contains the original scene color
  122394. */
  122395. SSAOOriginalSceneColorEffect: string;
  122396. /**
  122397. * @ignore
  122398. * The SSAO PostProcess id in the pipeline
  122399. */
  122400. SSAORenderEffect: string;
  122401. /**
  122402. * @ignore
  122403. * The horizontal blur PostProcess id in the pipeline
  122404. */
  122405. SSAOBlurHRenderEffect: string;
  122406. /**
  122407. * @ignore
  122408. * The vertical blur PostProcess id in the pipeline
  122409. */
  122410. SSAOBlurVRenderEffect: string;
  122411. /**
  122412. * @ignore
  122413. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122414. */
  122415. SSAOCombineRenderEffect: string;
  122416. /**
  122417. * The output strength of the SSAO post-process. Default value is 1.0.
  122418. */
  122419. totalStrength: number;
  122420. /**
  122421. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  122422. */
  122423. maxZ: number;
  122424. /**
  122425. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  122426. */
  122427. minZAspect: number;
  122428. private _samples;
  122429. /**
  122430. * Number of samples used for the SSAO calculations. Default value is 8
  122431. */
  122432. samples: number;
  122433. private _textureSamples;
  122434. /**
  122435. * Number of samples to use for antialiasing
  122436. */
  122437. textureSamples: number;
  122438. /**
  122439. * Ratio object used for SSAO ratio and blur ratio
  122440. */
  122441. private _ratio;
  122442. /**
  122443. * Dynamically generated sphere sampler.
  122444. */
  122445. private _sampleSphere;
  122446. /**
  122447. * Blur filter offsets
  122448. */
  122449. private _samplerOffsets;
  122450. private _expensiveBlur;
  122451. /**
  122452. * If bilateral blur should be used
  122453. */
  122454. expensiveBlur: boolean;
  122455. /**
  122456. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  122457. */
  122458. radius: number;
  122459. /**
  122460. * The base color of the SSAO post-process
  122461. * The final result is "base + ssao" between [0, 1]
  122462. */
  122463. base: number;
  122464. /**
  122465. * Support test.
  122466. */
  122467. static readonly IsSupported: boolean;
  122468. private _scene;
  122469. private _depthTexture;
  122470. private _normalTexture;
  122471. private _randomTexture;
  122472. private _originalColorPostProcess;
  122473. private _ssaoPostProcess;
  122474. private _blurHPostProcess;
  122475. private _blurVPostProcess;
  122476. private _ssaoCombinePostProcess;
  122477. private _firstUpdate;
  122478. /**
  122479. * Gets active scene
  122480. */
  122481. readonly scene: Scene;
  122482. /**
  122483. * @constructor
  122484. * @param name The rendering pipeline name
  122485. * @param scene The scene linked to this pipeline
  122486. * @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 }
  122487. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122488. */
  122489. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122490. /**
  122491. * Get the class name
  122492. * @returns "SSAO2RenderingPipeline"
  122493. */
  122494. getClassName(): string;
  122495. /**
  122496. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122497. */
  122498. dispose(disableGeometryBufferRenderer?: boolean): void;
  122499. private _createBlurPostProcess;
  122500. /** @hidden */
  122501. _rebuild(): void;
  122502. private _bits;
  122503. private _radicalInverse_VdC;
  122504. private _hammersley;
  122505. private _hemisphereSample_uniform;
  122506. private _generateHemisphere;
  122507. private _createSSAOPostProcess;
  122508. private _createSSAOCombinePostProcess;
  122509. private _createRandomTexture;
  122510. /**
  122511. * Serialize the rendering pipeline (Used when exporting)
  122512. * @returns the serialized object
  122513. */
  122514. serialize(): any;
  122515. /**
  122516. * Parse the serialized pipeline
  122517. * @param source Source pipeline.
  122518. * @param scene The scene to load the pipeline to.
  122519. * @param rootUrl The URL of the serialized pipeline.
  122520. * @returns An instantiated pipeline from the serialized object.
  122521. */
  122522. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  122523. }
  122524. }
  122525. declare module BABYLON {
  122526. /** @hidden */
  122527. export var ssaoPixelShader: {
  122528. name: string;
  122529. shader: string;
  122530. };
  122531. }
  122532. declare module BABYLON {
  122533. /**
  122534. * Render pipeline to produce ssao effect
  122535. */
  122536. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  122537. /**
  122538. * @ignore
  122539. * The PassPostProcess id in the pipeline that contains the original scene color
  122540. */
  122541. SSAOOriginalSceneColorEffect: string;
  122542. /**
  122543. * @ignore
  122544. * The SSAO PostProcess id in the pipeline
  122545. */
  122546. SSAORenderEffect: string;
  122547. /**
  122548. * @ignore
  122549. * The horizontal blur PostProcess id in the pipeline
  122550. */
  122551. SSAOBlurHRenderEffect: string;
  122552. /**
  122553. * @ignore
  122554. * The vertical blur PostProcess id in the pipeline
  122555. */
  122556. SSAOBlurVRenderEffect: string;
  122557. /**
  122558. * @ignore
  122559. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  122560. */
  122561. SSAOCombineRenderEffect: string;
  122562. /**
  122563. * The output strength of the SSAO post-process. Default value is 1.0.
  122564. */
  122565. totalStrength: number;
  122566. /**
  122567. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  122568. */
  122569. radius: number;
  122570. /**
  122571. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  122572. * Must not be equal to fallOff and superior to fallOff.
  122573. * Default value is 0.0075
  122574. */
  122575. area: number;
  122576. /**
  122577. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  122578. * Must not be equal to area and inferior to area.
  122579. * Default value is 0.000001
  122580. */
  122581. fallOff: number;
  122582. /**
  122583. * The base color of the SSAO post-process
  122584. * The final result is "base + ssao" between [0, 1]
  122585. */
  122586. base: number;
  122587. private _scene;
  122588. private _depthTexture;
  122589. private _randomTexture;
  122590. private _originalColorPostProcess;
  122591. private _ssaoPostProcess;
  122592. private _blurHPostProcess;
  122593. private _blurVPostProcess;
  122594. private _ssaoCombinePostProcess;
  122595. private _firstUpdate;
  122596. /**
  122597. * Gets active scene
  122598. */
  122599. readonly scene: Scene;
  122600. /**
  122601. * @constructor
  122602. * @param name - The rendering pipeline name
  122603. * @param scene - The scene linked to this pipeline
  122604. * @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 }
  122605. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122606. */
  122607. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122608. /**
  122609. * Get the class name
  122610. * @returns "SSAORenderingPipeline"
  122611. */
  122612. getClassName(): string;
  122613. /**
  122614. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122615. */
  122616. dispose(disableDepthRender?: boolean): void;
  122617. private _createBlurPostProcess;
  122618. /** @hidden */
  122619. _rebuild(): void;
  122620. private _createSSAOPostProcess;
  122621. private _createSSAOCombinePostProcess;
  122622. private _createRandomTexture;
  122623. }
  122624. }
  122625. declare module BABYLON {
  122626. /** @hidden */
  122627. export var standardPixelShader: {
  122628. name: string;
  122629. shader: string;
  122630. };
  122631. }
  122632. declare module BABYLON {
  122633. /**
  122634. * Standard rendering pipeline
  122635. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122636. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122637. */
  122638. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122639. /**
  122640. * Public members
  122641. */
  122642. /**
  122643. * Post-process which contains the original scene color before the pipeline applies all the effects
  122644. */
  122645. originalPostProcess: Nullable<PostProcess>;
  122646. /**
  122647. * Post-process used to down scale an image x4
  122648. */
  122649. downSampleX4PostProcess: Nullable<PostProcess>;
  122650. /**
  122651. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122652. */
  122653. brightPassPostProcess: Nullable<PostProcess>;
  122654. /**
  122655. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122656. */
  122657. blurHPostProcesses: PostProcess[];
  122658. /**
  122659. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122660. */
  122661. blurVPostProcesses: PostProcess[];
  122662. /**
  122663. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122664. */
  122665. textureAdderPostProcess: Nullable<PostProcess>;
  122666. /**
  122667. * Post-process used to create volumetric lighting effect
  122668. */
  122669. volumetricLightPostProcess: Nullable<PostProcess>;
  122670. /**
  122671. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122672. */
  122673. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  122674. /**
  122675. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122676. */
  122677. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  122678. /**
  122679. * Post-process used to merge the volumetric light effect and the real scene color
  122680. */
  122681. volumetricLightMergePostProces: Nullable<PostProcess>;
  122682. /**
  122683. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  122684. */
  122685. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  122686. /**
  122687. * Base post-process used to calculate the average luminance of the final image for HDR
  122688. */
  122689. luminancePostProcess: Nullable<PostProcess>;
  122690. /**
  122691. * Post-processes used to create down sample post-processes in order to get
  122692. * the average luminance of the final image for HDR
  122693. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  122694. */
  122695. luminanceDownSamplePostProcesses: PostProcess[];
  122696. /**
  122697. * Post-process used to create a HDR effect (light adaptation)
  122698. */
  122699. hdrPostProcess: Nullable<PostProcess>;
  122700. /**
  122701. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  122702. */
  122703. textureAdderFinalPostProcess: Nullable<PostProcess>;
  122704. /**
  122705. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  122706. */
  122707. lensFlareFinalPostProcess: Nullable<PostProcess>;
  122708. /**
  122709. * Post-process used to merge the final HDR post-process and the real scene color
  122710. */
  122711. hdrFinalPostProcess: Nullable<PostProcess>;
  122712. /**
  122713. * Post-process used to create a lens flare effect
  122714. */
  122715. lensFlarePostProcess: Nullable<PostProcess>;
  122716. /**
  122717. * Post-process that merges the result of the lens flare post-process and the real scene color
  122718. */
  122719. lensFlareComposePostProcess: Nullable<PostProcess>;
  122720. /**
  122721. * Post-process used to create a motion blur effect
  122722. */
  122723. motionBlurPostProcess: Nullable<PostProcess>;
  122724. /**
  122725. * Post-process used to create a depth of field effect
  122726. */
  122727. depthOfFieldPostProcess: Nullable<PostProcess>;
  122728. /**
  122729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122730. */
  122731. fxaaPostProcess: Nullable<FxaaPostProcess>;
  122732. /**
  122733. * Represents the brightness threshold in order to configure the illuminated surfaces
  122734. */
  122735. brightThreshold: number;
  122736. /**
  122737. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  122738. */
  122739. blurWidth: number;
  122740. /**
  122741. * Sets if the blur for highlighted surfaces must be only horizontal
  122742. */
  122743. horizontalBlur: boolean;
  122744. /**
  122745. * Gets the overall exposure used by the pipeline
  122746. */
  122747. /**
  122748. * Sets the overall exposure used by the pipeline
  122749. */
  122750. exposure: number;
  122751. /**
  122752. * Texture used typically to simulate "dirty" on camera lens
  122753. */
  122754. lensTexture: Nullable<Texture>;
  122755. /**
  122756. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  122757. */
  122758. volumetricLightCoefficient: number;
  122759. /**
  122760. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  122761. */
  122762. volumetricLightPower: number;
  122763. /**
  122764. * Used the set the blur intensity to smooth the volumetric lights
  122765. */
  122766. volumetricLightBlurScale: number;
  122767. /**
  122768. * Light (spot or directional) used to generate the volumetric lights rays
  122769. * The source light must have a shadow generate so the pipeline can get its
  122770. * depth map
  122771. */
  122772. sourceLight: Nullable<SpotLight | DirectionalLight>;
  122773. /**
  122774. * For eye adaptation, represents the minimum luminance the eye can see
  122775. */
  122776. hdrMinimumLuminance: number;
  122777. /**
  122778. * For eye adaptation, represents the decrease luminance speed
  122779. */
  122780. hdrDecreaseRate: number;
  122781. /**
  122782. * For eye adaptation, represents the increase luminance speed
  122783. */
  122784. hdrIncreaseRate: number;
  122785. /**
  122786. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122787. */
  122788. /**
  122789. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122790. */
  122791. hdrAutoExposure: boolean;
  122792. /**
  122793. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  122794. */
  122795. lensColorTexture: Nullable<Texture>;
  122796. /**
  122797. * The overall strengh for the lens flare effect
  122798. */
  122799. lensFlareStrength: number;
  122800. /**
  122801. * Dispersion coefficient for lens flare ghosts
  122802. */
  122803. lensFlareGhostDispersal: number;
  122804. /**
  122805. * Main lens flare halo width
  122806. */
  122807. lensFlareHaloWidth: number;
  122808. /**
  122809. * Based on the lens distortion effect, defines how much the lens flare result
  122810. * is distorted
  122811. */
  122812. lensFlareDistortionStrength: number;
  122813. /**
  122814. * Lens star texture must be used to simulate rays on the flares and is available
  122815. * in the documentation
  122816. */
  122817. lensStarTexture: Nullable<Texture>;
  122818. /**
  122819. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  122820. * flare effect by taking account of the dirt texture
  122821. */
  122822. lensFlareDirtTexture: Nullable<Texture>;
  122823. /**
  122824. * Represents the focal length for the depth of field effect
  122825. */
  122826. depthOfFieldDistance: number;
  122827. /**
  122828. * Represents the blur intensity for the blurred part of the depth of field effect
  122829. */
  122830. depthOfFieldBlurWidth: number;
  122831. /**
  122832. * Gets how much the image is blurred by the movement while using the motion blur post-process
  122833. */
  122834. /**
  122835. * Sets how much the image is blurred by the movement while using the motion blur post-process
  122836. */
  122837. motionStrength: number;
  122838. /**
  122839. * Gets wether or not the motion blur post-process is object based or screen based.
  122840. */
  122841. /**
  122842. * Sets wether or not the motion blur post-process should be object based or screen based
  122843. */
  122844. objectBasedMotionBlur: boolean;
  122845. /**
  122846. * List of animations for the pipeline (IAnimatable implementation)
  122847. */
  122848. animations: Animation[];
  122849. /**
  122850. * Private members
  122851. */
  122852. private _scene;
  122853. private _currentDepthOfFieldSource;
  122854. private _basePostProcess;
  122855. private _fixedExposure;
  122856. private _currentExposure;
  122857. private _hdrAutoExposure;
  122858. private _hdrCurrentLuminance;
  122859. private _motionStrength;
  122860. private _isObjectBasedMotionBlur;
  122861. private _floatTextureType;
  122862. private _ratio;
  122863. private _bloomEnabled;
  122864. private _depthOfFieldEnabled;
  122865. private _vlsEnabled;
  122866. private _lensFlareEnabled;
  122867. private _hdrEnabled;
  122868. private _motionBlurEnabled;
  122869. private _fxaaEnabled;
  122870. private _motionBlurSamples;
  122871. private _volumetricLightStepsCount;
  122872. private _samples;
  122873. /**
  122874. * @ignore
  122875. * Specifies if the bloom pipeline is enabled
  122876. */
  122877. BloomEnabled: boolean;
  122878. /**
  122879. * @ignore
  122880. * Specifies if the depth of field pipeline is enabed
  122881. */
  122882. DepthOfFieldEnabled: boolean;
  122883. /**
  122884. * @ignore
  122885. * Specifies if the lens flare pipeline is enabed
  122886. */
  122887. LensFlareEnabled: boolean;
  122888. /**
  122889. * @ignore
  122890. * Specifies if the HDR pipeline is enabled
  122891. */
  122892. HDREnabled: boolean;
  122893. /**
  122894. * @ignore
  122895. * Specifies if the volumetric lights scattering effect is enabled
  122896. */
  122897. VLSEnabled: boolean;
  122898. /**
  122899. * @ignore
  122900. * Specifies if the motion blur effect is enabled
  122901. */
  122902. MotionBlurEnabled: boolean;
  122903. /**
  122904. * Specifies if anti-aliasing is enabled
  122905. */
  122906. fxaaEnabled: boolean;
  122907. /**
  122908. * Specifies the number of steps used to calculate the volumetric lights
  122909. * Typically in interval [50, 200]
  122910. */
  122911. volumetricLightStepsCount: number;
  122912. /**
  122913. * Specifies the number of samples used for the motion blur effect
  122914. * Typically in interval [16, 64]
  122915. */
  122916. motionBlurSamples: number;
  122917. /**
  122918. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122919. */
  122920. samples: number;
  122921. /**
  122922. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122923. * @constructor
  122924. * @param name The rendering pipeline name
  122925. * @param scene The scene linked to this pipeline
  122926. * @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)
  122927. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122928. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122929. */
  122930. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122931. private _buildPipeline;
  122932. private _createDownSampleX4PostProcess;
  122933. private _createBrightPassPostProcess;
  122934. private _createBlurPostProcesses;
  122935. private _createTextureAdderPostProcess;
  122936. private _createVolumetricLightPostProcess;
  122937. private _createLuminancePostProcesses;
  122938. private _createHdrPostProcess;
  122939. private _createLensFlarePostProcess;
  122940. private _createDepthOfFieldPostProcess;
  122941. private _createMotionBlurPostProcess;
  122942. private _getDepthTexture;
  122943. private _disposePostProcesses;
  122944. /**
  122945. * Dispose of the pipeline and stop all post processes
  122946. */
  122947. dispose(): void;
  122948. /**
  122949. * Serialize the rendering pipeline (Used when exporting)
  122950. * @returns the serialized object
  122951. */
  122952. serialize(): any;
  122953. /**
  122954. * Parse the serialized pipeline
  122955. * @param source Source pipeline.
  122956. * @param scene The scene to load the pipeline to.
  122957. * @param rootUrl The URL of the serialized pipeline.
  122958. * @returns An instantiated pipeline from the serialized object.
  122959. */
  122960. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122961. /**
  122962. * Luminance steps
  122963. */
  122964. static LuminanceSteps: number;
  122965. }
  122966. }
  122967. declare module BABYLON {
  122968. /** @hidden */
  122969. export var tonemapPixelShader: {
  122970. name: string;
  122971. shader: string;
  122972. };
  122973. }
  122974. declare module BABYLON {
  122975. /** Defines operator used for tonemapping */
  122976. export enum TonemappingOperator {
  122977. /** Hable */
  122978. Hable = 0,
  122979. /** Reinhard */
  122980. Reinhard = 1,
  122981. /** HejiDawson */
  122982. HejiDawson = 2,
  122983. /** Photographic */
  122984. Photographic = 3
  122985. }
  122986. /**
  122987. * Defines a post process to apply tone mapping
  122988. */
  122989. export class TonemapPostProcess extends PostProcess {
  122990. private _operator;
  122991. /** Defines the required exposure adjustement */
  122992. exposureAdjustment: number;
  122993. /**
  122994. * Creates a new TonemapPostProcess
  122995. * @param name defines the name of the postprocess
  122996. * @param _operator defines the operator to use
  122997. * @param exposureAdjustment defines the required exposure adjustement
  122998. * @param camera defines the camera to use (can be null)
  122999. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  123000. * @param engine defines the hosting engine (can be ignore if camera is set)
  123001. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  123002. */
  123003. constructor(name: string, _operator: TonemappingOperator,
  123004. /** Defines the required exposure adjustement */
  123005. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  123006. }
  123007. }
  123008. declare module BABYLON {
  123009. /** @hidden */
  123010. export var depthVertexShader: {
  123011. name: string;
  123012. shader: string;
  123013. };
  123014. }
  123015. declare module BABYLON {
  123016. /** @hidden */
  123017. export var volumetricLightScatteringPixelShader: {
  123018. name: string;
  123019. shader: string;
  123020. };
  123021. }
  123022. declare module BABYLON {
  123023. /** @hidden */
  123024. export var volumetricLightScatteringPassVertexShader: {
  123025. name: string;
  123026. shader: string;
  123027. };
  123028. }
  123029. declare module BABYLON {
  123030. /** @hidden */
  123031. export var volumetricLightScatteringPassPixelShader: {
  123032. name: string;
  123033. shader: string;
  123034. };
  123035. }
  123036. declare module BABYLON {
  123037. /**
  123038. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  123039. */
  123040. export class VolumetricLightScatteringPostProcess extends PostProcess {
  123041. private _volumetricLightScatteringPass;
  123042. private _volumetricLightScatteringRTT;
  123043. private _viewPort;
  123044. private _screenCoordinates;
  123045. private _cachedDefines;
  123046. /**
  123047. * If not undefined, the mesh position is computed from the attached node position
  123048. */
  123049. attachedNode: {
  123050. position: Vector3;
  123051. };
  123052. /**
  123053. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  123054. */
  123055. customMeshPosition: Vector3;
  123056. /**
  123057. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  123058. */
  123059. useCustomMeshPosition: boolean;
  123060. /**
  123061. * If the post-process should inverse the light scattering direction
  123062. */
  123063. invert: boolean;
  123064. /**
  123065. * The internal mesh used by the post-process
  123066. */
  123067. mesh: Mesh;
  123068. /**
  123069. * @hidden
  123070. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  123071. */
  123072. useDiffuseColor: boolean;
  123073. /**
  123074. * Array containing the excluded meshes not rendered in the internal pass
  123075. */
  123076. excludedMeshes: AbstractMesh[];
  123077. /**
  123078. * Controls the overall intensity of the post-process
  123079. */
  123080. exposure: number;
  123081. /**
  123082. * Dissipates each sample's contribution in range [0, 1]
  123083. */
  123084. decay: number;
  123085. /**
  123086. * Controls the overall intensity of each sample
  123087. */
  123088. weight: number;
  123089. /**
  123090. * Controls the density of each sample
  123091. */
  123092. density: number;
  123093. /**
  123094. * @constructor
  123095. * @param name The post-process name
  123096. * @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)
  123097. * @param camera The camera that the post-process will be attached to
  123098. * @param mesh The mesh used to create the light scattering
  123099. * @param samples The post-process quality, default 100
  123100. * @param samplingModeThe post-process filtering mode
  123101. * @param engine The babylon engine
  123102. * @param reusable If the post-process is reusable
  123103. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  123104. */
  123105. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  123106. /**
  123107. * Returns the string "VolumetricLightScatteringPostProcess"
  123108. * @returns "VolumetricLightScatteringPostProcess"
  123109. */
  123110. getClassName(): string;
  123111. private _isReady;
  123112. /**
  123113. * Sets the new light position for light scattering effect
  123114. * @param position The new custom light position
  123115. */
  123116. setCustomMeshPosition(position: Vector3): void;
  123117. /**
  123118. * Returns the light position for light scattering effect
  123119. * @return Vector3 The custom light position
  123120. */
  123121. getCustomMeshPosition(): Vector3;
  123122. /**
  123123. * Disposes the internal assets and detaches the post-process from the camera
  123124. */
  123125. dispose(camera: Camera): void;
  123126. /**
  123127. * Returns the render target texture used by the post-process
  123128. * @return the render target texture used by the post-process
  123129. */
  123130. getPass(): RenderTargetTexture;
  123131. private _meshExcluded;
  123132. private _createPass;
  123133. private _updateMeshScreenCoordinates;
  123134. /**
  123135. * Creates a default mesh for the Volumeric Light Scattering post-process
  123136. * @param name The mesh name
  123137. * @param scene The scene where to create the mesh
  123138. * @return the default mesh
  123139. */
  123140. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  123141. }
  123142. }
  123143. declare module BABYLON {
  123144. interface Scene {
  123145. /** @hidden (Backing field) */
  123146. _boundingBoxRenderer: BoundingBoxRenderer;
  123147. /** @hidden (Backing field) */
  123148. _forceShowBoundingBoxes: boolean;
  123149. /**
  123150. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  123151. */
  123152. forceShowBoundingBoxes: boolean;
  123153. /**
  123154. * Gets the bounding box renderer associated with the scene
  123155. * @returns a BoundingBoxRenderer
  123156. */
  123157. getBoundingBoxRenderer(): BoundingBoxRenderer;
  123158. }
  123159. interface AbstractMesh {
  123160. /** @hidden (Backing field) */
  123161. _showBoundingBox: boolean;
  123162. /**
  123163. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  123164. */
  123165. showBoundingBox: boolean;
  123166. }
  123167. /**
  123168. * Component responsible of rendering the bounding box of the meshes in a scene.
  123169. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  123170. */
  123171. export class BoundingBoxRenderer implements ISceneComponent {
  123172. /**
  123173. * The component name helpfull to identify the component in the list of scene components.
  123174. */
  123175. readonly name: string;
  123176. /**
  123177. * The scene the component belongs to.
  123178. */
  123179. scene: Scene;
  123180. /**
  123181. * Color of the bounding box lines placed in front of an object
  123182. */
  123183. frontColor: Color3;
  123184. /**
  123185. * Color of the bounding box lines placed behind an object
  123186. */
  123187. backColor: Color3;
  123188. /**
  123189. * Defines if the renderer should show the back lines or not
  123190. */
  123191. showBackLines: boolean;
  123192. /**
  123193. * @hidden
  123194. */
  123195. renderList: SmartArray<BoundingBox>;
  123196. private _colorShader;
  123197. private _vertexBuffers;
  123198. private _indexBuffer;
  123199. private _fillIndexBuffer;
  123200. private _fillIndexData;
  123201. /**
  123202. * Instantiates a new bounding box renderer in a scene.
  123203. * @param scene the scene the renderer renders in
  123204. */
  123205. constructor(scene: Scene);
  123206. /**
  123207. * Registers the component in a given scene
  123208. */
  123209. register(): void;
  123210. private _evaluateSubMesh;
  123211. private _activeMesh;
  123212. private _prepareRessources;
  123213. private _createIndexBuffer;
  123214. /**
  123215. * Rebuilds the elements related to this component in case of
  123216. * context lost for instance.
  123217. */
  123218. rebuild(): void;
  123219. /**
  123220. * @hidden
  123221. */
  123222. reset(): void;
  123223. /**
  123224. * Render the bounding boxes of a specific rendering group
  123225. * @param renderingGroupId defines the rendering group to render
  123226. */
  123227. render(renderingGroupId: number): void;
  123228. /**
  123229. * In case of occlusion queries, we can render the occlusion bounding box through this method
  123230. * @param mesh Define the mesh to render the occlusion bounding box for
  123231. */
  123232. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  123233. /**
  123234. * Dispose and release the resources attached to this renderer.
  123235. */
  123236. dispose(): void;
  123237. }
  123238. }
  123239. declare module BABYLON {
  123240. /** @hidden */
  123241. export var depthPixelShader: {
  123242. name: string;
  123243. shader: string;
  123244. };
  123245. }
  123246. declare module BABYLON {
  123247. /**
  123248. * This represents a depth renderer in Babylon.
  123249. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  123250. */
  123251. export class DepthRenderer {
  123252. private _scene;
  123253. private _depthMap;
  123254. private _effect;
  123255. private readonly _storeNonLinearDepth;
  123256. private readonly _clearColor;
  123257. /** Get if the depth renderer is using packed depth or not */
  123258. readonly isPacked: boolean;
  123259. private _cachedDefines;
  123260. private _camera;
  123261. /**
  123262. * Specifiess that the depth renderer will only be used within
  123263. * the camera it is created for.
  123264. * This can help forcing its rendering during the camera processing.
  123265. */
  123266. useOnlyInActiveCamera: boolean;
  123267. /** @hidden */
  123268. static _SceneComponentInitialization: (scene: Scene) => void;
  123269. /**
  123270. * Instantiates a depth renderer
  123271. * @param scene The scene the renderer belongs to
  123272. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  123273. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  123274. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123275. */
  123276. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  123277. /**
  123278. * Creates the depth rendering effect and checks if the effect is ready.
  123279. * @param subMesh The submesh to be used to render the depth map of
  123280. * @param useInstances If multiple world instances should be used
  123281. * @returns if the depth renderer is ready to render the depth map
  123282. */
  123283. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123284. /**
  123285. * Gets the texture which the depth map will be written to.
  123286. * @returns The depth map texture
  123287. */
  123288. getDepthMap(): RenderTargetTexture;
  123289. /**
  123290. * Disposes of the depth renderer.
  123291. */
  123292. dispose(): void;
  123293. }
  123294. }
  123295. declare module BABYLON {
  123296. interface Scene {
  123297. /** @hidden (Backing field) */
  123298. _depthRenderer: {
  123299. [id: string]: DepthRenderer;
  123300. };
  123301. /**
  123302. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  123303. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  123304. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  123305. * @returns the created depth renderer
  123306. */
  123307. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  123308. /**
  123309. * Disables a depth renderer for a given camera
  123310. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  123311. */
  123312. disableDepthRenderer(camera?: Nullable<Camera>): void;
  123313. }
  123314. /**
  123315. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  123316. * in several rendering techniques.
  123317. */
  123318. export class DepthRendererSceneComponent implements ISceneComponent {
  123319. /**
  123320. * The component name helpfull to identify the component in the list of scene components.
  123321. */
  123322. readonly name: string;
  123323. /**
  123324. * The scene the component belongs to.
  123325. */
  123326. scene: Scene;
  123327. /**
  123328. * Creates a new instance of the component for the given scene
  123329. * @param scene Defines the scene to register the component in
  123330. */
  123331. constructor(scene: Scene);
  123332. /**
  123333. * Registers the component in a given scene
  123334. */
  123335. register(): void;
  123336. /**
  123337. * Rebuilds the elements related to this component in case of
  123338. * context lost for instance.
  123339. */
  123340. rebuild(): void;
  123341. /**
  123342. * Disposes the component and the associated ressources
  123343. */
  123344. dispose(): void;
  123345. private _gatherRenderTargets;
  123346. private _gatherActiveCameraRenderTargets;
  123347. }
  123348. }
  123349. declare module BABYLON {
  123350. /** @hidden */
  123351. export var outlinePixelShader: {
  123352. name: string;
  123353. shader: string;
  123354. };
  123355. }
  123356. declare module BABYLON {
  123357. /** @hidden */
  123358. export var outlineVertexShader: {
  123359. name: string;
  123360. shader: string;
  123361. };
  123362. }
  123363. declare module BABYLON {
  123364. interface Scene {
  123365. /** @hidden */
  123366. _outlineRenderer: OutlineRenderer;
  123367. /**
  123368. * Gets the outline renderer associated with the scene
  123369. * @returns a OutlineRenderer
  123370. */
  123371. getOutlineRenderer(): OutlineRenderer;
  123372. }
  123373. interface AbstractMesh {
  123374. /** @hidden (Backing field) */
  123375. _renderOutline: boolean;
  123376. /**
  123377. * Gets or sets a boolean indicating if the outline must be rendered as well
  123378. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  123379. */
  123380. renderOutline: boolean;
  123381. /** @hidden (Backing field) */
  123382. _renderOverlay: boolean;
  123383. /**
  123384. * Gets or sets a boolean indicating if the overlay must be rendered as well
  123385. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  123386. */
  123387. renderOverlay: boolean;
  123388. }
  123389. /**
  123390. * This class is responsible to draw bothe outline/overlay of meshes.
  123391. * It should not be used directly but through the available method on mesh.
  123392. */
  123393. export class OutlineRenderer implements ISceneComponent {
  123394. /**
  123395. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  123396. */
  123397. private static _StencilReference;
  123398. /**
  123399. * The name of the component. Each component must have a unique name.
  123400. */
  123401. name: string;
  123402. /**
  123403. * The scene the component belongs to.
  123404. */
  123405. scene: Scene;
  123406. /**
  123407. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  123408. */
  123409. zOffset: number;
  123410. private _engine;
  123411. private _effect;
  123412. private _cachedDefines;
  123413. private _savedDepthWrite;
  123414. /**
  123415. * Instantiates a new outline renderer. (There could be only one per scene).
  123416. * @param scene Defines the scene it belongs to
  123417. */
  123418. constructor(scene: Scene);
  123419. /**
  123420. * Register the component to one instance of a scene.
  123421. */
  123422. register(): void;
  123423. /**
  123424. * Rebuilds the elements related to this component in case of
  123425. * context lost for instance.
  123426. */
  123427. rebuild(): void;
  123428. /**
  123429. * Disposes the component and the associated ressources.
  123430. */
  123431. dispose(): void;
  123432. /**
  123433. * Renders the outline in the canvas.
  123434. * @param subMesh Defines the sumesh to render
  123435. * @param batch Defines the batch of meshes in case of instances
  123436. * @param useOverlay Defines if the rendering is for the overlay or the outline
  123437. */
  123438. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  123439. /**
  123440. * Returns whether or not the outline renderer is ready for a given submesh.
  123441. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  123442. * @param subMesh Defines the submesh to check readyness for
  123443. * @param useInstances Defines wheter wee are trying to render instances or not
  123444. * @returns true if ready otherwise false
  123445. */
  123446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123447. private _beforeRenderingMesh;
  123448. private _afterRenderingMesh;
  123449. }
  123450. }
  123451. declare module BABYLON {
  123452. /**
  123453. * Defines the list of states available for a task inside a AssetsManager
  123454. */
  123455. export enum AssetTaskState {
  123456. /**
  123457. * Initialization
  123458. */
  123459. INIT = 0,
  123460. /**
  123461. * Running
  123462. */
  123463. RUNNING = 1,
  123464. /**
  123465. * Done
  123466. */
  123467. DONE = 2,
  123468. /**
  123469. * Error
  123470. */
  123471. ERROR = 3
  123472. }
  123473. /**
  123474. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  123475. */
  123476. export abstract class AbstractAssetTask {
  123477. /**
  123478. * Task name
  123479. */ name: string;
  123480. /**
  123481. * Callback called when the task is successful
  123482. */
  123483. onSuccess: (task: any) => void;
  123484. /**
  123485. * Callback called when the task is not successful
  123486. */
  123487. onError: (task: any, message?: string, exception?: any) => void;
  123488. /**
  123489. * Creates a new AssetsManager
  123490. * @param name defines the name of the task
  123491. */
  123492. constructor(
  123493. /**
  123494. * Task name
  123495. */ name: string);
  123496. private _isCompleted;
  123497. private _taskState;
  123498. private _errorObject;
  123499. /**
  123500. * Get if the task is completed
  123501. */
  123502. readonly isCompleted: boolean;
  123503. /**
  123504. * Gets the current state of the task
  123505. */
  123506. readonly taskState: AssetTaskState;
  123507. /**
  123508. * Gets the current error object (if task is in error)
  123509. */
  123510. readonly errorObject: {
  123511. message?: string;
  123512. exception?: any;
  123513. };
  123514. /**
  123515. * Internal only
  123516. * @hidden
  123517. */
  123518. _setErrorObject(message?: string, exception?: any): void;
  123519. /**
  123520. * Execute the current task
  123521. * @param scene defines the scene where you want your assets to be loaded
  123522. * @param onSuccess is a callback called when the task is successfully executed
  123523. * @param onError is a callback called if an error occurs
  123524. */
  123525. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123526. /**
  123527. * Execute the current task
  123528. * @param scene defines the scene where you want your assets to be loaded
  123529. * @param onSuccess is a callback called when the task is successfully executed
  123530. * @param onError is a callback called if an error occurs
  123531. */
  123532. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123533. /**
  123534. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  123535. * This can be used with failed tasks that have the reason for failure fixed.
  123536. */
  123537. reset(): void;
  123538. private onErrorCallback;
  123539. private onDoneCallback;
  123540. }
  123541. /**
  123542. * Define the interface used by progress events raised during assets loading
  123543. */
  123544. export interface IAssetsProgressEvent {
  123545. /**
  123546. * Defines the number of remaining tasks to process
  123547. */
  123548. remainingCount: number;
  123549. /**
  123550. * Defines the total number of tasks
  123551. */
  123552. totalCount: number;
  123553. /**
  123554. * Defines the task that was just processed
  123555. */
  123556. task: AbstractAssetTask;
  123557. }
  123558. /**
  123559. * Class used to share progress information about assets loading
  123560. */
  123561. export class AssetsProgressEvent implements IAssetsProgressEvent {
  123562. /**
  123563. * Defines the number of remaining tasks to process
  123564. */
  123565. remainingCount: number;
  123566. /**
  123567. * Defines the total number of tasks
  123568. */
  123569. totalCount: number;
  123570. /**
  123571. * Defines the task that was just processed
  123572. */
  123573. task: AbstractAssetTask;
  123574. /**
  123575. * Creates a AssetsProgressEvent
  123576. * @param remainingCount defines the number of remaining tasks to process
  123577. * @param totalCount defines the total number of tasks
  123578. * @param task defines the task that was just processed
  123579. */
  123580. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  123581. }
  123582. /**
  123583. * Define a task used by AssetsManager to load meshes
  123584. */
  123585. export class MeshAssetTask extends AbstractAssetTask {
  123586. /**
  123587. * Defines the name of the task
  123588. */
  123589. name: string;
  123590. /**
  123591. * Defines the list of mesh's names you want to load
  123592. */
  123593. meshesNames: any;
  123594. /**
  123595. * Defines the root url to use as a base to load your meshes and associated resources
  123596. */
  123597. rootUrl: string;
  123598. /**
  123599. * Defines the filename of the scene to load from
  123600. */
  123601. sceneFilename: string;
  123602. /**
  123603. * Gets the list of loaded meshes
  123604. */
  123605. loadedMeshes: Array<AbstractMesh>;
  123606. /**
  123607. * Gets the list of loaded particle systems
  123608. */
  123609. loadedParticleSystems: Array<IParticleSystem>;
  123610. /**
  123611. * Gets the list of loaded skeletons
  123612. */
  123613. loadedSkeletons: Array<Skeleton>;
  123614. /**
  123615. * Gets the list of loaded animation groups
  123616. */
  123617. loadedAnimationGroups: Array<AnimationGroup>;
  123618. /**
  123619. * Callback called when the task is successful
  123620. */
  123621. onSuccess: (task: MeshAssetTask) => void;
  123622. /**
  123623. * Callback called when the task is successful
  123624. */
  123625. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  123626. /**
  123627. * Creates a new MeshAssetTask
  123628. * @param name defines the name of the task
  123629. * @param meshesNames defines the list of mesh's names you want to load
  123630. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  123631. * @param sceneFilename defines the filename of the scene to load from
  123632. */
  123633. constructor(
  123634. /**
  123635. * Defines the name of the task
  123636. */
  123637. name: string,
  123638. /**
  123639. * Defines the list of mesh's names you want to load
  123640. */
  123641. meshesNames: any,
  123642. /**
  123643. * Defines the root url to use as a base to load your meshes and associated resources
  123644. */
  123645. rootUrl: string,
  123646. /**
  123647. * Defines the filename of the scene to load from
  123648. */
  123649. sceneFilename: string);
  123650. /**
  123651. * Execute the current task
  123652. * @param scene defines the scene where you want your assets to be loaded
  123653. * @param onSuccess is a callback called when the task is successfully executed
  123654. * @param onError is a callback called if an error occurs
  123655. */
  123656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123657. }
  123658. /**
  123659. * Define a task used by AssetsManager to load text content
  123660. */
  123661. export class TextFileAssetTask extends AbstractAssetTask {
  123662. /**
  123663. * Defines the name of the task
  123664. */
  123665. name: string;
  123666. /**
  123667. * Defines the location of the file to load
  123668. */
  123669. url: string;
  123670. /**
  123671. * Gets the loaded text string
  123672. */
  123673. text: string;
  123674. /**
  123675. * Callback called when the task is successful
  123676. */
  123677. onSuccess: (task: TextFileAssetTask) => void;
  123678. /**
  123679. * Callback called when the task is successful
  123680. */
  123681. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  123682. /**
  123683. * Creates a new TextFileAssetTask object
  123684. * @param name defines the name of the task
  123685. * @param url defines the location of the file to load
  123686. */
  123687. constructor(
  123688. /**
  123689. * Defines the name of the task
  123690. */
  123691. name: string,
  123692. /**
  123693. * Defines the location of the file to load
  123694. */
  123695. url: string);
  123696. /**
  123697. * Execute the current task
  123698. * @param scene defines the scene where you want your assets to be loaded
  123699. * @param onSuccess is a callback called when the task is successfully executed
  123700. * @param onError is a callback called if an error occurs
  123701. */
  123702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123703. }
  123704. /**
  123705. * Define a task used by AssetsManager to load binary data
  123706. */
  123707. export class BinaryFileAssetTask extends AbstractAssetTask {
  123708. /**
  123709. * Defines the name of the task
  123710. */
  123711. name: string;
  123712. /**
  123713. * Defines the location of the file to load
  123714. */
  123715. url: string;
  123716. /**
  123717. * Gets the lodaded data (as an array buffer)
  123718. */
  123719. data: ArrayBuffer;
  123720. /**
  123721. * Callback called when the task is successful
  123722. */
  123723. onSuccess: (task: BinaryFileAssetTask) => void;
  123724. /**
  123725. * Callback called when the task is successful
  123726. */
  123727. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  123728. /**
  123729. * Creates a new BinaryFileAssetTask object
  123730. * @param name defines the name of the new task
  123731. * @param url defines the location of the file to load
  123732. */
  123733. constructor(
  123734. /**
  123735. * Defines the name of the task
  123736. */
  123737. name: string,
  123738. /**
  123739. * Defines the location of the file to load
  123740. */
  123741. url: string);
  123742. /**
  123743. * Execute the current task
  123744. * @param scene defines the scene where you want your assets to be loaded
  123745. * @param onSuccess is a callback called when the task is successfully executed
  123746. * @param onError is a callback called if an error occurs
  123747. */
  123748. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123749. }
  123750. /**
  123751. * Define a task used by AssetsManager to load images
  123752. */
  123753. export class ImageAssetTask extends AbstractAssetTask {
  123754. /**
  123755. * Defines the name of the task
  123756. */
  123757. name: string;
  123758. /**
  123759. * Defines the location of the image to load
  123760. */
  123761. url: string;
  123762. /**
  123763. * Gets the loaded images
  123764. */
  123765. image: HTMLImageElement;
  123766. /**
  123767. * Callback called when the task is successful
  123768. */
  123769. onSuccess: (task: ImageAssetTask) => void;
  123770. /**
  123771. * Callback called when the task is successful
  123772. */
  123773. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  123774. /**
  123775. * Creates a new ImageAssetTask
  123776. * @param name defines the name of the task
  123777. * @param url defines the location of the image to load
  123778. */
  123779. constructor(
  123780. /**
  123781. * Defines the name of the task
  123782. */
  123783. name: string,
  123784. /**
  123785. * Defines the location of the image to load
  123786. */
  123787. url: string);
  123788. /**
  123789. * Execute the current task
  123790. * @param scene defines the scene where you want your assets to be loaded
  123791. * @param onSuccess is a callback called when the task is successfully executed
  123792. * @param onError is a callback called if an error occurs
  123793. */
  123794. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123795. }
  123796. /**
  123797. * Defines the interface used by texture loading tasks
  123798. */
  123799. export interface ITextureAssetTask<TEX extends BaseTexture> {
  123800. /**
  123801. * Gets the loaded texture
  123802. */
  123803. texture: TEX;
  123804. }
  123805. /**
  123806. * Define a task used by AssetsManager to load 2D textures
  123807. */
  123808. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  123809. /**
  123810. * Defines the name of the task
  123811. */
  123812. name: string;
  123813. /**
  123814. * Defines the location of the file to load
  123815. */
  123816. url: string;
  123817. /**
  123818. * Defines if mipmap should not be generated (default is false)
  123819. */
  123820. noMipmap?: boolean | undefined;
  123821. /**
  123822. * Defines if texture must be inverted on Y axis (default is false)
  123823. */
  123824. invertY?: boolean | undefined;
  123825. /**
  123826. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123827. */
  123828. samplingMode: number;
  123829. /**
  123830. * Gets the loaded texture
  123831. */
  123832. texture: Texture;
  123833. /**
  123834. * Callback called when the task is successful
  123835. */
  123836. onSuccess: (task: TextureAssetTask) => void;
  123837. /**
  123838. * Callback called when the task is successful
  123839. */
  123840. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  123841. /**
  123842. * Creates a new TextureAssetTask object
  123843. * @param name defines the name of the task
  123844. * @param url defines the location of the file to load
  123845. * @param noMipmap defines if mipmap should not be generated (default is false)
  123846. * @param invertY defines if texture must be inverted on Y axis (default is false)
  123847. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123848. */
  123849. constructor(
  123850. /**
  123851. * Defines the name of the task
  123852. */
  123853. name: string,
  123854. /**
  123855. * Defines the location of the file to load
  123856. */
  123857. url: string,
  123858. /**
  123859. * Defines if mipmap should not be generated (default is false)
  123860. */
  123861. noMipmap?: boolean | undefined,
  123862. /**
  123863. * Defines if texture must be inverted on Y axis (default is false)
  123864. */
  123865. invertY?: boolean | undefined,
  123866. /**
  123867. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123868. */
  123869. samplingMode?: number);
  123870. /**
  123871. * Execute the current task
  123872. * @param scene defines the scene where you want your assets to be loaded
  123873. * @param onSuccess is a callback called when the task is successfully executed
  123874. * @param onError is a callback called if an error occurs
  123875. */
  123876. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123877. }
  123878. /**
  123879. * Define a task used by AssetsManager to load cube textures
  123880. */
  123881. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  123882. /**
  123883. * Defines the name of the task
  123884. */
  123885. name: string;
  123886. /**
  123887. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123888. */
  123889. url: string;
  123890. /**
  123891. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123892. */
  123893. extensions?: string[] | undefined;
  123894. /**
  123895. * Defines if mipmaps should not be generated (default is false)
  123896. */
  123897. noMipmap?: boolean | undefined;
  123898. /**
  123899. * Defines the explicit list of files (undefined by default)
  123900. */
  123901. files?: string[] | undefined;
  123902. /**
  123903. * Gets the loaded texture
  123904. */
  123905. texture: CubeTexture;
  123906. /**
  123907. * Callback called when the task is successful
  123908. */
  123909. onSuccess: (task: CubeTextureAssetTask) => void;
  123910. /**
  123911. * Callback called when the task is successful
  123912. */
  123913. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123914. /**
  123915. * Creates a new CubeTextureAssetTask
  123916. * @param name defines the name of the task
  123917. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123918. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123919. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123920. * @param files defines the explicit list of files (undefined by default)
  123921. */
  123922. constructor(
  123923. /**
  123924. * Defines the name of the task
  123925. */
  123926. name: string,
  123927. /**
  123928. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123929. */
  123930. url: string,
  123931. /**
  123932. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123933. */
  123934. extensions?: string[] | undefined,
  123935. /**
  123936. * Defines if mipmaps should not be generated (default is false)
  123937. */
  123938. noMipmap?: boolean | undefined,
  123939. /**
  123940. * Defines the explicit list of files (undefined by default)
  123941. */
  123942. files?: string[] | undefined);
  123943. /**
  123944. * Execute the current task
  123945. * @param scene defines the scene where you want your assets to be loaded
  123946. * @param onSuccess is a callback called when the task is successfully executed
  123947. * @param onError is a callback called if an error occurs
  123948. */
  123949. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123950. }
  123951. /**
  123952. * Define a task used by AssetsManager to load HDR cube textures
  123953. */
  123954. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123955. /**
  123956. * Defines the name of the task
  123957. */
  123958. name: string;
  123959. /**
  123960. * Defines the location of the file to load
  123961. */
  123962. url: string;
  123963. /**
  123964. * Defines the desired size (the more it increases the longer the generation will be)
  123965. */
  123966. size: number;
  123967. /**
  123968. * Defines if mipmaps should not be generated (default is false)
  123969. */
  123970. noMipmap: boolean;
  123971. /**
  123972. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123973. */
  123974. generateHarmonics: boolean;
  123975. /**
  123976. * 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)
  123977. */
  123978. gammaSpace: boolean;
  123979. /**
  123980. * Internal Use Only
  123981. */
  123982. reserved: boolean;
  123983. /**
  123984. * Gets the loaded texture
  123985. */
  123986. texture: HDRCubeTexture;
  123987. /**
  123988. * Callback called when the task is successful
  123989. */
  123990. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123991. /**
  123992. * Callback called when the task is successful
  123993. */
  123994. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123995. /**
  123996. * Creates a new HDRCubeTextureAssetTask object
  123997. * @param name defines the name of the task
  123998. * @param url defines the location of the file to load
  123999. * @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.
  124000. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124001. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124002. * @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)
  124003. * @param reserved Internal use only
  124004. */
  124005. constructor(
  124006. /**
  124007. * Defines the name of the task
  124008. */
  124009. name: string,
  124010. /**
  124011. * Defines the location of the file to load
  124012. */
  124013. url: string,
  124014. /**
  124015. * Defines the desired size (the more it increases the longer the generation will be)
  124016. */
  124017. size: number,
  124018. /**
  124019. * Defines if mipmaps should not be generated (default is false)
  124020. */
  124021. noMipmap?: boolean,
  124022. /**
  124023. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  124024. */
  124025. generateHarmonics?: boolean,
  124026. /**
  124027. * 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)
  124028. */
  124029. gammaSpace?: boolean,
  124030. /**
  124031. * Internal Use Only
  124032. */
  124033. reserved?: boolean);
  124034. /**
  124035. * Execute the current task
  124036. * @param scene defines the scene where you want your assets to be loaded
  124037. * @param onSuccess is a callback called when the task is successfully executed
  124038. * @param onError is a callback called if an error occurs
  124039. */
  124040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124041. }
  124042. /**
  124043. * Define a task used by AssetsManager to load Equirectangular cube textures
  124044. */
  124045. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  124046. /**
  124047. * Defines the name of the task
  124048. */
  124049. name: string;
  124050. /**
  124051. * Defines the location of the file to load
  124052. */
  124053. url: string;
  124054. /**
  124055. * Defines the desired size (the more it increases the longer the generation will be)
  124056. */
  124057. size: number;
  124058. /**
  124059. * Defines if mipmaps should not be generated (default is false)
  124060. */
  124061. noMipmap: boolean;
  124062. /**
  124063. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124064. * but the standard material would require them in Gamma space) (default is true)
  124065. */
  124066. gammaSpace: boolean;
  124067. /**
  124068. * Gets the loaded texture
  124069. */
  124070. texture: EquiRectangularCubeTexture;
  124071. /**
  124072. * Callback called when the task is successful
  124073. */
  124074. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  124075. /**
  124076. * Callback called when the task is successful
  124077. */
  124078. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  124079. /**
  124080. * Creates a new EquiRectangularCubeTextureAssetTask object
  124081. * @param name defines the name of the task
  124082. * @param url defines the location of the file to load
  124083. * @param size defines the desired size (the more it increases the longer the generation will be)
  124084. * If the size is omitted this implies you are using a preprocessed cubemap.
  124085. * @param noMipmap defines if mipmaps should not be generated (default is false)
  124086. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  124087. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  124088. * (default is true)
  124089. */
  124090. constructor(
  124091. /**
  124092. * Defines the name of the task
  124093. */
  124094. name: string,
  124095. /**
  124096. * Defines the location of the file to load
  124097. */
  124098. url: string,
  124099. /**
  124100. * Defines the desired size (the more it increases the longer the generation will be)
  124101. */
  124102. size: number,
  124103. /**
  124104. * Defines if mipmaps should not be generated (default is false)
  124105. */
  124106. noMipmap?: boolean,
  124107. /**
  124108. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  124109. * but the standard material would require them in Gamma space) (default is true)
  124110. */
  124111. gammaSpace?: boolean);
  124112. /**
  124113. * Execute the current task
  124114. * @param scene defines the scene where you want your assets to be loaded
  124115. * @param onSuccess is a callback called when the task is successfully executed
  124116. * @param onError is a callback called if an error occurs
  124117. */
  124118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  124119. }
  124120. /**
  124121. * This class can be used to easily import assets into a scene
  124122. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  124123. */
  124124. export class AssetsManager {
  124125. private _scene;
  124126. private _isLoading;
  124127. protected _tasks: AbstractAssetTask[];
  124128. protected _waitingTasksCount: number;
  124129. protected _totalTasksCount: number;
  124130. /**
  124131. * Callback called when all tasks are processed
  124132. */
  124133. onFinish: (tasks: AbstractAssetTask[]) => void;
  124134. /**
  124135. * Callback called when a task is successful
  124136. */
  124137. onTaskSuccess: (task: AbstractAssetTask) => void;
  124138. /**
  124139. * Callback called when a task had an error
  124140. */
  124141. onTaskError: (task: AbstractAssetTask) => void;
  124142. /**
  124143. * Callback called when a task is done (whatever the result is)
  124144. */
  124145. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  124146. /**
  124147. * Observable called when all tasks are processed
  124148. */
  124149. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  124150. /**
  124151. * Observable called when a task had an error
  124152. */
  124153. onTaskErrorObservable: Observable<AbstractAssetTask>;
  124154. /**
  124155. * Observable called when all tasks were executed
  124156. */
  124157. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  124158. /**
  124159. * Observable called when a task is done (whatever the result is)
  124160. */
  124161. onProgressObservable: Observable<IAssetsProgressEvent>;
  124162. /**
  124163. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  124164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  124165. */
  124166. useDefaultLoadingScreen: boolean;
  124167. /**
  124168. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  124169. * when all assets have been downloaded.
  124170. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  124171. */
  124172. autoHideLoadingUI: boolean;
  124173. /**
  124174. * Creates a new AssetsManager
  124175. * @param scene defines the scene to work on
  124176. */
  124177. constructor(scene: Scene);
  124178. /**
  124179. * Add a MeshAssetTask to the list of active tasks
  124180. * @param taskName defines the name of the new task
  124181. * @param meshesNames defines the name of meshes to load
  124182. * @param rootUrl defines the root url to use to locate files
  124183. * @param sceneFilename defines the filename of the scene file
  124184. * @returns a new MeshAssetTask object
  124185. */
  124186. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  124187. /**
  124188. * Add a TextFileAssetTask to the list of active tasks
  124189. * @param taskName defines the name of the new task
  124190. * @param url defines the url of the file to load
  124191. * @returns a new TextFileAssetTask object
  124192. */
  124193. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  124194. /**
  124195. * Add a BinaryFileAssetTask to the list of active tasks
  124196. * @param taskName defines the name of the new task
  124197. * @param url defines the url of the file to load
  124198. * @returns a new BinaryFileAssetTask object
  124199. */
  124200. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  124201. /**
  124202. * Add a ImageAssetTask to the list of active tasks
  124203. * @param taskName defines the name of the new task
  124204. * @param url defines the url of the file to load
  124205. * @returns a new ImageAssetTask object
  124206. */
  124207. addImageTask(taskName: string, url: string): ImageAssetTask;
  124208. /**
  124209. * Add a TextureAssetTask to the list of active tasks
  124210. * @param taskName defines the name of the new task
  124211. * @param url defines the url of the file to load
  124212. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124213. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  124214. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  124215. * @returns a new TextureAssetTask object
  124216. */
  124217. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  124218. /**
  124219. * Add a CubeTextureAssetTask to the list of active tasks
  124220. * @param taskName defines the name of the new task
  124221. * @param url defines the url of the file to load
  124222. * @param extensions defines the extension to use to load the cube map (can be null)
  124223. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124224. * @param files defines the list of files to load (can be null)
  124225. * @returns a new CubeTextureAssetTask object
  124226. */
  124227. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  124228. /**
  124229. *
  124230. * Add a HDRCubeTextureAssetTask to the list of active tasks
  124231. * @param taskName defines the name of the new task
  124232. * @param url defines the url of the file to load
  124233. * @param size defines the size you want for the cubemap (can be null)
  124234. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124235. * @param generateHarmonics defines if you want to automatically generate (true by default)
  124236. * @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)
  124237. * @param reserved Internal use only
  124238. * @returns a new HDRCubeTextureAssetTask object
  124239. */
  124240. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  124241. /**
  124242. *
  124243. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  124244. * @param taskName defines the name of the new task
  124245. * @param url defines the url of the file to load
  124246. * @param size defines the size you want for the cubemap (can be null)
  124247. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  124248. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  124249. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  124250. * @returns a new EquiRectangularCubeTextureAssetTask object
  124251. */
  124252. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  124253. /**
  124254. * Remove a task from the assets manager.
  124255. * @param task the task to remove
  124256. */
  124257. removeTask(task: AbstractAssetTask): void;
  124258. private _decreaseWaitingTasksCount;
  124259. private _runTask;
  124260. /**
  124261. * Reset the AssetsManager and remove all tasks
  124262. * @return the current instance of the AssetsManager
  124263. */
  124264. reset(): AssetsManager;
  124265. /**
  124266. * Start the loading process
  124267. * @return the current instance of the AssetsManager
  124268. */
  124269. load(): AssetsManager;
  124270. /**
  124271. * Start the loading process as an async operation
  124272. * @return a promise returning the list of failed tasks
  124273. */
  124274. loadAsync(): Promise<void>;
  124275. }
  124276. }
  124277. declare module BABYLON {
  124278. /**
  124279. * Wrapper class for promise with external resolve and reject.
  124280. */
  124281. export class Deferred<T> {
  124282. /**
  124283. * The promise associated with this deferred object.
  124284. */
  124285. readonly promise: Promise<T>;
  124286. private _resolve;
  124287. private _reject;
  124288. /**
  124289. * The resolve method of the promise associated with this deferred object.
  124290. */
  124291. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  124292. /**
  124293. * The reject method of the promise associated with this deferred object.
  124294. */
  124295. readonly reject: (reason?: any) => void;
  124296. /**
  124297. * Constructor for this deferred object.
  124298. */
  124299. constructor();
  124300. }
  124301. }
  124302. declare module BABYLON {
  124303. /**
  124304. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  124305. */
  124306. export class MeshExploder {
  124307. private _centerMesh;
  124308. private _meshes;
  124309. private _meshesOrigins;
  124310. private _toCenterVectors;
  124311. private _scaledDirection;
  124312. private _newPosition;
  124313. private _centerPosition;
  124314. /**
  124315. * Explodes meshes from a center mesh.
  124316. * @param meshes The meshes to explode.
  124317. * @param centerMesh The mesh to be center of explosion.
  124318. */
  124319. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  124320. private _setCenterMesh;
  124321. /**
  124322. * Get class name
  124323. * @returns "MeshExploder"
  124324. */
  124325. getClassName(): string;
  124326. /**
  124327. * "Exploded meshes"
  124328. * @returns Array of meshes with the centerMesh at index 0.
  124329. */
  124330. getMeshes(): Array<Mesh>;
  124331. /**
  124332. * Explodes meshes giving a specific direction
  124333. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  124334. */
  124335. explode(direction?: number): void;
  124336. }
  124337. }
  124338. declare module BABYLON {
  124339. /**
  124340. * Class used to help managing file picking and drag'n'drop
  124341. */
  124342. export class FilesInput {
  124343. /**
  124344. * List of files ready to be loaded
  124345. */
  124346. static readonly FilesToLoad: {
  124347. [key: string]: File;
  124348. };
  124349. /**
  124350. * Callback called when a file is processed
  124351. */
  124352. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  124353. private _engine;
  124354. private _currentScene;
  124355. private _sceneLoadedCallback;
  124356. private _progressCallback;
  124357. private _additionalRenderLoopLogicCallback;
  124358. private _textureLoadingCallback;
  124359. private _startingProcessingFilesCallback;
  124360. private _onReloadCallback;
  124361. private _errorCallback;
  124362. private _elementToMonitor;
  124363. private _sceneFileToLoad;
  124364. private _filesToLoad;
  124365. /**
  124366. * Creates a new FilesInput
  124367. * @param engine defines the rendering engine
  124368. * @param scene defines the hosting scene
  124369. * @param sceneLoadedCallback callback called when scene is loaded
  124370. * @param progressCallback callback called to track progress
  124371. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  124372. * @param textureLoadingCallback callback called when a texture is loading
  124373. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  124374. * @param onReloadCallback callback called when a reload is requested
  124375. * @param errorCallback callback call if an error occurs
  124376. */
  124377. 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);
  124378. private _dragEnterHandler;
  124379. private _dragOverHandler;
  124380. private _dropHandler;
  124381. /**
  124382. * Calls this function to listen to drag'n'drop events on a specific DOM element
  124383. * @param elementToMonitor defines the DOM element to track
  124384. */
  124385. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  124386. /**
  124387. * Release all associated resources
  124388. */
  124389. dispose(): void;
  124390. private renderFunction;
  124391. private drag;
  124392. private drop;
  124393. private _traverseFolder;
  124394. private _processFiles;
  124395. /**
  124396. * Load files from a drop event
  124397. * @param event defines the drop event to use as source
  124398. */
  124399. loadFiles(event: any): void;
  124400. private _processReload;
  124401. /**
  124402. * Reload the current scene from the loaded files
  124403. */
  124404. reload(): void;
  124405. }
  124406. }
  124407. declare module BABYLON {
  124408. /**
  124409. * Defines the root class used to create scene optimization to use with SceneOptimizer
  124410. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124411. */
  124412. export class SceneOptimization {
  124413. /**
  124414. * Defines the priority of this optimization (0 by default which means first in the list)
  124415. */
  124416. priority: number;
  124417. /**
  124418. * Gets a string describing the action executed by the current optimization
  124419. * @returns description string
  124420. */
  124421. getDescription(): string;
  124422. /**
  124423. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124424. * @param scene defines the current scene where to apply this optimization
  124425. * @param optimizer defines the current optimizer
  124426. * @returns true if everything that can be done was applied
  124427. */
  124428. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124429. /**
  124430. * Creates the SceneOptimization object
  124431. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124432. * @param desc defines the description associated with the optimization
  124433. */
  124434. constructor(
  124435. /**
  124436. * Defines the priority of this optimization (0 by default which means first in the list)
  124437. */
  124438. priority?: number);
  124439. }
  124440. /**
  124441. * Defines an optimization used to reduce the size of render target textures
  124442. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124443. */
  124444. export class TextureOptimization extends SceneOptimization {
  124445. /**
  124446. * Defines the priority of this optimization (0 by default which means first in the list)
  124447. */
  124448. priority: number;
  124449. /**
  124450. * 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
  124451. */
  124452. maximumSize: number;
  124453. /**
  124454. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124455. */
  124456. step: number;
  124457. /**
  124458. * Gets a string describing the action executed by the current optimization
  124459. * @returns description string
  124460. */
  124461. getDescription(): string;
  124462. /**
  124463. * Creates the TextureOptimization object
  124464. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124465. * @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
  124466. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124467. */
  124468. constructor(
  124469. /**
  124470. * Defines the priority of this optimization (0 by default which means first in the list)
  124471. */
  124472. priority?: number,
  124473. /**
  124474. * 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
  124475. */
  124476. maximumSize?: number,
  124477. /**
  124478. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  124479. */
  124480. step?: number);
  124481. /**
  124482. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124483. * @param scene defines the current scene where to apply this optimization
  124484. * @param optimizer defines the current optimizer
  124485. * @returns true if everything that can be done was applied
  124486. */
  124487. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124488. }
  124489. /**
  124490. * Defines an optimization used to increase or decrease the rendering resolution
  124491. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124492. */
  124493. export class HardwareScalingOptimization extends SceneOptimization {
  124494. /**
  124495. * Defines the priority of this optimization (0 by default which means first in the list)
  124496. */
  124497. priority: number;
  124498. /**
  124499. * Defines the maximum scale to use (2 by default)
  124500. */
  124501. maximumScale: number;
  124502. /**
  124503. * Defines the step to use between two passes (0.5 by default)
  124504. */
  124505. step: number;
  124506. private _currentScale;
  124507. private _directionOffset;
  124508. /**
  124509. * Gets a string describing the action executed by the current optimization
  124510. * @return description string
  124511. */
  124512. getDescription(): string;
  124513. /**
  124514. * Creates the HardwareScalingOptimization object
  124515. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124516. * @param maximumScale defines the maximum scale to use (2 by default)
  124517. * @param step defines the step to use between two passes (0.5 by default)
  124518. */
  124519. constructor(
  124520. /**
  124521. * Defines the priority of this optimization (0 by default which means first in the list)
  124522. */
  124523. priority?: number,
  124524. /**
  124525. * Defines the maximum scale to use (2 by default)
  124526. */
  124527. maximumScale?: number,
  124528. /**
  124529. * Defines the step to use between two passes (0.5 by default)
  124530. */
  124531. step?: number);
  124532. /**
  124533. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124534. * @param scene defines the current scene where to apply this optimization
  124535. * @param optimizer defines the current optimizer
  124536. * @returns true if everything that can be done was applied
  124537. */
  124538. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124539. }
  124540. /**
  124541. * Defines an optimization used to remove shadows
  124542. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124543. */
  124544. export class ShadowsOptimization extends SceneOptimization {
  124545. /**
  124546. * Gets a string describing the action executed by the current optimization
  124547. * @return description string
  124548. */
  124549. getDescription(): string;
  124550. /**
  124551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124552. * @param scene defines the current scene where to apply this optimization
  124553. * @param optimizer defines the current optimizer
  124554. * @returns true if everything that can be done was applied
  124555. */
  124556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124557. }
  124558. /**
  124559. * Defines an optimization used to turn post-processes off
  124560. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124561. */
  124562. export class PostProcessesOptimization extends SceneOptimization {
  124563. /**
  124564. * Gets a string describing the action executed by the current optimization
  124565. * @return description string
  124566. */
  124567. getDescription(): string;
  124568. /**
  124569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124570. * @param scene defines the current scene where to apply this optimization
  124571. * @param optimizer defines the current optimizer
  124572. * @returns true if everything that can be done was applied
  124573. */
  124574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124575. }
  124576. /**
  124577. * Defines an optimization used to turn lens flares off
  124578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124579. */
  124580. export class LensFlaresOptimization extends SceneOptimization {
  124581. /**
  124582. * Gets a string describing the action executed by the current optimization
  124583. * @return description string
  124584. */
  124585. getDescription(): string;
  124586. /**
  124587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124588. * @param scene defines the current scene where to apply this optimization
  124589. * @param optimizer defines the current optimizer
  124590. * @returns true if everything that can be done was applied
  124591. */
  124592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124593. }
  124594. /**
  124595. * Defines an optimization based on user defined callback.
  124596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124597. */
  124598. export class CustomOptimization extends SceneOptimization {
  124599. /**
  124600. * Callback called to apply the custom optimization.
  124601. */
  124602. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  124603. /**
  124604. * Callback called to get custom description
  124605. */
  124606. onGetDescription: () => string;
  124607. /**
  124608. * Gets a string describing the action executed by the current optimization
  124609. * @returns description string
  124610. */
  124611. getDescription(): string;
  124612. /**
  124613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124614. * @param scene defines the current scene where to apply this optimization
  124615. * @param optimizer defines the current optimizer
  124616. * @returns true if everything that can be done was applied
  124617. */
  124618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124619. }
  124620. /**
  124621. * Defines an optimization used to turn particles off
  124622. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124623. */
  124624. export class ParticlesOptimization extends SceneOptimization {
  124625. /**
  124626. * Gets a string describing the action executed by the current optimization
  124627. * @return description string
  124628. */
  124629. getDescription(): string;
  124630. /**
  124631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124632. * @param scene defines the current scene where to apply this optimization
  124633. * @param optimizer defines the current optimizer
  124634. * @returns true if everything that can be done was applied
  124635. */
  124636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124637. }
  124638. /**
  124639. * Defines an optimization used to turn render targets off
  124640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124641. */
  124642. export class RenderTargetsOptimization extends SceneOptimization {
  124643. /**
  124644. * Gets a string describing the action executed by the current optimization
  124645. * @return description string
  124646. */
  124647. getDescription(): string;
  124648. /**
  124649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124650. * @param scene defines the current scene where to apply this optimization
  124651. * @param optimizer defines the current optimizer
  124652. * @returns true if everything that can be done was applied
  124653. */
  124654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124655. }
  124656. /**
  124657. * Defines an optimization used to merge meshes with compatible materials
  124658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124659. */
  124660. export class MergeMeshesOptimization extends SceneOptimization {
  124661. private static _UpdateSelectionTree;
  124662. /**
  124663. * Gets or sets a boolean which defines if optimization octree has to be updated
  124664. */
  124665. /**
  124666. * Gets or sets a boolean which defines if optimization octree has to be updated
  124667. */
  124668. static UpdateSelectionTree: boolean;
  124669. /**
  124670. * Gets a string describing the action executed by the current optimization
  124671. * @return description string
  124672. */
  124673. getDescription(): string;
  124674. private _canBeMerged;
  124675. /**
  124676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124677. * @param scene defines the current scene where to apply this optimization
  124678. * @param optimizer defines the current optimizer
  124679. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  124680. * @returns true if everything that can be done was applied
  124681. */
  124682. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  124683. }
  124684. /**
  124685. * Defines a list of options used by SceneOptimizer
  124686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124687. */
  124688. export class SceneOptimizerOptions {
  124689. /**
  124690. * Defines the target frame rate to reach (60 by default)
  124691. */
  124692. targetFrameRate: number;
  124693. /**
  124694. * Defines the interval between two checkes (2000ms by default)
  124695. */
  124696. trackerDuration: number;
  124697. /**
  124698. * Gets the list of optimizations to apply
  124699. */
  124700. optimizations: SceneOptimization[];
  124701. /**
  124702. * Creates a new list of options used by SceneOptimizer
  124703. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  124704. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  124705. */
  124706. constructor(
  124707. /**
  124708. * Defines the target frame rate to reach (60 by default)
  124709. */
  124710. targetFrameRate?: number,
  124711. /**
  124712. * Defines the interval between two checkes (2000ms by default)
  124713. */
  124714. trackerDuration?: number);
  124715. /**
  124716. * Add a new optimization
  124717. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  124718. * @returns the current SceneOptimizerOptions
  124719. */
  124720. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  124721. /**
  124722. * Add a new custom optimization
  124723. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  124724. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  124725. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124726. * @returns the current SceneOptimizerOptions
  124727. */
  124728. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  124729. /**
  124730. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  124731. * @param targetFrameRate defines the target frame rate (60 by default)
  124732. * @returns a SceneOptimizerOptions object
  124733. */
  124734. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124735. /**
  124736. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  124737. * @param targetFrameRate defines the target frame rate (60 by default)
  124738. * @returns a SceneOptimizerOptions object
  124739. */
  124740. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124741. /**
  124742. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  124743. * @param targetFrameRate defines the target frame rate (60 by default)
  124744. * @returns a SceneOptimizerOptions object
  124745. */
  124746. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124747. }
  124748. /**
  124749. * Class used to run optimizations in order to reach a target frame rate
  124750. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124751. */
  124752. export class SceneOptimizer implements IDisposable {
  124753. private _isRunning;
  124754. private _options;
  124755. private _scene;
  124756. private _currentPriorityLevel;
  124757. private _targetFrameRate;
  124758. private _trackerDuration;
  124759. private _currentFrameRate;
  124760. private _sceneDisposeObserver;
  124761. private _improvementMode;
  124762. /**
  124763. * Defines an observable called when the optimizer reaches the target frame rate
  124764. */
  124765. onSuccessObservable: Observable<SceneOptimizer>;
  124766. /**
  124767. * Defines an observable called when the optimizer enables an optimization
  124768. */
  124769. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  124770. /**
  124771. * Defines an observable called when the optimizer is not able to reach the target frame rate
  124772. */
  124773. onFailureObservable: Observable<SceneOptimizer>;
  124774. /**
  124775. * Gets a boolean indicating if the optimizer is in improvement mode
  124776. */
  124777. readonly isInImprovementMode: boolean;
  124778. /**
  124779. * Gets the current priority level (0 at start)
  124780. */
  124781. readonly currentPriorityLevel: number;
  124782. /**
  124783. * Gets the current frame rate checked by the SceneOptimizer
  124784. */
  124785. readonly currentFrameRate: number;
  124786. /**
  124787. * Gets or sets the current target frame rate (60 by default)
  124788. */
  124789. /**
  124790. * Gets or sets the current target frame rate (60 by default)
  124791. */
  124792. targetFrameRate: number;
  124793. /**
  124794. * Gets or sets the current interval between two checks (every 2000ms by default)
  124795. */
  124796. /**
  124797. * Gets or sets the current interval between two checks (every 2000ms by default)
  124798. */
  124799. trackerDuration: number;
  124800. /**
  124801. * Gets the list of active optimizations
  124802. */
  124803. readonly optimizations: SceneOptimization[];
  124804. /**
  124805. * Creates a new SceneOptimizer
  124806. * @param scene defines the scene to work on
  124807. * @param options defines the options to use with the SceneOptimizer
  124808. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  124809. * @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)
  124810. */
  124811. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  124812. /**
  124813. * Stops the current optimizer
  124814. */
  124815. stop(): void;
  124816. /**
  124817. * Reset the optimizer to initial step (current priority level = 0)
  124818. */
  124819. reset(): void;
  124820. /**
  124821. * Start the optimizer. By default it will try to reach a specific framerate
  124822. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  124823. */
  124824. start(): void;
  124825. private _checkCurrentState;
  124826. /**
  124827. * Release all resources
  124828. */
  124829. dispose(): void;
  124830. /**
  124831. * Helper function to create a SceneOptimizer with one single line of code
  124832. * @param scene defines the scene to work on
  124833. * @param options defines the options to use with the SceneOptimizer
  124834. * @param onSuccess defines a callback to call on success
  124835. * @param onFailure defines a callback to call on failure
  124836. * @returns the new SceneOptimizer object
  124837. */
  124838. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  124839. }
  124840. }
  124841. declare module BABYLON {
  124842. /**
  124843. * Class used to serialize a scene into a string
  124844. */
  124845. export class SceneSerializer {
  124846. /**
  124847. * Clear cache used by a previous serialization
  124848. */
  124849. static ClearCache(): void;
  124850. /**
  124851. * Serialize a scene into a JSON compatible object
  124852. * @param scene defines the scene to serialize
  124853. * @returns a JSON compatible object
  124854. */
  124855. static Serialize(scene: Scene): any;
  124856. /**
  124857. * Serialize a mesh into a JSON compatible object
  124858. * @param toSerialize defines the mesh to serialize
  124859. * @param withParents defines if parents must be serialized as well
  124860. * @param withChildren defines if children must be serialized as well
  124861. * @returns a JSON compatible object
  124862. */
  124863. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  124864. }
  124865. }
  124866. declare module BABYLON {
  124867. /**
  124868. * Class used to host texture specific utilities
  124869. */
  124870. export class TextureTools {
  124871. /**
  124872. * Uses the GPU to create a copy texture rescaled at a given size
  124873. * @param texture Texture to copy from
  124874. * @param width defines the desired width
  124875. * @param height defines the desired height
  124876. * @param useBilinearMode defines if bilinear mode has to be used
  124877. * @return the generated texture
  124878. */
  124879. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  124880. }
  124881. }
  124882. declare module BABYLON {
  124883. /**
  124884. * This represents the different options available for the video capture.
  124885. */
  124886. export interface VideoRecorderOptions {
  124887. /** Defines the mime type of the video. */
  124888. mimeType: string;
  124889. /** Defines the FPS the video should be recorded at. */
  124890. fps: number;
  124891. /** Defines the chunk size for the recording data. */
  124892. recordChunckSize: number;
  124893. /** The audio tracks to attach to the recording. */
  124894. audioTracks?: MediaStreamTrack[];
  124895. }
  124896. /**
  124897. * This can help with recording videos from BabylonJS.
  124898. * This is based on the available WebRTC functionalities of the browser.
  124899. *
  124900. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124901. */
  124902. export class VideoRecorder {
  124903. private static readonly _defaultOptions;
  124904. /**
  124905. * Returns whether or not the VideoRecorder is available in your browser.
  124906. * @param engine Defines the Babylon Engine.
  124907. * @returns true if supported otherwise false.
  124908. */
  124909. static IsSupported(engine: Engine): boolean;
  124910. private readonly _options;
  124911. private _canvas;
  124912. private _mediaRecorder;
  124913. private _recordedChunks;
  124914. private _fileName;
  124915. private _resolve;
  124916. private _reject;
  124917. /**
  124918. * True when a recording is already in progress.
  124919. */
  124920. readonly isRecording: boolean;
  124921. /**
  124922. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124923. * @param engine Defines the BabylonJS Engine you wish to record.
  124924. * @param options Defines options that can be used to customize the capture.
  124925. */
  124926. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124927. /**
  124928. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124929. */
  124930. stopRecording(): void;
  124931. /**
  124932. * Starts recording the canvas for a max duration specified in parameters.
  124933. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124934. * If null no automatic download will start and you can rely on the promise to get the data back.
  124935. * @param maxDuration Defines the maximum recording time in seconds.
  124936. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124937. * @return A promise callback at the end of the recording with the video data in Blob.
  124938. */
  124939. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124940. /**
  124941. * Releases internal resources used during the recording.
  124942. */
  124943. dispose(): void;
  124944. private _handleDataAvailable;
  124945. private _handleError;
  124946. private _handleStop;
  124947. }
  124948. }
  124949. declare module BABYLON {
  124950. /**
  124951. * Class containing a set of static utilities functions for screenshots
  124952. */
  124953. export class ScreenshotTools {
  124954. /**
  124955. * Captures a screenshot of the current rendering
  124956. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124957. * @param engine defines the rendering engine
  124958. * @param camera defines the source camera
  124959. * @param size This parameter can be set to a single number or to an object with the
  124960. * following (optional) properties: precision, width, height. If a single number is passed,
  124961. * it will be used for both width and height. If an object is passed, the screenshot size
  124962. * will be derived from the parameters. The precision property is a multiplier allowing
  124963. * rendering at a higher or lower resolution
  124964. * @param successCallback defines the callback receives a single parameter which contains the
  124965. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124966. * src parameter of an <img> to display it
  124967. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124968. * Check your browser for supported MIME types
  124969. */
  124970. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  124971. /**
  124972. * Captures a screenshot of the current rendering
  124973. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124974. * @param engine defines the rendering engine
  124975. * @param camera defines the source camera
  124976. * @param size This parameter can be set to a single number or to an object with the
  124977. * following (optional) properties: precision, width, height. If a single number is passed,
  124978. * it will be used for both width and height. If an object is passed, the screenshot size
  124979. * will be derived from the parameters. The precision property is a multiplier allowing
  124980. * rendering at a higher or lower resolution
  124981. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124982. * Check your browser for supported MIME types
  124983. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124984. * to the src parameter of an <img> to display it
  124985. */
  124986. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124987. /**
  124988. * Generates an image screenshot from the specified camera.
  124989. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124990. * @param engine The engine to use for rendering
  124991. * @param camera The camera to use for rendering
  124992. * @param size This parameter can be set to a single number or to an object with the
  124993. * following (optional) properties: precision, width, height. If a single number is passed,
  124994. * it will be used for both width and height. If an object is passed, the screenshot size
  124995. * will be derived from the parameters. The precision property is a multiplier allowing
  124996. * rendering at a higher or lower resolution
  124997. * @param successCallback The callback receives a single parameter which contains the
  124998. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124999. * src parameter of an <img> to display it
  125000. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125001. * Check your browser for supported MIME types
  125002. * @param samples Texture samples (default: 1)
  125003. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125004. * @param fileName A name for for the downloaded file.
  125005. */
  125006. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  125007. /**
  125008. * Generates an image screenshot from the specified camera.
  125009. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  125010. * @param engine The engine to use for rendering
  125011. * @param camera The camera to use for rendering
  125012. * @param size This parameter can be set to a single number or to an object with the
  125013. * following (optional) properties: precision, width, height. If a single number is passed,
  125014. * it will be used for both width and height. If an object is passed, the screenshot size
  125015. * will be derived from the parameters. The precision property is a multiplier allowing
  125016. * rendering at a higher or lower resolution
  125017. * @param mimeType The MIME type of the screenshot image (default: image/png).
  125018. * Check your browser for supported MIME types
  125019. * @param samples Texture samples (default: 1)
  125020. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  125021. * @param fileName A name for for the downloaded file.
  125022. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  125023. * to the src parameter of an <img> to display it
  125024. */
  125025. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  125026. /**
  125027. * Gets height and width for screenshot size
  125028. * @private
  125029. */
  125030. private static _getScreenshotSize;
  125031. }
  125032. }
  125033. declare module BABYLON {
  125034. /**
  125035. * A cursor which tracks a point on a path
  125036. */
  125037. export class PathCursor {
  125038. private path;
  125039. /**
  125040. * Stores path cursor callbacks for when an onchange event is triggered
  125041. */
  125042. private _onchange;
  125043. /**
  125044. * The value of the path cursor
  125045. */
  125046. value: number;
  125047. /**
  125048. * The animation array of the path cursor
  125049. */
  125050. animations: Animation[];
  125051. /**
  125052. * Initializes the path cursor
  125053. * @param path The path to track
  125054. */
  125055. constructor(path: Path2);
  125056. /**
  125057. * Gets the cursor point on the path
  125058. * @returns A point on the path cursor at the cursor location
  125059. */
  125060. getPoint(): Vector3;
  125061. /**
  125062. * Moves the cursor ahead by the step amount
  125063. * @param step The amount to move the cursor forward
  125064. * @returns This path cursor
  125065. */
  125066. moveAhead(step?: number): PathCursor;
  125067. /**
  125068. * Moves the cursor behind by the step amount
  125069. * @param step The amount to move the cursor back
  125070. * @returns This path cursor
  125071. */
  125072. moveBack(step?: number): PathCursor;
  125073. /**
  125074. * Moves the cursor by the step amount
  125075. * If the step amount is greater than one, an exception is thrown
  125076. * @param step The amount to move the cursor
  125077. * @returns This path cursor
  125078. */
  125079. move(step: number): PathCursor;
  125080. /**
  125081. * Ensures that the value is limited between zero and one
  125082. * @returns This path cursor
  125083. */
  125084. private ensureLimits;
  125085. /**
  125086. * Runs onchange callbacks on change (used by the animation engine)
  125087. * @returns This path cursor
  125088. */
  125089. private raiseOnChange;
  125090. /**
  125091. * Executes a function on change
  125092. * @param f A path cursor onchange callback
  125093. * @returns This path cursor
  125094. */
  125095. onchange(f: (cursor: PathCursor) => void): PathCursor;
  125096. }
  125097. }
  125098. declare module BABYLON {
  125099. /** @hidden */
  125100. export var blurPixelShader: {
  125101. name: string;
  125102. shader: string;
  125103. };
  125104. }
  125105. declare module BABYLON {
  125106. /** @hidden */
  125107. export var pointCloudVertexDeclaration: {
  125108. name: string;
  125109. shader: string;
  125110. };
  125111. }
  125112. // Mixins
  125113. interface Window {
  125114. mozIndexedDB: IDBFactory;
  125115. webkitIndexedDB: IDBFactory;
  125116. msIndexedDB: IDBFactory;
  125117. webkitURL: typeof URL;
  125118. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  125119. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  125120. WebGLRenderingContext: WebGLRenderingContext;
  125121. MSGesture: MSGesture;
  125122. CANNON: any;
  125123. AudioContext: AudioContext;
  125124. webkitAudioContext: AudioContext;
  125125. PointerEvent: any;
  125126. Math: Math;
  125127. Uint8Array: Uint8ArrayConstructor;
  125128. Float32Array: Float32ArrayConstructor;
  125129. mozURL: typeof URL;
  125130. msURL: typeof URL;
  125131. VRFrameData: any; // WebVR, from specs 1.1
  125132. DracoDecoderModule: any;
  125133. setImmediate(handler: (...args: any[]) => void): number;
  125134. }
  125135. interface HTMLCanvasElement {
  125136. requestPointerLock(): void;
  125137. msRequestPointerLock?(): void;
  125138. mozRequestPointerLock?(): void;
  125139. webkitRequestPointerLock?(): void;
  125140. /** Track wether a record is in progress */
  125141. isRecording: boolean;
  125142. /** Capture Stream method defined by some browsers */
  125143. captureStream(fps?: number): MediaStream;
  125144. }
  125145. interface CanvasRenderingContext2D {
  125146. msImageSmoothingEnabled: boolean;
  125147. }
  125148. interface MouseEvent {
  125149. mozMovementX: number;
  125150. mozMovementY: number;
  125151. webkitMovementX: number;
  125152. webkitMovementY: number;
  125153. msMovementX: number;
  125154. msMovementY: number;
  125155. }
  125156. interface Navigator {
  125157. mozGetVRDevices: (any: any) => any;
  125158. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125159. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125160. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125161. webkitGetGamepads(): Gamepad[];
  125162. msGetGamepads(): Gamepad[];
  125163. webkitGamepads(): Gamepad[];
  125164. }
  125165. interface HTMLVideoElement {
  125166. mozSrcObject: any;
  125167. }
  125168. interface Math {
  125169. fround(x: number): number;
  125170. imul(a: number, b: number): number;
  125171. }
  125172. interface WebGLRenderingContext {
  125173. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  125174. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  125175. vertexAttribDivisor(index: number, divisor: number): void;
  125176. createVertexArray(): any;
  125177. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  125178. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  125179. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  125180. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  125181. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  125182. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  125183. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  125184. // Queries
  125185. createQuery(): WebGLQuery;
  125186. deleteQuery(query: WebGLQuery): void;
  125187. beginQuery(target: number, query: WebGLQuery): void;
  125188. endQuery(target: number): void;
  125189. getQueryParameter(query: WebGLQuery, pname: number): any;
  125190. getQuery(target: number, pname: number): any;
  125191. MAX_SAMPLES: number;
  125192. RGBA8: number;
  125193. READ_FRAMEBUFFER: number;
  125194. DRAW_FRAMEBUFFER: number;
  125195. UNIFORM_BUFFER: number;
  125196. HALF_FLOAT_OES: number;
  125197. RGBA16F: number;
  125198. RGBA32F: number;
  125199. R32F: number;
  125200. RG32F: number;
  125201. RGB32F: number;
  125202. R16F: number;
  125203. RG16F: number;
  125204. RGB16F: number;
  125205. RED: number;
  125206. RG: number;
  125207. R8: number;
  125208. RG8: number;
  125209. UNSIGNED_INT_24_8: number;
  125210. DEPTH24_STENCIL8: number;
  125211. /* Multiple Render Targets */
  125212. drawBuffers(buffers: number[]): void;
  125213. readBuffer(src: number): void;
  125214. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  125215. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  125216. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  125217. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  125218. // Occlusion Query
  125219. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  125220. ANY_SAMPLES_PASSED: number;
  125221. QUERY_RESULT_AVAILABLE: number;
  125222. QUERY_RESULT: number;
  125223. }
  125224. interface WebGLProgram {
  125225. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  125226. }
  125227. interface EXT_disjoint_timer_query {
  125228. QUERY_COUNTER_BITS_EXT: number;
  125229. TIME_ELAPSED_EXT: number;
  125230. TIMESTAMP_EXT: number;
  125231. GPU_DISJOINT_EXT: number;
  125232. QUERY_RESULT_EXT: number;
  125233. QUERY_RESULT_AVAILABLE_EXT: number;
  125234. queryCounterEXT(query: WebGLQuery, target: number): void;
  125235. createQueryEXT(): WebGLQuery;
  125236. beginQueryEXT(target: number, query: WebGLQuery): void;
  125237. endQueryEXT(target: number): void;
  125238. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  125239. deleteQueryEXT(query: WebGLQuery): void;
  125240. }
  125241. interface WebGLUniformLocation {
  125242. _currentState: any;
  125243. }
  125244. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  125245. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  125246. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  125247. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125248. interface WebGLRenderingContext {
  125249. readonly RASTERIZER_DISCARD: number;
  125250. readonly DEPTH_COMPONENT24: number;
  125251. readonly TEXTURE_3D: number;
  125252. readonly TEXTURE_2D_ARRAY: number;
  125253. readonly TEXTURE_COMPARE_FUNC: number;
  125254. readonly TEXTURE_COMPARE_MODE: number;
  125255. readonly COMPARE_REF_TO_TEXTURE: number;
  125256. readonly TEXTURE_WRAP_R: number;
  125257. readonly HALF_FLOAT: number;
  125258. readonly RGB8: number;
  125259. readonly RED_INTEGER: number;
  125260. readonly RG_INTEGER: number;
  125261. readonly RGB_INTEGER: number;
  125262. readonly RGBA_INTEGER: number;
  125263. readonly R8_SNORM: number;
  125264. readonly RG8_SNORM: number;
  125265. readonly RGB8_SNORM: number;
  125266. readonly RGBA8_SNORM: number;
  125267. readonly R8I: number;
  125268. readonly RG8I: number;
  125269. readonly RGB8I: number;
  125270. readonly RGBA8I: number;
  125271. readonly R8UI: number;
  125272. readonly RG8UI: number;
  125273. readonly RGB8UI: number;
  125274. readonly RGBA8UI: number;
  125275. readonly R16I: number;
  125276. readonly RG16I: number;
  125277. readonly RGB16I: number;
  125278. readonly RGBA16I: number;
  125279. readonly R16UI: number;
  125280. readonly RG16UI: number;
  125281. readonly RGB16UI: number;
  125282. readonly RGBA16UI: number;
  125283. readonly R32I: number;
  125284. readonly RG32I: number;
  125285. readonly RGB32I: number;
  125286. readonly RGBA32I: number;
  125287. readonly R32UI: number;
  125288. readonly RG32UI: number;
  125289. readonly RGB32UI: number;
  125290. readonly RGBA32UI: number;
  125291. readonly RGB10_A2UI: number;
  125292. readonly R11F_G11F_B10F: number;
  125293. readonly RGB9_E5: number;
  125294. readonly RGB10_A2: number;
  125295. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  125296. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  125297. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  125298. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  125299. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  125300. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  125301. 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;
  125302. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  125303. readonly TRANSFORM_FEEDBACK: number;
  125304. readonly INTERLEAVED_ATTRIBS: number;
  125305. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  125306. createTransformFeedback(): WebGLTransformFeedback;
  125307. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  125308. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  125309. beginTransformFeedback(primitiveMode: number): void;
  125310. endTransformFeedback(): void;
  125311. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  125312. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125313. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125314. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  125315. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  125316. }
  125317. interface ImageBitmap {
  125318. readonly width: number;
  125319. readonly height: number;
  125320. close(): void;
  125321. }
  125322. interface WebGLQuery extends WebGLObject {
  125323. }
  125324. declare var WebGLQuery: {
  125325. prototype: WebGLQuery;
  125326. new(): WebGLQuery;
  125327. };
  125328. interface WebGLSampler extends WebGLObject {
  125329. }
  125330. declare var WebGLSampler: {
  125331. prototype: WebGLSampler;
  125332. new(): WebGLSampler;
  125333. };
  125334. interface WebGLSync extends WebGLObject {
  125335. }
  125336. declare var WebGLSync: {
  125337. prototype: WebGLSync;
  125338. new(): WebGLSync;
  125339. };
  125340. interface WebGLTransformFeedback extends WebGLObject {
  125341. }
  125342. declare var WebGLTransformFeedback: {
  125343. prototype: WebGLTransformFeedback;
  125344. new(): WebGLTransformFeedback;
  125345. };
  125346. interface WebGLVertexArrayObject extends WebGLObject {
  125347. }
  125348. declare var WebGLVertexArrayObject: {
  125349. prototype: WebGLVertexArrayObject;
  125350. new(): WebGLVertexArrayObject;
  125351. };
  125352. // Type definitions for WebVR API
  125353. // Project: https://w3c.github.io/webvr/
  125354. // Definitions by: six a <https://github.com/lostfictions>
  125355. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  125356. interface VRDisplay extends EventTarget {
  125357. /**
  125358. * Dictionary of capabilities describing the VRDisplay.
  125359. */
  125360. readonly capabilities: VRDisplayCapabilities;
  125361. /**
  125362. * z-depth defining the far plane of the eye view frustum
  125363. * enables mapping of values in the render target depth
  125364. * attachment to scene coordinates. Initially set to 10000.0.
  125365. */
  125366. depthFar: number;
  125367. /**
  125368. * z-depth defining the near plane of the eye view frustum
  125369. * enables mapping of values in the render target depth
  125370. * attachment to scene coordinates. Initially set to 0.01.
  125371. */
  125372. depthNear: number;
  125373. /**
  125374. * An identifier for this distinct VRDisplay. Used as an
  125375. * association point in the Gamepad API.
  125376. */
  125377. readonly displayId: number;
  125378. /**
  125379. * A display name, a user-readable name identifying it.
  125380. */
  125381. readonly displayName: string;
  125382. readonly isConnected: boolean;
  125383. readonly isPresenting: boolean;
  125384. /**
  125385. * If this VRDisplay supports room-scale experiences, the optional
  125386. * stage attribute contains details on the room-scale parameters.
  125387. */
  125388. readonly stageParameters: VRStageParameters | null;
  125389. /**
  125390. * Passing the value returned by `requestAnimationFrame` to
  125391. * `cancelAnimationFrame` will unregister the callback.
  125392. * @param handle Define the hanle of the request to cancel
  125393. */
  125394. cancelAnimationFrame(handle: number): void;
  125395. /**
  125396. * Stops presenting to the VRDisplay.
  125397. * @returns a promise to know when it stopped
  125398. */
  125399. exitPresent(): Promise<void>;
  125400. /**
  125401. * Return the current VREyeParameters for the given eye.
  125402. * @param whichEye Define the eye we want the parameter for
  125403. * @returns the eye parameters
  125404. */
  125405. getEyeParameters(whichEye: string): VREyeParameters;
  125406. /**
  125407. * Populates the passed VRFrameData with the information required to render
  125408. * the current frame.
  125409. * @param frameData Define the data structure to populate
  125410. * @returns true if ok otherwise false
  125411. */
  125412. getFrameData(frameData: VRFrameData): boolean;
  125413. /**
  125414. * Get the layers currently being presented.
  125415. * @returns the list of VR layers
  125416. */
  125417. getLayers(): VRLayer[];
  125418. /**
  125419. * Return a VRPose containing the future predicted pose of the VRDisplay
  125420. * when the current frame will be presented. The value returned will not
  125421. * change until JavaScript has returned control to the browser.
  125422. *
  125423. * The VRPose will contain the position, orientation, velocity,
  125424. * and acceleration of each of these properties.
  125425. * @returns the pose object
  125426. */
  125427. getPose(): VRPose;
  125428. /**
  125429. * Return the current instantaneous pose of the VRDisplay, with no
  125430. * prediction applied.
  125431. * @returns the current instantaneous pose
  125432. */
  125433. getImmediatePose(): VRPose;
  125434. /**
  125435. * The callback passed to `requestAnimationFrame` will be called
  125436. * any time a new frame should be rendered. When the VRDisplay is
  125437. * presenting the callback will be called at the native refresh
  125438. * rate of the HMD. When not presenting this function acts
  125439. * identically to how window.requestAnimationFrame acts. Content should
  125440. * make no assumptions of frame rate or vsync behavior as the HMD runs
  125441. * asynchronously from other displays and at differing refresh rates.
  125442. * @param callback Define the eaction to run next frame
  125443. * @returns the request handle it
  125444. */
  125445. requestAnimationFrame(callback: FrameRequestCallback): number;
  125446. /**
  125447. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  125448. * Repeat calls while already presenting will update the VRLayers being displayed.
  125449. * @param layers Define the list of layer to present
  125450. * @returns a promise to know when the request has been fulfilled
  125451. */
  125452. requestPresent(layers: VRLayer[]): Promise<void>;
  125453. /**
  125454. * Reset the pose for this display, treating its current position and
  125455. * orientation as the "origin/zero" values. VRPose.position,
  125456. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  125457. * updated when calling resetPose(). This should be called in only
  125458. * sitting-space experiences.
  125459. */
  125460. resetPose(): void;
  125461. /**
  125462. * The VRLayer provided to the VRDisplay will be captured and presented
  125463. * in the HMD. Calling this function has the same effect on the source
  125464. * canvas as any other operation that uses its source image, and canvases
  125465. * created without preserveDrawingBuffer set to true will be cleared.
  125466. * @param pose Define the pose to submit
  125467. */
  125468. submitFrame(pose?: VRPose): void;
  125469. }
  125470. declare var VRDisplay: {
  125471. prototype: VRDisplay;
  125472. new(): VRDisplay;
  125473. };
  125474. interface VRLayer {
  125475. leftBounds?: number[] | Float32Array | null;
  125476. rightBounds?: number[] | Float32Array | null;
  125477. source?: HTMLCanvasElement | null;
  125478. }
  125479. interface VRDisplayCapabilities {
  125480. readonly canPresent: boolean;
  125481. readonly hasExternalDisplay: boolean;
  125482. readonly hasOrientation: boolean;
  125483. readonly hasPosition: boolean;
  125484. readonly maxLayers: number;
  125485. }
  125486. interface VREyeParameters {
  125487. /** @deprecated */
  125488. readonly fieldOfView: VRFieldOfView;
  125489. readonly offset: Float32Array;
  125490. readonly renderHeight: number;
  125491. readonly renderWidth: number;
  125492. }
  125493. interface VRFieldOfView {
  125494. readonly downDegrees: number;
  125495. readonly leftDegrees: number;
  125496. readonly rightDegrees: number;
  125497. readonly upDegrees: number;
  125498. }
  125499. interface VRFrameData {
  125500. readonly leftProjectionMatrix: Float32Array;
  125501. readonly leftViewMatrix: Float32Array;
  125502. readonly pose: VRPose;
  125503. readonly rightProjectionMatrix: Float32Array;
  125504. readonly rightViewMatrix: Float32Array;
  125505. readonly timestamp: number;
  125506. }
  125507. interface VRPose {
  125508. readonly angularAcceleration: Float32Array | null;
  125509. readonly angularVelocity: Float32Array | null;
  125510. readonly linearAcceleration: Float32Array | null;
  125511. readonly linearVelocity: Float32Array | null;
  125512. readonly orientation: Float32Array | null;
  125513. readonly position: Float32Array | null;
  125514. readonly timestamp: number;
  125515. }
  125516. interface VRStageParameters {
  125517. sittingToStandingTransform?: Float32Array;
  125518. sizeX?: number;
  125519. sizeY?: number;
  125520. }
  125521. interface Navigator {
  125522. getVRDisplays(): Promise<VRDisplay[]>;
  125523. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  125524. }
  125525. interface Window {
  125526. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  125527. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  125528. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  125529. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125530. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  125531. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  125532. }
  125533. interface Gamepad {
  125534. readonly displayId: number;
  125535. }
  125536. type XRSessionMode =
  125537. | "inline"
  125538. | "immersive-vr"
  125539. | "immersive-ar";
  125540. type XRReferenceSpaceType =
  125541. | "viewer"
  125542. | "local"
  125543. | "local-floor"
  125544. | "bounded-floor"
  125545. | "unbounded";
  125546. type XREnvironmentBlendMode =
  125547. | "opaque"
  125548. | "additive"
  125549. | "alpha-blend";
  125550. type XRVisibilityState =
  125551. | "visible"
  125552. | "visible-blurred"
  125553. | "hidden";
  125554. type XRHandedness =
  125555. | "none"
  125556. | "left"
  125557. | "right";
  125558. type XRTargetRayMode =
  125559. | "gaze"
  125560. | "tracked-pointer"
  125561. | "screen";
  125562. type XREye =
  125563. | "none"
  125564. | "left"
  125565. | "right";
  125566. interface XRSpace extends EventTarget {
  125567. }
  125568. interface XRRenderState {
  125569. depthNear?: number;
  125570. depthFar?: number;
  125571. inlineVerticalFieldOfView?: number;
  125572. baseLayer?: XRWebGLLayer;
  125573. }
  125574. interface XRInputSource {
  125575. handedness: XRHandedness;
  125576. targetRayMode: XRTargetRayMode;
  125577. targetRaySpace: XRSpace;
  125578. gripSpace: XRSpace | undefined;
  125579. gamepad: Gamepad | undefined;
  125580. profiles: Array<string>;
  125581. }
  125582. interface XRSession {
  125583. addEventListener: Function;
  125584. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  125585. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  125586. requestAnimationFrame: Function;
  125587. end(): Promise<void>;
  125588. renderState: XRRenderState;
  125589. inputSources: Array<XRInputSource>;
  125590. }
  125591. interface XRReferenceSpace extends XRSpace {
  125592. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  125593. onreset: any;
  125594. }
  125595. interface XRFrame {
  125596. session: XRSession;
  125597. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  125598. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  125599. }
  125600. interface XRViewerPose extends XRPose {
  125601. views: Array<XRView>;
  125602. }
  125603. interface XRPose {
  125604. transform: XRRigidTransform;
  125605. emulatedPosition: boolean;
  125606. }
  125607. declare var XRWebGLLayer: {
  125608. prototype: XRWebGLLayer;
  125609. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  125610. };
  125611. interface XRWebGLLayer {
  125612. framebuffer: WebGLFramebuffer;
  125613. framebufferWidth: number;
  125614. framebufferHeight: number;
  125615. getViewport: Function;
  125616. }
  125617. interface XRRigidTransform {
  125618. position: DOMPointReadOnly;
  125619. orientation: DOMPointReadOnly;
  125620. matrix: Float32Array;
  125621. inverse: XRRigidTransform;
  125622. }
  125623. interface XRView {
  125624. eye: XREye;
  125625. projectionMatrix: Float32Array;
  125626. transform: XRRigidTransform;
  125627. }
  125628. interface XRInputSourceChangeEvent {
  125629. session: XRSession;
  125630. removed: Array<XRInputSource>;
  125631. added: Array<XRInputSource>;
  125632. }